Skip to contents

Solves the linear system a %*% x = b for x, where a is a symmetric positive-definite matrix. Uses Cholesky decomposition internally. Supports batched inputs: a and b must have the same batch dimensions (all dimensions before the last two).

Usage

nv_solve(a, b)

Arguments

a

(arrayish)
Symmetric positive-definite matrix.

b

(arrayish)
Right-hand side matrix or vector. Must have the same data type and batch dimensions as a.

Value

arrayish
The solution x such that a %*% x = b.

Shapes

  • a: (..., n, n)

  • b: (..., n, k)

  • output: same shape as b

where ... are zero or more batch dimensions that must match between a and b.

Examples

a <- nv_array(matrix(c(4, 2, 2, 3), nrow = 2), dtype = "f32")
b <- nv_array(matrix(c(1, 2), nrow = 2), dtype = "f32")
nv_solve(a, b)
#> AnvlArray
#>  -0.1250
#>   0.7500
#> [ CPUf32{2,1} ]