Solves a triangular system of linear equations. When left_side = TRUE,
returns x such that op(a) %*% x = b. When left_side = FALSE,
returns x such that x %*% op(a) = b. Here op is a or t(a)
depending on transpose_a.
Usage
nv_triangular_solve(
a,
b,
left_side = TRUE,
lower = TRUE,
unit_diagonal = FALSE,
transpose_a = FALSE
)Arguments
- a
(
arrayish)
Triangular coefficient matrix with at least 2 dimensions. The last two dimensions must be equal; any leading dimensions are batch dimensions.- b
(
arrayish)
Right-hand side. Foraof shape(B..., n, n),bmay be either:full rank — shape
(B..., n, k)whenleft_side = TRUE, or(B..., k, n)whenleft_side = FALSE;one rank less, shape
(B..., n), meaning a single column (left_side = TRUE) or row (left_side = FALSE) per batch — it is reshaped internally and the reshape is undone on the result so the output rank matchesb.
b's batch dimensions (B...) must matcha's exactly.- left_side
(
logical(1))
IfTRUE(default), solveop(a) %*% x = b; ifFALSE, solvex %*% op(a) = b.- lower
(
logical(1))
Whetherais lower or upper triangular. Defaults toTRUE.- unit_diagonal
(
logical(1))
IfTRUE, the diagonal ofais treated as all ones (and the actual values on the diagonal are ignored). Defaults toFALSE.- transpose_a
(
logical(1))
IfTRUE, solve witht(a)in place ofa. Defaults toFALSE.
Value
arrayish
The solution x, with the same shape and dtype as b.
Details
As a convenience, b may have one fewer dimension than a (a single
right-hand side per batch, shape (B..., n) for a of shape
(B..., n, n)). It is reshaped internally to a column (left_side = TRUE) or row (left_side = FALSE) and reshaped back on the way out.
Because we don't broadcast, this is not ambiguous (as it would be for NumPy).