These subroutines solve the tridiagonal system
Ax = b using Gaussian elimination, where
tridiagonal matrix A is stored in tridiagonal storage mode.
c, d, e, b, x | Subroutine |
Short-precision real | SGTNP |
Long-precision real | DGTNP |
Short-precision complex | CGTNP |
Long-precision complex | ZGTNP |
Fortran | CALL SGTNP | DGTNP | CGTNP | ZGTNP (n, c, d, e, bx) |
C and C++ | sgtnp | dgtnp | cgtnp | zgtnp (n, c, d, e, bx); |
PL/I | CALL SGTNP | DGTNP | CGTNP | ZGTNP (n, c, d, e, bx); |
For a description of how tridiagonal matrices are stored, see General Tridiagonal Matrix.
The solution of the tridiagonal system Ax = b is computed by Gaussian elimination.
No pivoting is done. Therefore, these subroutines should not be used when pivoting is necessary to maintain the numerical accuracy of the solution. Overflow may occur if small main diagonal elements are generated. Underflow or accuracy loss may occur if large main diagonal elements are generated.
For performance reasons, complex divides are done without scaling. Computing the inverse in this way restricts the range of numbers for which the ZGTNP subroutine works properly.
For performance reasons, divides are done in a way that reduces the effective exponent range for which DGTNP and ZGTNP work properly; therefore, you may want to scale your problem, such that the diagonal elements are close to 1.0 for DGTNP and (1.0, 0.0) for ZGTNP.
None
n < 0
This example shows a factorization of the real tridiagonal matrix A, of order 4:
* * | 7.0 4.0 0.0 0.0 | | 1.0 8.0 5.0 0.0 | | 0.0 2.0 9.0 6.0 | | 0.0 0.0 3.0 10.0 | * *
It then finds the solution of the tridiagonal system Ax = b, where b is:
(11.0, 14.0, 17.0, 13.0)
and x is:
(1.0, 1.0, 1.0, 1.0)
On output, arrays C, D, and E are overwritten.
N C D E BX | | | | | CALL DGTNP( 4 , C , D , E , BX ) C = ( . , 1.0, 2.0, 3.0) D = (7.0, 8.0, 9.0, 10.0) E = (4.0, 5.0, 6.0, . ) BX = (11.0, 14.0, 17.0, 13.0)
BX = (1.0, 1.0, 1.0, 1.0)
This example shows a factorization of the complex tridiagonal matrix A, of order 4:
* * | (7.0, 7.0) (4.0, 4.0) (0.0, 0.0) (0.0, 0.0) | | (1.0, 1.0) (8.0, 8.0) (5.0, 5.0) (0.0, 0.0) | | (0.0, 0.0) (2.0, 2.0) (9.0, 9.0) (6.0, 6.0) | | (0.0, 0.0) (0.0, 0.0) (3.0, 3.0) (10.0, 10.0) | * *
It then finds the solution of the tridiagonal system Ax = b, where b is:
((-11.0,19.0), (-14.0,50.0), (-17.0,93.0), (-13.0,85.0))
and x is:
((1.0,-1.0), (2.0,-2.0), (3.0,-3.0), (4.0,-4.0))
On output, arrays C, D, and E are overwritten.
N C D E BX | | | | | CALL ZGTNP( 4 , C , D , E , BX ) C = ( . , (1.0, 1.0), (2.0, 2.0), (3.0, 3.0)) D = ((7.0, 7.0), (8.0, 8.0), (9.0, 9.0), (10.0, 10.0)) E = ((4.0, 4.0), (5.0, 5.0), (6.0, 6.0), . ) BX = ((-11.0, 19.0), (-14.0, 50.0), (-17.0, 93.0), (-13.0, 85.0))
BX = ((0.0, 1.0), (1.0, 2.0), (2.0, 3.0), (3.0, 4.0))