Examples for 'base::backsolve'


Solve an Upper or Lower Triangular System

Aliases: backsolve forwardsolve

Keywords: algebra array

### ** Examples

## 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
[1] -1  3  1
r %*% y # == x = (8,4,2)
     [,1]
[1,]    8
[2,]    4
[3,]    2
backsolve(r, x, transpose = TRUE) # 8 -12 -5
[1]   8 -12  -5

[Package base version 4.2.3 Index]