Previous Next Contents Generated Index Doc Set Home



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

The subroutines described in this section refine the solution to 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. These subroutines also compute forward error bounds and backward error estimates for the refined solution.

Calling Sequence

CALL DPTRFS 
(N, NRHS, DDIAG, DOFFD, DDIAGF, DOFFDF, DB, LDB, DX, 
LDX, DFERR, DBERR, DWORK, INFO)
CALL SPTRFS 
(N, NRHS, SDIAG, SOFFD, SDIAGF, SOFFDF, SB, LDB, SX, 
LDX, SFERR, SBERR, SWORK, INFO)
CALL ZPTRFS 
(UPLO, N, NRHS, DDIAG, ZOFFD, DDIAGF, ZOFFDF, ZB, LDB, 
ZX, LDX, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CPTRFS 
(UPLO, N, NRHS, SDIAG, COFFD, SDIAGF, COFFDF, CB, LDB, 
CX, LDX, SFERR, SBERR, CWORK, SWORK2, INFO)






void dptrfs 
(int n, int nrhs, double *ddiag, double *doffd, double 
*ddiagf, double *doffdf, double *db, int ldb, double 
*dx, int ldx, double *dferr, double *dberr, int *info)
void sptrfs 
(int n, int nrhs, float *sdiag, float *soffd, float 
*sdiagf, float *soffdf, float *sb, int ldb, float *sx, 
int ldx, float *sferr, float *sberr, int *info)
void zptrfs 
(char uplo, int n, int nrhs, double *ddiag, 
doublecomplex *zoffd, double *ddiagf, doublecomplex 
*zoffdf, doublecomplex *zb, int ldb, doublecomplex 
*zx, int ldx, double *dferr, double *dberr, int *info)
void cptrfs 
(char uplo, int n, int nrhs, float *sdiag, complex 
*coffd, float *sdiagf, complex *coffdf, complex *cb, 
int ldb, complex *cx, int ldx, float *sferr, float 
*sberr, int *info)

Arguments

UPLO

(For complex matrices)

Indicates whether OFFDF contains the superdiagonal or 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'

xOFFDF contains the superdiagonal and the factorization is UDU.

'L' or 'l'

xOFFDF contains the subdiagonal and the factorization is LDL.

N

Order of the matrix A. N 0.

NRHS

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

xDIAG

The N diagonal elements of A.

xOFFD

The N-1 off-diagonal elements of A.

xDIAGF

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

xOFFDF

The N-1 off-diagonal elements of the matrix U or L from the UDU or LDL factorization of A, as computed by xPTTRF.

xB

The N×NRHS right-hand side matrix B.

LDB

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

xX

On entry, the N×NRHS solution matrix X.
On exit, the refined N×NRHS solution matrix X.

LDX

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

xFERR

On exit, the estimated forward error bound for each solution vector X(*, j) for 1 j NRHS. If X' is the true solution corresponding to
X(*, j) then FERR(j) is an upper bound on the magnitude of the largest element in X(*, j) - X' divided by the magnitude of the largest element in X(*, j).

xBERR

On exit, BERR(j) is the smallest relative change in any element of A or B(*, j) that makes X(*, j) an exact solution to AX(*, j) = B(*, j) for
1 j NRHS.

xWORK

Scratch array with a dimension of 2 × N for real subroutines or N for complex subroutines.

xWORK2

Scratch array with a dimension of N for complex subroutines.

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, LDWORK, LDX, N, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (LDB = N)
      PARAMETER        (LDWORK = 2 * N)
      PARAMETER        (LDX = N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  B(LDB,NRHS), BERR(NRHS), DIAG(N)
      DOUBLE PRECISION  DIAGF(N), DLOW(N-1), DLOWF(N-1), EPSLON
      DOUBLE PRECISION  FERR(NRHS), WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DCOPY, DPTCON, DPTRFS, DPTTRF, DPTTRS
      INTRINSIC         ABS, MAX
C
C     Initialize the arrays DLOW, DIAG, and DUP1 to store
C     the first subdiagonal, the diagonal, and the first
C     superdiagonal of the symmetric coefficient matrix A
C     shown below.  Initialize the array B to store the right
C     hand side matrix b shown below.
C
C         0   0                30
C     A = 0   2   2        b = 50
C             2   2   0        70
C                 0   0       110
C
      DATA DLOW / 0.0D0, 2.0D0, 0.0D0 /
      DATA DIAG / 0.0D0,  2.0D0, 2.0D0, 0.0D0 /
      DATA B / 3.0D1, 5.0D1, 7.0D1, 1.1D2 /
C
C     Add a small value to each of the elements on the diagonal
C     and subtract the same value from the first sub- and
C     super-diagonal of A.  After this loop, A will resemble the
C     matrix shown below. Print A after adding epsilon.
C
C         -e    -e
C     A = -e   2+e   2-e
C              2-e   2+e   -e
C                     -e   -e
C
      EPSLON = ABS ((((2.0D0 / 3.0D0) + 4.0D0) - 4.0D0) -
     $         (2.0D0 / 3.0D0))
      DO 100, IROW = 1, N - 1
        DLOW(IROW) = DLOW(IROW) - EPSLON
        DIAG(IROW) = DIAG(IROW) + EPSLON
  100 CONTINUE
      DIAG(N) = DIAG(N) + EPSLON
      CALL DCOPY (N - 1, DLOW, 1, DLOWF, 1)
      CALL DCOPY (N, DIAG, 1, DIAGF, 1)
C
      PRINT 1000
      DO 110, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - 2),
     $        (DLOW(ICOL + 1), ICOL = ABS(IROW - 2), IROW - 2),
     $        DIAG(IROW),
     $        (DLOW(IROW), ICOL = 1, MIN(1, N - IROW)),
     $        (0.0D0, ICOL = IROW + 2, N)
  110 CONTINUE
C
C     Slightly perturb each element of B.  After this loop, B will
C     resemble the matrix shown below.  Print B afterwards.
C
C         30+e
C     B = 50+e
C         70+e
C        110+e
C
      DO 130, ICOL = 1, NRHS
        DO 120, IROW = 1, N
          B(IROW,ICOL) = B(IROW,ICOL) * (1.0D0 - EPSLON)
  120   CONTINUE
  130 CONTINUE
      CALL DCOPY (N, B, 1, X, 1)
      PRINT 1020
      PRINT 1030, B
C
C     LDL factor A.
C
      CALL DPTTRF (N, DIAGF, DLOWF, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1040, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1050, INFO
        STOP 2
      END IF
C
C     Solve Ax=b and print the solution.
C
      CALL DPTTRS (N, NRHS, DIAGF, DLOWF, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1060, INFO
        STOP 3
      END IF
      PRINT 1070
      PRINT 1080, X
      PRINT 1090
      PRINT 1030,                    DIAG(1) * X(1,1) + DLOW(1) *
     $   X(2,1)
      PRINT 1030, DLOW(1) * X(1,1) + DIAG(2) * X(2,1) + DLOW(2) *
     $   X(3,1)
      PRINT 1030, DLOW(2) * X(2,1) + DIAG(3) * X(3,1) + DLOW(3) *
     $   X(4,1)
      PRINT 1030, DLOW(3) * X(3,1) + DIAG(4) * X(4,1)
C
C     Refine the solution to Ax=b and print the refined solution.
C
      CALL DPTRFS (N, NRHS, DIAG, DLOW, DIAGF, DLOWF, B, LDB,
     $             X, LDX, FERR, BERR, WORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1100, ABS(INFO)
        STOP 4
      END IF
      PRINT 1110
      PRINT 1080, X
      PRINT 1120
      PRINT 1030,                    DIAG(1) * X(1,1) + DLOW(1) *
     $   X(2,1)
      PRINT 1030, DLOW(1) * X(1,1) + DIAG(2) * X(2,1) + DLOW(2) *
     $   X(3,1)
      PRINT 1030, DLOW(2) * X(2,1) + DIAG(3) * X(3,1) + DLOW(3) *
     $   X(4,1)
      PRINT 1030, DLOW(3) * X(3,1) + DIAG(4) * X(4,1)
      PRINT 1130, FERR(1)
      PRINT 1140, BERR(1)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(2X, F18.16))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F21.17)
 1040 FORMAT (1X, 'Illegal argument to DPTRFS, argument #', I2)
 1050 FORMAT (1X, 'A is not positive definite, INFO = ', I2)
 1060 FORMAT (1X, 'Illegal argument to DPTRFS, argument #', I2)
 1070 FORMAT (/1X, 'Initial solution to Ax=b:')
 1080 FORMAT (1X, E25.17)
 1090 FORMAT (/1X, 'Ax with the initial x:')
 1100 FORMAT (1X, 'Illegal argument to DPTRFS, INFO = ', I2)
 1110 FORMAT (/1X, 'Refined solution to Ax=b:')
 1120 FORMAT (/1X, 'Ax with refined x:')
 1130 FORMAT (/1X, 'Forward error:  ', E14.8)
 1140 FORMAT (1X, 'Backward error: ', E14.8)
C
      END
 

Sample Output

 
 A:
  0.0000000000000003  -.0000000000000003  0.0000000000000000  0.0000000000000000
  -.0000000000000003  2.0000000000000004  1.9999999999999996  0.0000000000000000
  0.0000000000000000  1.9999999999999996  2.0000000000000004  -.0000000000000003
  0.0000000000000000  0.0000000000000000  -.0000000000000003  0.0000000000000003



 b:
  29.99999999999998934
  49.99999999999998579
  69.99999999999997158
 109.99999999999995737



 Initial solution to Ax=b:
  -0.10007999171934384E+17
  -0.10007999171934427E+18
   0.10007999171934432E+18
   0.43034396439318054E+18



 Ax with the initial x:
  29.99999999999999289
  32.00000000000000000
  16.66666666666674246
 109.99999999999994316



 Refined solution to Ax=b:
  -0.57379195252423992E+17
  -0.14745118779983389E+18
   0.14745118779983392E+18
   0.47771516047367027E+18



 Ax with refined x:
  29.99999999999999645
 -64.00000000000000000
  32.88888888888891415
 110.00000000000000000



 Forward error:  0.47796400E+01
 Backward error: 0.17862806E-15






Previous Next Contents Generated Index Doc Set Home