Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Symmetric Positive Definite Tridiagonal Matrix (Simple Driver)

The subroutines described in this section solve a linear system AX = B for a real symmetric (or Hermitian) positive definite tridiagonal matrix A and general matrices B and X. Note that the expert driver xPTSVX is also available.

Calling Sequence

CALL DPTSV 
(N, NRHS, DDIAG, DSUB, DB, LDB, INFO)
CALL SPTSV 
(N, NRHS, SDIAG, SSUB, SB, LDB, INFO)
CALL ZPTSV 
(N, NRHS, DDIAG, ZSUB, ZB, LDB, INFO)
CALL CPTSV 
(N, NRHS, SDIAG, CSUB, CB, LDB, INFO)






void dptsv 
(int n, int nrhs, double *ddiag, double *dsub, double 
*db, int ldb, int *info)
void sptsv 
(int n, int nrhs, float *sdiag, float *ssub, float *sb, 
int ldb, int *info)
void zptsv 
(int n, int nrhs, double *ddiag, doublecomplex *dsub, 
doublecomplex *zb, int ldb, int *info)
void cptsv 
(int n, int nrhs, float *sdiag, complex *ssub, complex 
*cb, int ldb, int *info)

Arguments

N

Order of the matrix A. N 0.

NRHS

Number of right-hand sides, equal to the number of columns of the matrix B. NRHS 0.

xDIAG

On entry, the N diagonal elements of the matrix A.
On exit, the N diagonal elements of the diagonal matrix D from the LDL factorization of A, as computed by xPTTRF.

xSUB

On entry, the N-1 subdiagonal elements of the matrix A.
On exit, the N-1 subdiagonal elements of the unit bidiagonal factor L from the LDL factorization of A, as computed by xPTTRF.

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, the N×NRHS solution matrix X.

LDB

Leading dimension of the array B as specified in a dimension or type statement. LDB max(1, N).

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

INFO > 0

The leading minor of order i of A, where i = INFO, is not positive definite. The factorization has not been completed, unless i = N, and the solution could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDB, N, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDB = N)
C
      DOUBLE PRECISION  B(LDB,NRHS), DIAG(N), DLOWER(N-1)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DPTSV
C
C     Initialize the arrays DIAG and DLOWER to store in symmetric
C     tridiagonal form the 4x4 symmetric positive definite
C     coefficient matrix A shown below.  Initialize the array B
C     to store the right hand side vector b shown below.
C
C          2  -1   0   0         6
C     A = -1   2  -1   0    b = 12
C          0  -1   2  -1        12
C          0   0  -1   2         6
C
      DATA DIAG / 2.0D0, 2.0D0, 2.0D0, 2.0D0 /
      DATA DLOWER / -1.0D0, -1.0D0, -1.0D0 /
      DATA B / 6.0D0, 1.2D1, 1.2D1, 6.0D0 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - 2),
     $        (DLOWER(ICOL + 1), ICOL = ABS(IROW - 2), IROW - 2),
     $        DIAG(IROW),
     $        (DLOWER(IROW), ICOL = 1, MIN(1, N - IROW)),
     $        (0.0D0, ICOL = IROW + 2, N)
  100 CONTINUE
      PRINT 1020
      PRINT 1030, B
C
C     Solve the system and print the results.
C
      CALL DPTSV (N, NRHS, DIAG, DLOWER, B, LDB, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
      PRINT 1050
      PRINT 1030, B
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F6.3))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F6.2)
 1040 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1050 FORMAT (/1X, 'x:')
C
      END
 

Sample Output

 
 A:
    2.000   -1.000    0.000    0.000
   -1.000    2.000   -1.000    0.000
    0.000   -1.000    2.000   -1.000
    0.000    0.000   -1.000    2.000



 b:
   6.00
  12.00
  12.00
   6.00



 x:
  18.00
  30.00
  30.00
  18.00






Previous Next Contents Generated Index Doc Set Home