Skip to content
fn

lu_factor_op

→std::vector<TensorImplPtr>
int lu_factor_op(const int & a)

Python wrappers

Public Python APIs implemented by this engine symbol.

Compute the LU factorisation PA=LUPA = LU of a square matrix.

Shape

  • Input a: (..., n, n).
  • Output LU_packed: (..., n, n).
  • Output pivots: (..., n) with Dtype::I32.
  • Output info: (...) with Dtype::I32.

References

LAPACK sgetrf/dgetrf; LAPACK Users' Guide §2.5.

See Also

[[lu_solve_op]] : Apply the factors to solve Ax=bAx = b. [[solve_op]] : End-to-end differentiable linear solve.

Parameters

aconst TensorImplPtr&
Square float tensor of shape (..., n, n). Leading dimensions are treated as independent batch axes — one factorisation is produced per batch element.

Returns

std::vector<TensorImplPtr>

A three-element vector {LU_packed, pivots, info}: - LU_packed has the same shape and dtype as a; its upper triangle holds UU and its strict lower triangle holds the off-diagonal entries of LL (unit diagonal is implicit). - pivots has shape (..., n) and dtype I32; entries are 1-based row indices matching the LAPACK convention. - info has the batch shape (...) and dtype I32: getrf's code per matrix, 0 or the first exactly-zero pivot (1-based).

Raises

LucidError
When a is below 2-D or not float-typed. A singular matrix is reported through info, never raised.