lu_solve(LU: Tensor, pivots: Tensor, B: Tensor, left: bool = True, adjoint: bool = False)Implementing kernel
C++ engine symbols that back this Python API.Solve a linear system from a precomputed LU factorization.
Given the packed factorization returned by
lu_factor, solves
by applying the permutation and performing two triangular solves (forward + back substitution).
Parameters
LUTensorPacked LU factor of shape
(*, n, n) from lu_factor.pivotsTensorPivot indices of shape
(*, n) from lu_factor
(1-based, LAPACK convention).Right-hand side
(*, n, k), broadcast against LU; a vector is refused.left(bool, keyword - only)= TrueIf
True (default), solve ; False solves
.adjoint(bool, keyword - only)= FalseIf
True, solve with instead of .
Default False.Returns
TensorSolution : broadcast batch, then (n, k).
Notes
Backed by LAPACK getrs. Cost per solve is —
much cheaper than a fresh solve () when the
same is reused.
Examples
>>> import lucid
>>> from lucid.linalg import lu_factor, lu_solve
>>> A = lucid.tensor([[3.0, 1.0], [1.0, 2.0]])
>>> LU, piv = lu_factor(A)
>>> b = lucid.tensor([[9.0], [8.0]])
>>> lu_solve(LU, piv, b)
tensor([[2.], [3.]])