# LDLt factorization for sparse matrix

**URL:** <https://discourse.julialang.org/t/ldlt-factorization-for-sparse-matrix/57011>\
**Category:** Specific Domains\
**Tags:** linearalgebra\
**Created:** [March 12, 2021, 10:05am UTC](https://discourse.julialang.org/t/ldlt-factorization-for-sparse-matrix/57011 "2021-03-12T10:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbakas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nbakas/32/10615_2.png) [@nbakas](https://discourse.julialang.org/u/nbakas)\
**Post date:** [March 12, 2021, 10:05am UTC](https://discourse.julialang.org/t/ldlt-factorization-for-sparse-matrix/57011/1 "2021-03-12T10:05:05Z")

</div>

I am trying to compute the LDLt factorization for sparse matrix, which is symmetric and positive definite, and get the L and D factors.

I tried many things, but I don’t yet have a solution. For example,

```julia
julia> C=ldlt(xss)
SuiteSparse.CHOLMOD.Factor{Float64}
type: LDLt
method: simplicial
maxnnz: 4073497
nnz: 1363617
success: true

```

returns

```julia
julia> C.L
SuiteSparse.CHOLMOD.FactorComponent{Float64,:L}
type: LDLt
method: simplicial
maxnnz: 4073497
nnz: 1363617
success: true

julia> C.D
SuiteSparse.CHOLMOD.FactorComponent{Float64,:D}
type: LDLt
method: simplicial
maxnnz: 4073497
nnz: 1363617
success: true

```

and

```julia
julia> sparse(C.L)
ERROR: SuiteSparse.CHOLMOD.CHOLMODException("sparse: supported only for :LD on LDLt factorizations")

```

I can get sparse(C.LD), but I need **separately L & D**.

Any ideas much appreciated!

---

<div class="post-metadata">

**Author:** ![nbakas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nbakas/32/10615_2.png) [@nbakas](https://discourse.julialang.org/u/nbakas)\
**Post date:** [March 12, 2021, 7:27pm UTC](https://discourse.julialang.org/t/ldlt-factorization-for-sparse-matrix/57011/2 "2021-03-12T19:27:38Z")

</div>

I think I’ve found it, the LD is the invperm of F.p indices

```julia
F=ldlt(xss)
LD=sparse(F.LD)
iok=invperm(F.p)
LDiok=LD[iok,iok]

```

and afterwards, D is the diag(LD) and L the LD with 1s in the diagonal

---

<div class="post-metadata">

**Author:** ![noil-reed](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noil-reed/32/24125_2.png) [@noil-reed](https://discourse.julialang.org/u/noil-reed)\
**Post date:** [August 14, 2021, 7:50pm UTC](https://discourse.julialang.org/t/ldlt-factorization-for-sparse-matrix/57011/3 "2021-08-14T19:50:27Z")

</div>

Same here, what is the current status of this? It really should have an interface for L and D seperately.
