Skip to content
fn

ldl_factor_op

→std::vector<TensorImplPtr> of size 3
int ldl_factor_op(const int & a)

Python wrappers

Public Python APIs implemented by this engine symbol.

Compute the LDL⊤^\top factorisation of a symmetric matrix.

Returns the packed factor and the pivot index tensor. Both follow the LAPACK *sytrf storage convention so they are consumable by lucid.linalg.ldl_solve (which composes triangular solves). Batched inputs are supported: leading dimensions are treated as independent matrices and the factorisation is run on each N×NN \times N slice.

Math

PAP⊤=LDL⊤, P A P^\top = L D L^\top,

where PP is the permutation implied by the pivots, LL is unit lower-triangular, and DD is block-diagonal with 1×\times1 and 2×\times2 blocks. The 2×\times2 blocks are necessary when no scalar pivot can be chosen without losing numerical stability — this is what allows the factorisation to handle indefinite AA.

Shape

  • a : (..., N, N).
  • return [0] : (..., N, N).
  • return [1] : (..., N).
  • return [2] : (...).

See Also

  • cholesky_op — cheaper alternative when AA is SPD.
  • solve_triangular_op — building block for ldl_solve.

Parameters

aTensorImplPtr
Square symmetric matrix of shape (..., N, N) with dtype F32 or F64. The matrix need not be positive definite; only the lower triangle is read.

Returns

std::vector<TensorImplPtr> of size 3
  • [0] packed factor LD of shape (..., N, N), same dtype as a. Strict lower triangle stores LL (unit diagonal implicit); diagonal and sub-diagonal entries jointly encode DD including 2×\times2 pivot blocks. - [1] pivot tensor of shape (..., N), dtype I32, following the LAPACK ipiv convention (positive: 1×\times1 pivot; pair of equal negatives: 2×\times2 pivot block). - [2] info of the batch shape (...), dtype I32: sytrf's code per matrix — 0, or the first zero (or NaN) 1×\times1 block of DD.

Raises

LucidError
If a is not at least 2-D, not square, or has a non-float dtype. A singular DD completes the factorisation and is reported through info, never raised.

Notes

  • No autograd node is registered; the outputs are leaves.
  • The current ldl_solve wrapper in lucid.linalg only supports 1×\times1 pivots (no 2×\times2 Bunch-Kaufman block solving yet).