fn
inv_ex
→Tensorinv_ex(A: Tensor, check_errors: bool = False)Matrix inverse with an explicit success flag.
Variant of inv that returns an info code instead of
raising on a singular input.
info == 0— success;Ainvis .info != 0— was singular;Ainvis zero-filled.
Parameters
ATensorSquare matrix of shape
(*, n, n).check_errors(bool, keyword - only)= FalseIf
True, re-raise the underlying engine error instead of
emitting a non-zero info.Returns
TensorInverse (or zero placeholder) of shape (*, n, n).
Notes
Useful in algorithms that occasionally probe near-singular
matrices (e.g., iterative refinement, regularisation grid
searches) without wanting to wrap every call in a try.
Examples
>>> import lucid
>>> from lucid.linalg import inv_ex
>>> Ainv, info = inv_ex(lucid.tensor([[1.0, 2.0], [3.0, 4.0]]))
>>> int(info)
0