
Last chance! 50% off unlimited learning
Sale ends in
Solves a triangular system of linear equations.
backsolve(r, x, k = ncol(r), upper.tri = TRUE,
transpose = FALSE)
forwardsolve(l, x, k = ncol(l), upper.tri = FALSE,
transpose = FALSE)
an upper (or lower) triangular matrix giving the coefficients for the system to be solved. Values below (above) the diagonal are ignored.
a matrix whose columns give the right-hand sides for the equations.
The number of columns of r
and rows of x
to use.
logical; if TRUE
(default), the upper
triangular part of r
is used. Otherwise, the lower one.
logical; if TRUE
, solve t(r) %*% y == x
.
The solution of the triangular system. The result will be a vector if
x
is a vector and a matrix if x
is a matrix.
Solves a system of linear equations where the coefficient matrix is upper (or ‘right’, ‘R’) or lower (‘left’, ‘L’) triangular.
x <- backsolve (R, b)
solves x <- forwardsolve(L, b)
solves
The r
/l
must have at least k
rows and columns,
and x
must have at least k
rows.
This is a wrapper for the level-3 BLAS routine dtrsm
.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1978) LINPACK Users Guide. Philadelphia: SIAM Publications.
# NOT RUN {
## upper triangular matrix 'r':
r <- rbind(c(1,2,3),
c(0,1,1),
c(0,0,2))
( y <- backsolve(r, x <- c(8,4,2)) ) # -1 3 1
r %*% y # == x = (8,4,2)
backsolve(r, x, transpose = TRUE) # 8 -12 -5
# }
Run the code above in your browser using DataLab