fn
ldl_solve
→Tensorldl_solve(LD: Tensor, pivots: Tensor, B: Tensor)Solve a symmetric linear system using an LDL factorization.
Given produced by ldl_factor,
solves
by chaining three substitutions:
followed by an inverse permutation to undo the Bunch-Kaufman row swaps.
Parameters
LDTensorPacked LDL factor from
ldl_factor, shape (n, n).pivotsTensorPivot 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.BTensorRight-hand side of shape
(n, k) (or (n,)).Returns
TensorSolution , same shape as B.
Notes
Supports indefinite symmetric (unlike Cholesky), so it is appropriate for KKT / saddle-point systems where Cholesky would fail. Cost per solve is 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)