Skip to content
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

lufact ill condition on sparse matrix #13781

Closed
colinfang opened this issue Oct 26, 2015 · 2 comments
Closed

lufact ill condition on sparse matrix #13781

colinfang opened this issue Oct 26, 2015 · 2 comments
Labels

Comments

@colinfang
Copy link
Contributor

Basically, I cannot use lufact on a simple sparse matrix, but the dense version works fine.

Forgive me if I missed something obvious. Is it a result of some linear algebra concept?

A = sparse(Int[],Int[],Float64[], 3,3)
A[1,1] = 1
A[3,1] = 1
A[3,3] = 1
A[1,3] = 1

full(A)
3x3 Array{Float64,2}:
 1.0  0.0  1.0
 0.0  0.0  0.0
 1.0  0.0  1.0

B = lufact(A)
LoadError: Base.SparseMatrix.UMFPACK.MatrixIllConditionedException("")

B = lufact(full(A))

Base.LinAlg.LU{Float64,Array{Float64,2}}(3x3 Array{Float64,2}:
 1.0  0.0  1.0
 0.0  0.0  0.0
 1.0  0.0  0.0,Int32[1,2,3],2)
@kshyatt kshyatt added domain:linear algebra Linear algebra domain:arrays:sparse Sparse arrays labels Oct 26, 2015
@andreasnoack
Copy link
Member

The matrix you are trying to factorize is singular and therefore the factorization fails. That is the case for both the sparse and the dense version. If you look at the result from the dense factorization, you'll see a 2 after the Int32[1,2,3] which is an error code. The factorization has failed when that value is larger that zero.

In the sparse case we throw an exception when the matrix is singular instead of returning the failed factorization. You could argue that we are inconsistent here and maybe we should not throw an exception in the sparse case. Note, however, that you cannot do much with a failed LU factorization. The reason why we don't throw in the dense case is because we want to use the information to compute det(A)=0, see #1499, and indeed

julia> det(A)
ERROR: Base.SparseMatrix.UMFPACK.MatrixIllConditionedException("")
 in umfpack_numeric! at sparse/umfpack.jl:173
 in lufact at sparse/umfpack.jl:114
 in det at linalg/generic.jl:508

@colinfang
Copy link
Contributor Author

thank you for the explanation.

@jiahao jiahao closed this as completed Oct 27, 2015
andreasnoack added a commit that referenced this issue Oct 28, 2015
Don't throw in sparse LU for singular matrices. Fixes #13781.
andreasnoack added a commit that referenced this issue Oct 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants