Previous Next Contents Generated Index Doc Set Home



UDU or LDL Factorization of a Symmetric Positive Definite Tridiagonal Matrix

The subroutines described in this section compute a UHDU or LDLH factorization of a real symmetric (or Hermitian) positive definite tridiagonal matrix A. It is typical to follow a call to xPTTRF with a call to xPTSVX or xPTTRS to solve a linear system AX = B, or to xPTCON to estimate the condition number of A.

Calling Sequence

CALL DPTTRF 
(N, DDIAG, DOFFD, INFO)
CALL SPTTRF 
(N, SDIAG, SOFFD, INFO)
CALL ZPTTRF 
(N, DDIAG, ZOFFD, INFO)
CALL CPTTRF 
(N, SDIAG, COFFD, INFO)






void dpttrf 
(int n, double *ddiag, double *doffd, int *info)
void spttrf 
(int n, float *sdiag, float *soffd, int *info)
void zpttrf 
(int n, double *ddiag, doublecomplex *zoffd, int *info)
void cpttrf 
(int n, float *sdiag, complex *coffd, int *info)

Arguments

N

Order of the matrix A. N 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 UDU or LDL factorization of A.

xOFFD

On entry, the N-1 off-diagonal elements of the matrix A.
On exit, the N-1 off-diagonal elements of the unit bidiagonal factor U or L from the factorization of A.

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 could not be completed.

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