Missing sparse methods

linearalgebra

#1

It seems like there are missing sparse matrix methods. In both 1.0.2 and 0.7 this code:

using SparseArrays
using LinearAlgebra

A = sprand(10,10,.9)
b_dense = Array(sprand(10,1,.8)) # works
b_sparse = sprand(10,1,.8) # doesn't work
x = A\b_dense # works
x = A\b_sparse # doesn't work
lu!(A) # gives an error

produces these errors:
julia> x = A\b_sparse # error ERROR: MethodError: no method matching ldiv!(::SuiteSparse.UMFPACK.UmfpackLU{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64})
and
ERROR: MethodError: no method matching lu!(::SparseMatrixCSC{Float64,Int64})


#2

We use the library UMFPACK for solving problems with an asymmetric lhs and unfortunately the library doesn’t support a sparse rhs.


#3

That makes sense, but it seems like the error message could be a bit more user friendly.

Also, why does lu!(A) not work for a sparse matrix? The existing error for A\b pointed me to lu!, but lu!() doesn’t work. It seems odd that we can’t factor sparse matrices using the “default” version of lu.


#4

You should use lu(A). lu!(A) means that you want LU factorization in-place, which is not generally possible for sparse matrices.