38-Back/Forward solve | R Documentation |
Solves a system of linear equations where the coefficient matrix is upper or lower triangular. The function solves the equation A X = B
, where A
is the coefficient matrix, X
is the solution vector, and B
is the right-hand side vector.
## S4 method for signature 'Rcpp_MPCR,Rcpp_MPCR'
backsolve(r, x, k = ncol(r), upper.tri = TRUE, transpose = FALSE)
## S4 method for signature 'Rcpp_MPCR,Rcpp_MPCR'
forwardsolve(l, x, k = ncol(l), upper.tri = FALSE, transpose = FALSE)
l |
An MPCR object. |
r |
An MPCR object. |
x |
An MPCR object whose columns give the right-hand sides for the equations. |
k |
The number of columns of r and rows of x to use. |
upper.tri |
logical; if TRUE, the upper triangular part of r is used. Otherwise, the lower one. |
transpose |
logical; if TRUE, solve for t( l , r ) %*% output == x. |
An MPCR object represents the solution to the system of linear equations.
library(MPCR)
a <- matrix(c(2, 0, 0, 3), nrow = 2)
b <- matrix(c(1, 2), nrow = 2)
a_MPCR <- as.MPCR(a,2,2,"single")
b_MPCR <- as.MPCR(b,2,1,"double")
x <- backsolve(a_MPCR, b_MPCR)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.