-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix exception type for sparse LDLᵀ #33372
Conversation
Unfortunately, the fix here will probably be a bit more complicated. The current fix is still not accurate as julia/stdlib/SuiteSparse/src/cholmod.jl Lines 745 to 750 in 4f17558
julia> cholesky(sparse([0 1; 1 1]), check=false)\ones(2)
ERROR: PosDefException: matrix is not positive definite; Cholesky factorization failed.
Stacktrace:
[1] solve(::Int32, ::SuiteSparse.CHOLMOD.Factor{Float64}, ::SuiteSparse.CHOLMOD.Dense{Float64}) at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:747
[2] \ at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:1678 [inlined]
[3] \(::SuiteSparse.CHOLMOD.Factor{Float64}, ::Array{Float64,1}) at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:1683
[4] top-level scope at REPL[256]:1 |
The matrix julia> ldlt(sparse([0 1; 1 1]), check=false) \ ones(2)
ERROR: ArgumentError: factorized matrix has one or more zero pivots. Try using `lu` instead. |
Let me try again since I clearly wrote the last comment too early in the morning. What I think would still be wrong with this PR is ldlt(sparse([0 1; 1 1]) which will now throw julia> ldlt(sparse([0 1; 1 1]), check=false)\ones(2)
ERROR: ArgumentError: factorized matrix has one or more zero pivots. Try using `lu` instead.
Stacktrace:
[1] solve(::Int32, ::SuiteSparse.CHOLMOD.Factor{Float64}, ::SuiteSparse.CHOLMOD.Dense{Float64}) at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:749
[2] \ at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:1678 [inlined]
[3] \(::SuiteSparse.CHOLMOD.Factor{Float64}, ::Array{Float64,1}) at /Users/andreasnoack/julia/usr/share/julia/stdlib/v1.4/SuiteSparse/src/cholmod.jl:1683
[4] top-level scope at REPL[283]:1 |
Does SuiteSparse allow you to distinguish between the actually singular case and cases where there are just zero pivots for LDLt factorization? Maybe we need to define a new |
I don't think it has any idea if the matrix is singular or not. It only knows that it has hit a zero pivot.
Yes. That might be a good idea. Could also be useful in LU without pivoting. |
By the way, all of the |
Added the |
What's the status here? Does this look good to you now, @andreasnoack? |
Fixes JuliaLang/LinearAlgebra.jl#667.