fn

ldl_factor

Tensor
ldl_factor(A: Tensor, hermitian: bool = True)
source

LDL factorization of a symmetric (or Hermitian) matrix.

For a real symmetric matrix AA (possibly indefinite), computes a Bunch-Kaufman block factorization

A=LDL,A \,=\, L\,D\,L^\top,

where LL is unit-lower-triangular and DD is block-diagonal with 1×11 \times 1 or 2×22 \times 2 blocks. Unlike cholesky, this factorization exists for indefinite symmetric matrices (e.g., saddle-point systems).

Parameters

ATensor
Symmetric / Hermitian matrix of shape (*, n, n).
hermitianbool= True
If True (default), treat A as Hermitian (conjugate symmetric in the complex case).

Returns

Tensor

Packed factor of shape (*, n, n). The strict lower triangle holds LL; the diagonal holds DD's entries (2×22 \times 2 blocks are stored in the sub-diagonal).

Notes

Backed by LAPACK sytrf. Cost is O(n3/3)O(n^3 / 3). Pair with ldl_solve for solving symmetric indefinite systems.

Examples

>>> import lucid
>>> from lucid.linalg import ldl_factor
>>> A = lucid.tensor([[1.0, 2.0], [2.0, 3.0]])
>>> LD, piv = ldl_factor(A)