The TRISOL function solves tridiagonal systems of linear equations that have the form: A T U = R
Note: because IDL subscripts are in column-row order, the equation above is written A T U = R rather than AU = R. The result U is a vector of length n whose type is identical to A .
TRISOL is based on the routine
tridag
described in section 2.4 of
Numerical Recipes in C: The Art of Scientific Computing
(Second Edition), published by Cambridge University Press, and is used by permission.
A vector of length n containing the n -1 sub-diagonal elements of A T . The first element of A , A 0 , is ignored.
To solve a tridiagonal linear system, begin with an array representing a real tridiagonal linear system. (Note that only three vectors need be specified; there is no need to enter the entire array shown.)
Define a vector A containing the sub-diagonal elements with a leading 0.0 element:
Define B containing the main diagonal elements:
Define C containing the super-diagonal elements with a trailing 0.0 element:
Define the right-hand side vector:
Compute the solution and print: