### 15.3.9 LDL decomposition

The ldl command computes the LDL decomposition of the given symmetric (real or complex) or Hermitian matrix A.

- ldl takes one mandatory argument and a sequence of optional arguments:
  - A, a symmetric or Hermitian matrix.
  - Optionally, opts, a sequence of options, each of which is one of the following:
    - hermite, which must be passed alongside a Hermitian matrix A since no check is performed.
    - zip, which forces merging the output matrices L and D into matrix M.
- ldl(A⟨,opts⟩) returns the sequence p,L,D or p,M (if the option zip is passed), where p is the permutation defining the permutation matrix P (using permu2mat command), L is a unit lower triangular matrix and D is a tridiagonal matrix with 1- or 2-blocks on the diagonal. Matrix M is obtained by merging L and D together which saves the space while allowing unambiguous reconstruction of L and D. The following relation holds:

  PAPT=LDLT.

#### Example

A:=[[1,-1,2],[-1,4,3],[2,3,-5]]

⎡
⎢
⎢
⎣

1 | −1 | 2
−1 | 4 | 3
2 | 3 | −5

⎤
⎥
⎥
⎦

ldl(A)

⎡
⎣

0,2,1

⎤
⎦

,

⎡
⎢
⎢
⎢
⎢
⎢
⎣

1 | 0 | 0
2 | 1 | 0

−1

−

5
9

1

⎤
⎥
⎥
⎥
⎥
⎥
⎦

,

⎡
⎢
⎢
⎢
⎢
⎢
⎣

1 | 0 | 0
0 | −9 | 0

0

0

52
9

⎤
⎥
⎥
⎥
⎥
⎥
⎦