Solves the banded linear system Ax = b. |
||
Syntax |
x = LSolveB(M, kl, ku, b) |
|
Arguments |
Name |
Description |
M |
Compressed diagonal storage matrix form of the banded square matrix A. Use BandMatrix to create it and BandMatrixIndices to populate it. |
|
kl |
Number of sub-diagonals in the lower band of the original matrix. It should include off-diagonals with zero entries that are in between diagonals with non zero entries. |
|
ku |
Number of super-diagonals in upper band of the original matrix. It should include off-diagonals with zero entries that are in between diagonals with non zero entries. |
|
b |
The right-hand side column vector or 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 will have the same dimensions as the right-hand side argument b. For each column in b, there will be a solution in the corresponding column in x. |
|
Example |
Solve a banded 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 side matrixcolumn kl=1; ku=1; // Number of off diagonals M = BandMatrix(3, kl, ku); // This will hold the compressed matrix // For each band entry (i,j) of A do the following two operations row, col = BandMatrixIndices(i,j,3,kl,ku); M(row,col) = A(i,j); // Now solve x = LSolveB(M,B) |
||
ResultThe solution to the system in a column vector. [Matrix] 3 x 2 -0.21659 -0.43318 0.60829 1.2166 1.7926 3.5853 |
||
Comments |
For efficiency, the matrix M should be generated directly without creating the matrix A. The number of rows of M is 2*kl+ku+1 and the number of columns is the same as in A. Hence, the narrower the band compared to the size of A, the smaller the size of M in comparison to A. LSolveB calls dgbsv from LAPACK. |
|
See Also: |