JuliaLinearAlgebra / SkewLinearAlgebra.jl

Julia Package for skew-symmetric matrices
MIT License
19 stars 5 forks source link

transpose and adjoint #104

Open stevengj opened 2 years ago

stevengj commented 2 years ago

Currently we override transpose and adjoint to make copies here: https://github.com/JuliaLinearAlgebra/SkewLinearAlgebra.jl/blob/main/src/skewhermitian.jl#L115-L116

Instead, the right thing to do is to use the default definitions of these functions, which create Transpose and Adjoint wrappers around the matrix without making a copy.

Ideally, one then defines specialized methods for Adjoint{<:SkewHermitian} which exploit the fact that it is merely a sign flip.

smataigne commented 2 years ago

I will transform these functions now.

smataigne commented 2 years ago

@stevengj , if I am correct, this will ask to create a new file trying to mimic the following file: https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/adjtrans.jl

stevengj commented 2 years ago

No, you shouldn't need to mimic that whole file — that defines lots of methods for Adjoint{<:AbstractMatrix} that should automatically apply to Adjoint{<:SkewHermitian}.

What is needed is that whenever you have a specialized matrix method for SkewHermitian, you might need to also define one for Adjoint{<:SkewHermitian} that just flips the sign of the result (e.g. for multiplying two matrices).

Still requires a fair amount of code, so I'm not 100% sure if it's worth it. On the other hand, the usual expectation in Julia is that A' doesn't make a copy.