Skip to content

BoundsError bug in SVD for zero matrix #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chriscoey opened this issue Mar 31, 2023 · 2 comments · Fixed by #120
Closed

BoundsError bug in SVD for zero matrix #119

chriscoey opened this issue Mar 31, 2023 · 2 comments · Fixed by #120

Comments

@chriscoey
Copy link

I see the following behavior in v0.3.8 (not sure when it started, but this error did not occur before about Dec 5, 2022, the last time I ran Hypatia.jl's test suite):

julia> svd(zeros(BigFloat, 2, 2))
ERROR: BoundsError: attempt to access 1-element Vector{BigFloat} at index [0]
Stacktrace:
 [1] setindex!
   @ ./array.jl:966 [inlined]
 [2] svdDemmelKahan!(B::Bidiagonal{BigFloat, Vector{BigFloat}}, n1::Int64, n2::Int64, U::Matrix{BigFloat}, Vᴴ::Matrix{BigFloat})
   @ GenericLinearAlgebra ~/.julia/packages/GenericLinearAlgebra/ilNvI/src/svd.jl:110
 [3] __svd!(B::Bidiagonal{BigFloat, Vector{BigFloat}}, U::Matrix{BigFloat}, Vᴴ::Matrix{BigFloat}; tol::BigFloat, debug::Bool)
   @ GenericLinearAlgebra ~/.julia/packages/GenericLinearAlgebra/ilNvI/src/svd.jl:184
 [4] _svd!(B::Bidiagonal{BigFloat, Vector{BigFloat}}; tol::BigFloat, debug::Bool)
   @ GenericLinearAlgebra ~/.julia/packages/GenericLinearAlgebra/ilNvI/src/svd.jl:301
 [5] svd!(A::Matrix{BigFloat}; tol::BigFloat, full::Bool, alg::LinearAlgebra.DivideAndConquer, debug::Bool)
   @ GenericLinearAlgebra ~/.julia/packages/GenericLinearAlgebra/ilNvI/src/svd.jl:658
 [6] #svd#114
   @ ~/julia/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/svd.jl:179 [inlined]
 [7] svd(A::Matrix{BigFloat})
   @ LinearAlgebra ~/julia/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/svd.jl:178
 [8] top-level scope
   @ REPL[15]:1
@andreasnoack
Copy link
Member

So the bounds error is not present on master. I made some simplifications to the code and apparently that also fixed the issue you are hitting here. However, I noticed an issue with the U matrix which was zeroed by the sign flipping postprocessing because sign(0)==0. I'm fixing that in #120 and will make a release once it's merged.

@chriscoey
Copy link
Author

Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants