Skip to contents

Solves A %*% x = B where A is the square matrix stored in factor, delegating to base::solve (LAPACK DGESV).

Usage

lu_solve(factor, B)

Arguments

factor

An amLU object from lu_factor.

B

Numeric vector or matrix; the right-hand side. The number of rows must equal the dimension of factor@A.

Value

Numeric vector or matrix x satisfying A %*% x == B. Returns a vector when B is a vector or single-column matrix.

Examples

m <- matrix(c(2, 1, 5, 3), nrow = 2)
fac <- lu_factor(m)
b <- c(1, 2)
lu_solve(fac, b)
#> [1] -7  3