Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a UDU- or LDL-Factored Symmetric Positive Definite Tridiagonal Matrix

The subroutines described in this section solve a linear system AX = B for a real symmetric (or Hermitian) positive definite tridiagonal matrix A, which has been UDU-factored or LDL-factored by xPTTRF, and general matrices B and X.

Calling Sequence

CALL DPTTRS 
(UPLO, N, NRHS, DDIAG, DOFFD, DB, LDB, INFO)
CALL SPTTRS 
(UPLO, N, NRHS, SDIAG, SOFFD, SB, LDB, INFO)
CALL ZPTTRS 
(N, NRHS, DDIAG, ZOFFD, ZB, LDB, INFO)
CALL CPTTRS 
(N, NRHS, SDIAG, COFFD, CB, LDB, INFO)






void dpttrs 
(int n, int nrhs, double *ddiag, double *doffd, double 
*db, int ldb, int *info)
void spttrs 
(int n, int nrhs, float *sdiag, float *soffd, float 
*sb, int ldb, int *info)
void zpttrs 
(char uplo, int n, int nrhs, double *ddiag, 
doublecomplex *zoffd, doublecomplex *zb, int ldb, int 
*info)
void cpttrs 
(char uplo, int n, int nrhs, float *sdiag, complex 
*coffd, complex *cb, int ldb, int *info)

Arguments

UPLO

(For real matrices)

Indicates whether OFFD contains the superdiagonal or the subdiagonal of the matrix A and the form of the factorization. The legal values for UPLO are listed below. Any values not listed are illegal.

'U' or 'u'

xOFFD contains the superdiagonal and the factorization is UDU.

'L' or 'l'

xOFFD contains the subdiagonal and the factorization is LDL.

(The two forms are equivalent if A if real.)

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

The N diagonal elements of the matrix D from the UDU or LDL factorization of the matrix A, as computed by xPTTRF.

xOFFD

The N-1 off-diagonal elements of the unit bidiagonal factor U or L from the UDU or LDL factorization of the matrix 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.

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          DPTTRF, DPTTRS
      INTRINSIC         ABS
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     LDL factor A.
C
      CALL DPTTRF (N, DIAG, DLOWER, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
C
C     Use the factored form of A to solve Ax=b then print
C     the result.
C
      CALL DPTTRS (N, NRHS, DIAG, DLOWER, B, LDB, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, ABS(INFO)
        STOP 2
      END IF
      PRINT 1060
      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 factoring A, INFO = ', I5)
 1050 FORMAT (1X, 'Illegal argument to DPTTRS, argument #', I1)
 1060 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