fn

ldl_solve

Tensor
ldl_solve(LD: Tensor, pivots: Tensor, B: Tensor)
source

Solve a symmetric linear system using an LDL factorization.

Given A=LDLA = L\,D\,L^\top produced by ldl_factor, solves

AX=BA\,X \,=\, B

by chaining three substitutions:

LY=PB,DZ=Y,LX=Z,L\,Y = P B, \quad D\,Z = Y, \quad L^\top X = Z,

followed by an inverse permutation to undo the Bunch-Kaufman row swaps.

Parameters

LDTensor
Packed LDL factor from ldl_factor, shape (n, n).
pivotsTensor
Pivot indices from ldl_factor. This implementation only supports 1×1 (simple) pivots — every entry must be strictly positive. Mixed 2×2 block pivots raise NotImplementedError.
BTensor
Right-hand side of shape (n, k) (or (n,)).

Returns

Tensor

Solution XX, same shape as B.

Notes

Supports indefinite symmetric AA (unlike Cholesky), so it is appropriate for KKT / saddle-point systems where Cholesky would fail. Cost per solve is O(n2k)O(n^2 k) once the LDL factor is in hand.

Examples

>>> import lucid
>>> from lucid.linalg import ldl_factor, ldl_solve
>>> A = lucid.tensor([[4.0, 1.0], [1.0, 3.0]])
>>> LD, piv = ldl_factor(A)
>>> b = lucid.tensor([[5.0], [4.0]])
>>> ldl_solve(LD, piv, b)