Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Symmetric Positive Definite Tridiagonal Matrix

The subroutines described in this section solve the linear system Ax = b for a symmetric positive definite tridiagonal matrix A and vectors b and x.

Calling Sequence

CALL DPTSL 
(N, DDIAG, DOFFD, DB)
CALL SPTSL 
(N, SDIAG, SOFFD, SB)
CALL ZPTSL 
(N, ZDIAG, ZOFFD, ZB)
CALL CPTSL 
(N, CDIAG, COFFD, CB)






void dptsl 
(int n, double *ddiag, double *doffd, double *db)
void sptsl 
(int n, float *sdiag, float *soffd, float *sb)
void zptsl 
(int n, doublecomplex *zdiag, doublecomplex *zoffd, 
doublecomplex *zb)
void cptsl 
(int n, complex *cdiag, complex *coffd, complex *cb)

Arguments

N

Order of the matrix A. N 0.

xDIAG

Main diagonal elements of A.

xOFFD

Off diagonal elements of A. OFFD(1) through OFFD(N-1) contains the off diagonal elements; OFFD(N) is not referenced.

xB

On entry, the right-hand side vector b.
On exit, the solution vector x.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           N
      PARAMETER        (N = 4)
C
      DOUBLE PRECISION  B(N), SUBD(N), DIAG(N)
C
      EXTERNAL          DPTSL
C
C     Initialize the arrays SUBD and DIAG to store the subdiagonal
C     and diagonal of the tridiagonal positive definite matrix A
C     shown below.  Initialize the array B to store the right hand
C     side vector b shown below.
C
C          2  -1                 6
C     A = -1   2  -1        b = 12
C             -1   2  -1        12
C                 -1   2         6
C
      DATA SUBD / -1.0D0, -1.0D0, -1.0D0, 8D8 /
      DATA DIAG / 4*2.0D0 /
      DATA B / 6.0D0, 1.2D1, 1.2D1, 6.0D0 /
C
      PRINT 1000
      PRINT 1010, DIAG(1), SUBD(1)
      PRINT 1020, SUBD(1), DIAG(2), SUBD(2)
      PRINT 1030,          SUBD(2), DIAG(3), SUBD(3)
      PRINT 1040,                   SUBD(3), DIAG(4)
      PRINT 1050
      PRINT 1060, B
      CALL DPTSL (N, DIAG, SUBD, B)
      PRINT 1070
      PRINT 1060, B
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (1X, 2(2X, F4.1))
 1020 FORMAT (1X, 3(2X, F4.1))
 1030 FORMAT (1X,  6X, 3(2X, F4.1))
 1040 FORMAT (1X, 12X, 2(2X, F4.1))
 1050 FORMAT (/1X, 'b:')
 1060 FORMAT (3X, F6.1)
 1070 FORMAT (/1X, 'A**(-1) * b:')
C
      END
 

Sample Output

 
 A:
    2.0  -1.0
   -1.0   2.0  -1.0
         -1.0   2.0  -1.0
               -1.0   2.0



 b:
      6.0
     12.0
     12.0
      6.0



 A**(-1) * b:
     18.0
     30.0
     30.0
     18.0






Previous Next Contents Generated Index Doc Set Home