fn
cholesky_ex
→Tensorcholesky_ex(A: Tensor, upper: bool = False, check_errors: bool = False)Cholesky factorization with an explicit success flag.
Variant of cholesky that, instead of raising when the
input fails to be positive-definite, returns the factor together
with an integer info code following LAPACK's convention:
info == 0— success; (or ) is meaningful.info != 0— numerical failure; is zero-filled.
Parameters
ATensorCandidate SPD matrix of shape
(*, n, n).upper(bool, keyword - only)= FalseIf
True return the upper-triangular factor such
that . Default False.check_errors(bool, keyword - only)= FalseIf
True, re-raise the underlying engine error instead of
emitting a non-zero info — useful while debugging.Returns
TensorCholesky factor (or zeros on failure), shape (*, n, n).
Notes
Designed for code paths where a failed Cholesky is an expected
event (e.g., trial steps in trust-region optimisers). Callers
must inspect info before trusting L.
Examples
>>> import lucid
>>> from lucid.linalg import cholesky_ex
>>> A = lucid.tensor([[4.0, 2.0], [2.0, 3.0]])
>>> L, info = cholesky_ex(A)
>>> int(info)
0