-
Notifications
You must be signed in to change notification settings - Fork 60
Cannot solve Ax = B for sparse matrices A, B #117
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
Comments
See also JuliaLang/LinearAlgebra.jl#381 |
For this very specific case, I think we could provide the missing ldiv!(::Diagonal{Bool,Array{Bool,1}}, ::SparseMatrixCSC{Float64,Int64}) easily. For the more general case, would it make sense to have the column-by-colum solver the default? Extracting columns from |
Hm, actually why not something like function mydiv!(C::AbstractMatrix, A::SparseMatrixCSC, B::SparseMatrixCSC)
F = factorize(A)
return mydiv!(C, F, B)
end
function mydiv!(C::AbstractMatrix, F::Factorization, B::SparseMatrixCSC)
@views for (c, b) in zip(eachcol(C), eachcol(B))
ldiv!(c, F, b)
end
return C
end I couldn't find how |
The issue is, column-wise division doesn't seem to work either in general. I have not yet determined when you can divide by a sparse column. |
You said in the OP it does work, and I tested my code snippet. |
That's what confuses me. It sometimes works for some matrices and sometimes doesn't. It works if you're dividing a sparse identity matrix by a sparse column vector but not always.
Sorry, I should have made that clearer. I'll amend my original post soon.
?? Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Daniel Karrasch <[email protected]>
Sent: Thursday, December 12, 2019 12:49:35 PM
To: JuliaLang/julia <[email protected]>
Cc: lzxnl <[email protected]>; Author <[email protected]>
Subject: Re: [JuliaLang/julia] Cannot solve Ax = B for sparse matrices A, B (#34052)
You said in the OP it does work, and I tested my code snippet.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://github.com/JuliaLang/julia/issues/34052?email_source=notifications&email_token=ANNNDYZ5MPU7WOHS7MR6FR3QYJ2S7A5CNFSM4JYDAK42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGXPBZQ#issuecomment-565113062>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANNNDY4AVWCML3OYYU5EHVDQYJ2S7ANCNFSM4JYDAK4Q>.
|
Maybe the failure you're seeing with sparse vectors has nothing to do with the sparse vectors, but simply with the fact that the sparse matrix is singular? If it works sometimes, i.e., you don't get a
Yes, providing the error message should help to clarify what exactly doesn't work. |
A = sprand(100,100,0.5) MethodError: no method matching ldiv!(::SuiteSparse.UMFPACK.UmfpackLU{Float64,Int64}, ::SparseVector{Float64,Int64}) However, B\C goes through. |
It looks like there's a routine there specifically for the identity. |
No, the special method is for |
This works now. |
A\B works if A is a sparse matrix and B is a sparse vector. A\B does not work if B is a sparse matrix.
Example:
Sometimes I can get around this by dividing column by column, but it's nevertheless still a strange bug to have.
The text was updated successfully, but these errors were encountered: