KrylovKit.jl icon indicating copy to clipboard operation
KrylovKit.jl copied to clipboard

SVD on big floats

Open matbesancon opened this issue 4 years ago • 4 comments

Observed on master and Julia 1.5, svdsolve does not seem to work with BigFloats:

julia> using KrylovKit
julia> direction = rand(BigFloat, 4, 3)

julia> svdsolve(direction)
ERROR: MethodError: no method matching bidiagsvd!(::LinearAlgebra.Bidiagonal{BigFloat,SubArray{BigFloat,1,Array{BigFloat,1},Tuple{UnitRange{Int64}},true}}, ::SubArray{BigFloat,2,Array{BigFloat,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::SubArray{BigFloat,2,Array{BigFloat,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false})
Stacktrace:
 [1] svdsolve(::Array{BigFloat,2}, ::Array{BigFloat,1}, ::Int64, ::Symbol, ::GKL{ModifiedGramSchmidt2,Float64}) at /home/mbesancon/.julia/packages/KrylovKit/OLgKs/src/eigsolve/svdsolve.jl:155
 [2] svdsolve(::Array{BigFloat,2}, ::Array{BigFloat,1}, ::Int64, ::Symbol; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/mbesancon/.julia/packages/KrylovKit/OLgKs/src/eigsolve/svdsolve.jl:109
 [3] svdsolve(::Array{BigFloat,2}, ::Array{BigFloat,1}, ::Int64, ::Symbol) at /home/mbesancon/.julia/packages/KrylovKit/OLgKs/src/eigsolve/svdsolve.jl:106
 [4] svdsolve(::Array{BigFloat,2}, ::Int64, ::Symbol, ::Type{T} where T; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/mbesancon/.julia/packages/KrylovKit/OLgKs/src/eigsolve/svdsolve.jl:101
 [5] svdsolve(::Array{BigFloat,2}, ::Int64, ::Symbol, ::Type{T} where T) at /home/mbesancon/.julia/packages/KrylovKit/OLgKs/src/eigsolve/svdsolve.jl:101 (repeats 2 times)
 [6] top-level scope at REPL[4]:1

matbesancon avatar Feb 18 '21 19:02 matbesancon

KrylovKit still uses the julia LinearAlgebra standard library, or thus BLAS and LAPACK, for dealing with the small problems projected on the Krylov subspace. So it is currently restricted to the same eltypes as LAPACK. I would love to see this changed in the future, but I don't expect to have any time for this anywhere soon.

Jutho avatar Feb 18 '21 20:02 Jutho

Thanks, indeed I tracked down some issues in the Julia repo itself. Could it rely on GenericSVD? https://github.com/JuliaLinearAlgebra/GenericSVD.jl/

matbesancon avatar Feb 18 '21 20:02 matbesancon

It could, but so far I did not find the time to implement these backends. It also seems there is some fragmentation of linear algebra routines for generic numbers / BigFloat across different packages.

Jutho avatar Mar 26 '21 14:03 Jutho

Edit on this: GenericSVD is deprecated, GenericLinearAlgebra implements all the necessary features I believe?

matbesancon avatar Jul 07 '21 18:07 matbesancon