Change SVD.S::Vector{Tr} to SVD.S::AbstractVector{Tr}

I am developing a new package for Kronecker product matrices

A ⊗ B ⊗ .... 

I want to support efficient factorizations for these type of matrices and want to use the types in LinearAlgebra.jl

Here follows the type definition of SVD in LinearAlgebra/src/svd.jl

struct SVD{T,Tr,M<:AbstractArray{T}} <: Factorization{T}
U::M
S::Vector{Tr}
Vt::M
function SVD{T,Tr,M}(U, S, Vt) where {T,Tr,M<:AbstractArray{T}}
require_one_based_indexing(U, S, Vt)
new{T,Tr,M}(U, S, Vt)
end
end

Storage of the singular values in a standard Vector is sub-optimal for an svd of Kronecker products. Can we make the following change?

S::Vector{Tr}

to

S::AbstractVector{Tr}

Maybe this could be done with Kronecker.jl.

In Kronecker.jl they decided to define their own Factorization types instead of using the parametric ones in LinearAlgebra.jl. I should probably open an issue at Issues · JuliaLang/julia · GitHub for this issue.

1 Like

You can not replace a concretely typed field with an abstractly typed field, that would kill performance. You could potentially make the vector type a type parameter, but I’m not sure if this would be considered a breaking change since it would change the type definition.

2 Likes