solve_triangular(A: Tensor, B: Tensor, upper: bool = True, left: bool = True, unitriangular: bool = False)Implementing kernel
C++ engine symbols that back this Python API.Solve a triangular linear system by back/forward substitution.
Solves the system (or ) in which the coefficient matrix is triangular. For upper-triangular the system is solved by back-substitution starting from the last row; for lower-triangular by forward substitution from the first row. Either direction runs in time and is numerically stable when the diagonal of is well-conditioned.
Parameters
(*, n, n). Only
the relevant triangle is read; the other half is ignored.(*, n, k) or (n,); batch dims broadcast with A.upper(bool, keyword - only)= TrueTrue (default) is upper-triangular; if
False lower-triangular.left(bool, keyword - only)= TrueTrue (default) solves ; if False
solves via transposition.unitriangular(bool, keyword - only)= FalseTrue the diagonal of is treated as all-ones
regardless of its stored values (LAPACK's "unit-diagonal"
mode).Returns
TensorSolution — the broadcast batch, then (n, k) (or (n,)).
Notes
Backed by BLAS trsm on both devices. Triangular solves are the
workhorse used inside Cholesky, LU, and QR back-substitution paths.
A singular (an exact zero on the diagonal, with
unitriangular=False) is not refused: substitution divides by the
zero, so the solution holds , or NaN where it meets
, as the reference framework does.
Examples
>>> import lucid
>>> from lucid.linalg import solve_triangular
>>> A = lucid.tensor([[2.0, 1.0], [0.0, 3.0]]) # upper
>>> b = lucid.tensor([[5.0], [9.0]])
>>> solve_triangular(A, b, upper=True)
tensor([[1.], [3.]])