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

**URL:** <https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693>\
**Category:** Specific Domains\
**Tags:** package, linearalgebra\
**Created:** [May 3, 2020, 7:10pm UTC](https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693 "2020-05-03T19:10:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrhiemstra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rrhiemstra/32/12263_2.png) [@rrhiemstra](https://discourse.julialang.org/u/rrhiemstra)\
**Post date:** [May 3, 2020, 7:10pm UTC](https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693/1 "2020-05-03T19:10:30Z")

</div>

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}
> 
> ```

---

<div class="post-metadata">

**Author:** ![eliassno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eliassno/32/18917_2.png) [@eliassno](https://discourse.julialang.org/u/eliassno)\
**Post date:** [May 3, 2020, 9:25pm UTC](https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693/2 "2020-05-03T21:25:42Z")

</div>

Maybe this could be done with [Kronecker.jl](https://github.com/MichielStock/Kronecker.jl).

---

<div class="post-metadata">

**Author:** ![rrhiemstra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rrhiemstra/32/12263_2.png) [@rrhiemstra](https://discourse.julialang.org/u/rrhiemstra)\
**Post date:** [May 3, 2020, 9:40pm UTC](https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693/3 "2020-05-03T21:40:27Z")

</div>

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](https://github.com/JuliaLang/julia/issues) for this issue.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 4, 2020, 10:56am UTC](https://discourse.julialang.org/t/change-svd-s-vector-tr-to-svd-s-abstractvector-tr/38693/4 "2020-05-04T10:56:39Z")

</div>

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.
