Implementing kernel
C++ engine symbols that back this Python API.LDL factorization of a symmetric (or Hermitian) matrix.
For a real symmetric matrix (possibly indefinite), computes a Bunch-Kaufman block factorization
where is unit-lower-triangular and is
block-diagonal with or
blocks. Unlike cholesky, this factorization exists for
indefinite symmetric matrices (e.g., saddle-point systems).
Parameters
(*, n, n).hermitian(bool, keyword - only)= FalseA is Hermitian rather than symmetric. A real
A is both, so either value factors it the same. Default
False, as the reference's.Returns
TensorPacked factor of shape (*, n, n). The strict lower
triangle holds ; the diagonal holds 's
entries ( blocks are stored in the
sub-diagonal). The strict upper triangle is zero.
Raises
LinAlgErrorldl_factor_ex returns it with a non-zero info instead.Notes
Backed by LAPACK sytrf. Cost is . Pair
with ldl_solve for solving symmetric indefinite systems.
sytrf writes the factor into the lower triangle and leaves the
upper one as it found it — the input's own entries. Those are
cleared here, so LD holds the factorization and nothing else.
LD is differentiable in A, to any order, wherever the pivots
do not change — an addition over the reference framework, which
defines no derivative for this factorization and raises on backward.
The gradient lands on A's lower triangle, the part sytrf
reads, as cholesky's does.
Examples
>>> import lucid
>>> from lucid.linalg import ldl_factor
>>> A = lucid.tensor([[4.0, 1.0], [1.0, 3.0]])
>>> LD, piv = ldl_factor(A)
>>> LD
tensor([[4., 0.], [0.25, 2.75]])
>>> piv
tensor([1, 2], dtype=lucid.int32)