Skip to content
fn

ldl_factor_ex

→LD, pivots : Tensor
ldl_factor_ex(input: Tensor, hermitian: bool = False, check_errors: bool = False)

LDL factorization with an explicit status.

Variant of ldl_factor that returns the factors of a matrix whose DD is singular too, with an info code following LAPACK sytrf:

  • info == 0 — DD is non-singular.
  • info == k > 0 — DkkD_{kk}, a 1×11 \times 1 block, is the first one that is exactly zero (or NaN), 1-based. The factorization is complete, but ldl_solve would divide by that block.

Parameters

inputTensor
Symmetric / Hermitian matrix of shape (*, n, n).
hermitian(bool, keyword - only)= False
As ldl_factor. Default False.
check_errors(bool, keyword - only)= False
If True, raise LinAlgError for the first failed matrix instead of reporting it through info.

Returns

LD, pivots : Tensor

The packed factor (*, n, n) and int32 pivots (*, n), as ldl_factor returns them.

Notes

LD differentiates as ldl_factor's does — the reference framework does not differentiate it. A matrix whose info is non-zero receives no gradient, as a failed matrix of the other *_ex variants does.

Examples

>>> import lucid
>>> from lucid.linalg import ldl_factor_ex
>>> LD, piv, info = ldl_factor_ex(lucid.zeros(2, 2))
>>> int(info)
1

Used by 1