fn
solve
→Tensorsolve(A: Tensor, b: Tensor)Solve a square linear system .
Returns the unique solution of the system
where is a non-singular square matrix. The system is solved by LU decomposition with partial pivoting, which is both faster and more accurate than forming explicitly.
Parameters
ATensorSquare coefficient matrix of shape
(*, n, n).bTensorRight-hand side of shape
(*, n, k) (multiple RHS columns) or
(*, n) (single RHS vector).Returns
TensorSolution with the same shape as b.
Notes
Algorithm: factor , then perform forward-substitution followed by back-substitution . Total cost is .
Examples
>>> import lucid
>>> from lucid.linalg import solve
>>> A = lucid.tensor([[3.0, 1.0], [1.0, 2.0]])
>>> b = lucid.tensor([9.0, 8.0])
>>> solve(A, b)
Tensor([2.0000, 3.0000])