Solves the tri-diagonal linear system Ax = b. |
||
Syntax |
x = LSolveT(diag, lower, upper, b) |
|
Arguments |
Name |
Description |
diag |
A vector of the main diagonal elements. |
|
lower |
A vector of the lower off-diagonal elements. |
|
upper |
A vector of the upper off-diagonal elements. |
|
b |
The right-hand side column vector or a matrix. If it is a matrix, each column produces a separate solution to the system. The number of rows must be equal to the row/column size of the square matrix A. |
|
Output |
Name |
Description |
x |
The solution(s) to the system(s). It has the same dimensions as the right-hand side argument b. For each column in b, there is a solution in the corresponding column in x. |
|
Example |
Solve a a tri-diagonal linear system Ax=b. |
|
|
Syntax |
|
|
A = [1,2,0;41,15,6;0,8,9];// banded 3x3 matrix B = [1,2;11,22;21,42]; // the right hand matrix column diag = [1,15,9]; // diagonal terms upper = [2,6]; // upper diagonal terms lower = [41,8]; // lower diagonal terms x = LSolveT(diag,lower,upper,B); |
|
|
ResultA column vector of the solution to the system. |
|
|
[Matrix] 3 x 2 x = -0.21659 -0.43318 0.60829 1.2166 1.7926 3.5853 |
|
Comments |
LSolveT calls dgtsv from LAPACK. |
|
See Also: |