Skip to content
fn

lu_factor_ex

→Tensor
lu_factor_ex(A: Tensor, pivot: bool = True, check_errors: bool = False)

LU factorization with partial pivoting and an explicit status.

Variant of lu_factor that returns the factors of a singular matrix too, with an info code following LAPACK getrf:

  • info == 0 — every pivot UkkU_{kk} is non-zero.
  • info == k > 0 — UkkU_{kk} is the first exactly-zero pivot (1-based). The factorization is still complete, but AA is singular and lu_solve divides by that pivot.

Parameters

Matrix of shape (*, m, n). Need not be square.
pivot(bool, keyword - only)= True
Must be True (the default); unpivoted LU is not implemented and raises NotImplementedError.
check_errors(bool, keyword - only)= False
If True, raise LinAlgError for the first singular matrix instead of reporting it through info.

Returns

Tensor

Packed factorization of shape (*, m, n), as lu_factor.

Examples

>>> import lucid
>>> from lucid.linalg import lu_factor_ex
>>> LU, piv, info = lu_factor_ex(lucid.tensor([[1.0, 2.0], [2.0, 4.0]]))
>>> int(info)
2

Used by 1