BackSolve: Back/Forward solve

38-Back/Forward solveR Documentation

Back/Forward solve

Description

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.

Usage

 ## 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)

Arguments

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.

Value

An MPCR object represents the solution to the system of linear equations.

Examples


  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)


MPCR documentation built on April 13, 2025, 5:08 p.m.

Related to BackSolve in MPCR...