trisolve: Tridiagonal Linear System Solver

Description Usage Arguments Details Value Note References See Also Examples

View source: R/trisolve.R

Description

Solves tridiagonal linear systems A*x=rhs efficiently.

Usage

1
trisolve(a, b, d, rhs)

Arguments

a

diagonal of the tridiagonal matrix A.

b, d

upper and lower secondary diagonal of A.

rhs

right hand side of the linear system A*x=rhs.

Details

Solves tridiagonal linear systems A*x=rhs by applying Givens transformations.

By only storing the three diagonals, trisolve has memory requirements of 3*n instead of n^2 and is faster than the standard solve function for larger matrices.

Value

Returns the solution of the tridiagonal linear system as vector.

Note

Has applications for spline approximations and for solving boundary value problems (ordinary differential equations).

References

Gander, W. (1992). Computermathematik. Birkhaeuser Verlag, Basel.

See Also

qrSolve

Examples

1
2
3
4
5
6
7
8
9
set.seed(8237)
a <- rep(1, 100)
e <- runif(99); f <- rnorm(99)
x <- rep(seq(0.1, 0.9, by = 0.2), times = 20)
A <- diag(100) + Diag(e, 1) + Diag(f, -1)
rhs <- A %*% x
s <- trisolve(a, e, f, rhs)
s[1:10]                         #=> 0.1 0.3 0.5 0.7 0.9 0.1 0.3 0.5 0.7 0.9
s[91:100]                       #=> 0.1 0.3 0.5 0.7 0.9 0.1 0.3 0.5 0.7 0.9


pracma documentation built on May 21, 2017, 1:25 a.m.
Search within the pracma package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.