-
-
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
Error in A_ldiv_B! with sparse matrix #7488
Comments
@JeffBezanson It was strange that the above commit fixed this bug. I wonder if this is a compiler issue. |
And this wasn't caught by any of the existing tests in |
@ViralBShah I don't think that the commit changes anything for this example. With latest master I still get the @CodeLenz I am not sure it is a bug. When calling What you might want to do is either
or
|
Hi. It worked with the previous versions. As I understand, lufact!(A) stores the LU factors of |
If you mean to factorize A and use the factorization to solve a linear problem, you'll need to save the factorization object and call backslash on that. julia> B=copy(A); Z=lufact!(B)
UMFPACK LU Factorization of a 3-by-3 sparse matrix
Ptr{Void} @0x00007f85ab78d8c0
julia> typeof(B) #Julia still thinks it is a sparse matrix
SparseMatrixCSC{Float64,Int64} (constructor with 2 methods)
julia> Z\b
3-element Array{Float64,1}:
1.0
1.0
1.0
julia> @which Z\b #Uses the factorization object
\{TF<:Number,TB<:Number,N}(F::Factorization{TF<:Number},B::AbstractArray{TB<:Number,N}) at linalg/factorization.jl:798
julia> @which A\b #Doesn't use the factorization object
@\{TA,TB,N}(A::AbstractArray{TA,2},B::AbstractArray{TB,N}) at linalg/generic.jl:227
|
@jiahao I see ...thanks. I will look more carefully before posting another bug report. But I have no idea why it used to work before and the ! mark lead me to this conclusion....so....my bad. Thank you all for this amazing tool. I just found it and I am porting all my tools (FInite element and optimization) to it. |
It could be that you were just lucky before, since the specific memory access patterns can vary a lot. |
The documentation could use some extra clarification here. In the vast majority of cases, |
Is there a way to make it an error to access |
I do think that we should not allow |
All of the |
Yes, I guess that even though the solution is returned in the input, it is not really in usable form. |
How about a test for valid indices when calling |
A simple test for valid indices is whether the first element of the It turns out that the only difference in behavior between |
The right (medium-level, with reusable factorizations - |
I am pretty sure such a thing will be there in the umfpack interface. |
Whoops, yep, there they are in It could be almost-as-dangerous (maybe more since it doesn't error?) and confusing to accidentally misuse a dense matrix that has had As @dmbates said, "in place" is not so much a thing with sparse. You do often want multiple factorizations in a row with the same sparsity pattern but changed nzval. |
Yeah, I think this is the right thing to do. It is certainly doable in 0.3. |
All the |
I think cheap error checking is an easy way to avoid confusion. Removing the |
Another possibility is to simply nudge the pointer values back to 1-based indexing after calling UMFPACK functions. |
@jiahao Seems reasonable. |
We have now removed |
@andreasnoack Should we disallow
|
I see that it has a fallback to the generic implementation. Perhaps we need an explicit method to disallow it for sparse? |
I think it is safe to restrict that method to |
Fixed in 9c72dec |
This is still a potential concern. But I don't think our current |
I agree. The generic |
In case you did not already know, see: https://github.com/JuliaSparse/MultiFrontalCholesky.jl |
That's great to see a start for a pure-Julia sparse solver implementation. So far that's working at a pretty low level though, the API refinement will need to happen somewhat separately from and in parallel with the pure-Julia solver implementations. Ideally we want a design somewhat like MathProgBase where different low-level solvers (some in Julia, some in C or C++ or Fortran) can plug into a uniform set of interfaces, to present the same API to consumers (whether users directly working with sparse linear algebra, or higher-level libraries like optimization solvers). This probably should happen outside of base to start with. Though to truly resolve JuliaLang/LinearAlgebra.jl#136 and make sparse matrices first-class citizens, the way base Julia deals with dense matrices will eventually have to adapt in order to generically handle either dense or sparse matrices for all operations. |
Hi.
I just found a bug in A_ldiv_B! when used with a sparse matrix
factored with lufact!
The error is trigered with
ERROR: BoundsError()
in istriu at sparse/sparsematrix.jl:1748
in unsafe_copy! at array.jl:41
in A_ldiv_B! at linalg/sparse.jl:209
julia> versioninfo()
Julia Version 0.3.0-prerelease+3952
Commit b2fd3af (2014-06-30 01:39 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
LAPACK: libopenblas
LIBM: libopenlibm
It was working with the previous versions.
Sincerely yours,
Eduardo.
The text was updated successfully, but these errors were encountered: