Solves the linear system a %*% x = b for x. Uses LU decomposition
with partial pivoting internally, so a need only be square and
non-singular.
Usage
nv_solve(a, b)
# S3 method for class 'AnvlArray'
solve(a, b, ...)
Arguments
- a
(arrayish)
Coefficient matrix.
- b
(arrayish)
Right-hand side. If missing, returns nv_inv() of a.
- ...
No additional arguments.
Value
arrayish
The solution x such that a %*% x = b.
Details
$$A x = b$$
$$P A = L U$$
$$L U x = P b$$
$$L y = P b$$
$$U x = y$$
Shapes
a: (n, n)
b: (n,) or (n, k)
output: same shape as b
Examples
a <- nv_matrix(c(4, 3, 6, 3), nrow = 2, dtype = "f64")
b <- nv_matrix(c(1, 2), nrow = 2, dtype = "f64")
nv_solve(a, b)
#> AnvlArray
#> 1.5000
#> -0.8333
#> [ CPUf64{2,1} ]