# Looking for documentation related to sparse matrix factorization

**URL:** <https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976>\
**Category:** Numerics\
**Created:** [March 17, 2019, 9:43pm UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976 "2019-03-17T21:43:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddMahen](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@siddMahen](https://discourse.julialang.org/u/siddMahen)\
**Post date:** [March 17, 2019, 9:43pm UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976/1 "2019-03-17T21:43:10Z")

</div>

This is surely a dumb question, but I can’t seem to find documentation describing LU factorization for sparse matrices. Could anyone direct me to the docs?

Thanks

---

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [March 17, 2019, 9:48pm UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976/2 "2019-03-17T21:48:38Z")

</div>

I’m pretty sure it’s all from SuiteSparse/UMFPack [suitesparse : a suite of sparse matrix software](http://faculty.cse.tamu.edu/davis/suitesparse.html) which uses a graph theoretic algorithm to determine optimal pivoting, which depends on the specific entries to avoid ill-conditioning.

In other words, it’s complicated and best treated as a black-box unless it’s your area of research.

---

<div class="post-metadata">

**Author:** ![siddMahen](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@siddMahen](https://discourse.julialang.org/u/siddMahen)\
**Post date:** [March 17, 2019, 11:35pm UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976/3 "2019-03-17T23:35:00Z")

</div>

Maybe I’m not being clear; I’m looking for the documentation describing what arguments the `lu()` function takes, what it returns etc when given a sparse input. For example, the documentation [here](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.lu) does not seem correct; try:

```julia
using LinearAlgebra
using SparseArrays

A = spzeros(2,2)
A[1:2, 1:2] = [1 1; -1 1]
F = lu(A)
print(F.L * F.U == A[F.p, :]) # false

```

---

<div class="post-metadata">

**Author:** ![aharoun](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aharoun/32/6887_2.png) [@aharoun](https://discourse.julialang.org/u/aharoun)\
**Post date:** [March 18, 2019, 12:17am UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976/4 "2019-03-18T00:17:33Z")

</div>

For sparse matrices, output of `lu` is slightly different. The following is from help mode of Julia REPL (notice the very last line):

```julia
  lu(A::SparseMatrixCSC; check = true) -> F::UmfpackLU

  Compute the LU factorization of a sparse matrix A.

  For sparse A with real or complex element type, the return type of F is UmfpackLU{Tv, Ti}, with Tv = Float64 or ComplexF64 respectively
  and Ti is an integer type (Int32 or Int64).

  When check = true, an error is thrown if the decomposition fails. When check = false, responsibility for checking the decomposition's
  validity (via issuccess) lies with the user.

  The individual components of the factorization F can be accessed by indexing:

Component Description                    
––––––––– –––––––––––––––––––––––––––––––
L L (lower triangular) part of LU
U U (upper triangular) part of LU
p right permutation Vector       
q left permutation Vector        
Rs Vector of scaling factors      
: (L,U,p,q,Rs) components        

  The relation between F and A is

  F.L*F.U == (F.Rs .* A)[F.p, F.q]

```

---

<div class="post-metadata">

**Author:** ![siddMahen](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@siddMahen](https://discourse.julialang.org/u/siddMahen)\
**Post date:** [March 22, 2019, 9:15pm UTC](https://discourse.julialang.org/t/looking-for-documentation-related-to-sparse-matrix-factorization/21976/5 "2019-03-22T21:15:16Z")

</div>

Thanks! This is exactly what I was looking for. Is there any reason why this isn’t part of the Julia docs?
