File Exchange

image thumbnail

Fast Pentadiagonal System Solver

version 1.0 (2.01 KB) by

Solves symmetric and asymmetric pentadiagonal systems.

6 Ratings



View License

Solves the problem Ax=b when A is pentadiagonal (5-banded) and strongly nonsingular. This is much faster than x=A\b for large matrices. The algorithm will check to see if A is symmetric and use a more efficient algorithm if it is. Users are encouraged to improve and redistribute this script.

Comments and Ratings (8)

Terry Shen


AAAA (view profile)

jeon jiyeon


Tim Davis

For production use, this function is superseded by x=A\b in MATLAB, which now includes a test for banded matrices (and uses LAPACK). I compared it in MATLAB 7.5 with A=spdiags(rand(n,5),-2:2,n,n); A=A+A'+10*speye(n) which is symmetric and positive definite. This pentsolve function was from 20x to 230x slower than x=A\b, as n increased from 100 to 10,000. The slowdown is linear; that is, this function seems to behave like O(n^2) time (which is surprising since the code doesn't have an O(n^2) behavior in it). The same thing occurs with unsymmetric banded matrices.

The accuracy of this function is fine. Its purpose now on the File Exchange is now no longer the need for speed; it's only for illustrating an algorithm (for which it's still useful).

Thus, if you're looking just to solve Ax=b for your pentadiagonal system, just use x=A\b. If you want to read the code to understand an algorithm, then this code is still useful.

Hassan R.

You can make slight changes to the code to fit your problem. You can save a lot of computation time.

Mohd osman

Bastiaan Huisman

Great Stuff!

Jagadeesha Kumar

Thanks a lot for this matlab code.. This has really made the execution of programs faster.. Thanks again...

MATLAB Release
MATLAB 6.0 (R12)

Inspired by: Fast Tridiagonal System Solver

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video