# Missing sparse methods

**URL:** <https://discourse.julialang.org/t/missing-sparse-methods/17596>\
**Category:** Numerics\
**Tags:** linearalgebra\
**Created:** [November 16, 2018, 2:41pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596 "2018-11-16T14:41:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Hines](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_hines/32/6107_2.png) [@Paul\_Hines](https://discourse.julialang.org/u/Paul_Hines)\
**Post date:** [November 16, 2018, 2:41pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596/1 "2018-11-16T14:41:48Z")

</div>

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

```julia
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})`

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)\
**Post date:** [November 16, 2018, 2:58pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596/2 "2018-11-16T14:58:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Paul\_Hines](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_hines/32/6107_2.png) [@Paul\_Hines](https://discourse.julialang.org/u/Paul_Hines)\
**Post date:** [November 16, 2018, 4:10pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596/3 "2018-11-16T16:10:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 16, 2018, 6:24pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596/4 "2018-11-16T18:24:10Z")

</div>

> [@Paul\_Hines](#):
>
> Also, why does `lu!(A)` not work for a sparse matrix?

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

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 24, 2022, 3:17pm UTC](https://discourse.julialang.org/t/missing-sparse-methods/17596/5 "2022-05-24T15:17:26Z")

</div>

A post was split to a new topic: [Sparse solve with sparse rhs](https://discourse.julialang.org/t/sparse-solve-with-sparse-rhs/81595)
