fn
lu
→Tensorlu(A: Tensor, pivot: bool = True)Full LU decomposition with explicit factors .
Decomposes a square matrix as
where is a row permutation, is unit-lower
triangular (ones on the diagonal), and is upper
triangular. Unlike lu_factor (which returns a packed
factor + integer pivots), this routine returns the three factors
as explicit dense tensors — convenient for inspection or for
re-using in downstream linear-algebra expressions.
Parameters
ATensorSquare matrix of shape
(n, n). Batched inputs are not
yet exposed through the Python wrapper (will raise).pivot(bool, keyword - only)= TrueMust be
True (the default). False would request an
unpivoted LU; Lucid does not currently ship that kernel and
raises NotImplementedError.Returns
TensorPermutation matrix of shape (n, n).
Notes
Implemented as a Python composite over lu_factor followed
by explicit triangular masking and pivot-to-matrix conversion.
Cost is , dominated by the underlying
factorization.
Examples
>>> import lucid
>>> from lucid.linalg import lu
>>> A = lucid.tensor([[2.0, 1.0], [4.0, 7.0]])
>>> P, L, U = lu(A)
>>> (P @ L @ U).numpy()
array([[2., 1.],
[4., 7.]], dtype=float32)