Triangular_solve
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_triangular_solve.Rd
Triangular_solve
Arguments
- self
(Tensor) multiple right-hand sides of size \((*, m, k)\) where \(*\) is zero of more batch dimensions (\(b\))
- A
(Tensor) the input triangular coefficient matrix of size \((*, m, m)\) where \(*\) is zero or more batch dimensions
- upper
(bool, optional) whether to solve the upper-triangular system of equations (default) or the lower-triangular system of equations. Default:
TRUE
.- transpose
(bool, optional) whether \(A\) should be transposed before being sent into the solver. Default:
FALSE
.- unitriangular
(bool, optional) whether \(A\) is unit triangular. If TRUE, the diagonal elements of \(A\) are assumed to be 1 and not referenced from \(A\). Default:
FALSE
.
triangular_solve(input, A, upper=TRUE, transpose=False, unitriangular=False) -> (Tensor, Tensor)
Solves a system of equations with a triangular coefficient matrix \(A\) and multiple right-hand sides \(b\).
In particular, solves \(AX = b\) and assumes \(A\) is upper-triangular with the default keyword arguments.
torch_triangular_solve(b, A)
can take in 2D inputs b, A
or inputs that are
batches of 2D matrices. If the inputs are batches, then returns
batched outputs X
Examples
if (torch_is_installed()) {
A = torch_randn(c(2, 2))$triu()
A
b = torch_randn(c(2, 3))
b
torch_triangular_solve(b, A)
}
#> [[1]]
#> torch_tensor
#> -0.4159 -19.8541 -28.8686
#> -9.9554 -26.7462 -40.0722
#> [ CPUFloatType{2,3} ]
#>
#> [[2]]
#> torch_tensor
#> 0.2344 -0.1714
#> 0.0000 -0.0268
#> [ CPUFloatType{2,2} ]
#>