Previous Next Contents Generated Index Doc Set Home



Refined Solution to a Linear System in a Cholesky-Factored Symmetric Positive Definite Matrix in Banded Storage

The subroutines described in this section refine the solution to a real symmetric (or Hermitian) positive definite linear system AX = B for a real symmetric (or Hermitian) positive definite matrix A in banded storage, which has been Cholesky-factored by xPBTRF, and general matrices B and X. These subroutines also compute forward error bounds and backward error estimates for the refined solution.

Calling Sequence

CALL DPBRFS 
(UPLO, N, NDIAG, NRHS, DA, LDA, DAF, LDAF, DB, LDB, DX, 
LDX, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL SPBRFS 
(UPLO, N, NDIAG, NRHS, SA, LDA, SAF, LDAF, SB, LDB, SX, 
LDX, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZPBRFS 
(UPLO, N, NDIAG, NRHS, ZA, LDA, ZAF, LDAF, ZB, LDB, ZX, 
LDX, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CPBRFS 
(UPLO, N, NDIAG, NRHS, CA, LDA, CAF, LDAF, CB, LDB, CX, 
LDX, SFERR, SBERR, CWORK, SWORK2, INFO)






void dpbrfs 
(char uplo, int n, int ndiag, int nrhs, double *da, int 
lda, double *daf, int ldaf, double *db, int ldb, double 
*dx, int ldx, double *dferr, double *dberr, int *info)
void spbrfs 
(char uplo, int n, int ndiag, int nrhs, float *sa, int 
lda, float *saf, int ldaf, float *sb, int ldb, float 
*sx, int ldx, float *sferr, float *sberr, int *info)
void zpbrfs 
(char uplo, int n, int ndiag, int nrhs, doublecomplex 
*za, int lda, doublecomplex *zaf, int ldaf, 
doublecomplex *zb, int ldb, doublecomplex *zx, int ldx, 
double *dferr, double *dberr, int *info)
void cpbrfs 
(char uplo, int n, int ndiag, int nrhs, complex *ca, 
int lda, complex *caf, int ldaf, complex *cb, int ldb, 
complex *cx, int ldx, float *sferr, float *sberr, int 
*info)

Arguments

UPLO

Indicates whether xA contains the upper or lower triangle of the matrix. The legal values for UPLO are listed below. Any values not listed below are illegal.

'U' or 'u'

xA contains the upper triangle.

'L' or 'l'

xA contains the lower triangle.

N

Order of the matrix A. N 0.

NDIAG

Number of superdiagonals or subdiagonals of the matrix A. N-1 NDIAG 0 but if N = 0 then NDIAG = 0.

If UPLO = 'U' or 'u', NDIAG is the number of superdiagonals.

If UPLO = 'L' or 'l', NDIAG is the number of subdiagonals.

NRHS

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

xA

Upper or lower triangle of the matrix A.

LDA

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

xAF

Cholesky factorization of the matrix A as computed by xPBTRF.

LDAF

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

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 3 × N for real subroutines or 2 × N for complex subroutines.

xWORK2

Scratch array with a dimension of 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           LDA, LDAF, LDB, LDIWRK, LDWORK, LDX
      INTEGER           N, NRHS, NDIAG
      PARAMETER        (N = 4)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (LDA = NDIAG + 1)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LDA,N), AF(LDAF,N), B(LDB,NRHS)
      DOUBLE PRECISION  B1(LDB,NRHS), BERR(NRHS), EPSLON
      DOUBLE PRECISION  FERR(NRHS), WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DSBMV, DPBTRF, DPBTRS, DPBRFS
      INTRINSIC         ABS, DBLE, MAX
C
C     Initialize the array B to store the right hand side 
C     vector b shown.
C
C         4
C     b = 4
C         4
C         4
C
      DATA B / N*4.0D0 /
C
C     Initialize the array A to contain the matrix A shown below
C     where e=epsilon=small.
C
C          e    e*e
C     A = e*e    e    e*e
C               e*e    e   e*e
C                     e*e   e
C
      A(1,1) = SQRT(-1.0D0)
      EPSLON = ABS((((2.0D0 / 3.0D0) + 8.0D0) - 8.0D0) - 
     $         (2.0D0 / 3.0D0))
      DO 100, ICOL = 1, N
        A(NDIAG + 1,ICOL) = EPSLON
  100 CONTINUE
      DO 110, ICOL = 2, N
        A(1,ICOL) = EPSLON * EPSLON
  110 CONTINUE
      CALL DCOPY (LDA*N, A, 1, AF, 1)
C
C     Print the A array.
C
      PRINT 1000
      PRINT 1010, A(2,1), A(1,2),  0.0D0, 0.0D0
      PRINT 1010, A(1,2), A(2,2), A(1,3), 0.0D0
      PRINT 1010,  0.0D0, A(1,3), A(2,3), A(1,4)
      PRINT 1010,  0.0D0,  0.0D0, A(1,4), A(2,4)
      PRINT 1020
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, LDA)
C
C     Make a copy of B and then print B.
C
      CALL DCOPY (N, B, 1, X, 1)
      PRINT 1030
      PRINT 1040, B
C
C     Factor A.
C
      CALL DPBTRF ('UPPER TRIANGLE OF A STORED', N, NDIAG,
     $             AF, LDAF, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        STOP 1
      END IF
C
C     Solve Ax=b and print the solution.
C
      CALL DPBTRS ('UPPER TRIANGLE OF A STORED', N, NDIAG, NRHS,
     $             AF, LDAF, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1060, INFO
        STOP 2
      END IF
      PRINT 1070
      PRINT 1080, X
      CALL DSBMV ('UPPER TRIANGLE OF A STORED', N, NDIAG, 1.0D0,
     $            A, LDA, X, 1, 0.0D0, B1, 1)
      PRINT 1090
      PRINT 1040, B1
C
C     Refine the initial solution and print the new solution.
C
      CALL DPBRFS ('UPPER TRIANGLE OF A STORED', N, NDIAG, NRHS,
     $             A, LDA, AF, LDAF, B, LDB, X, LDX, FERR, BERR,
     $             WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1100, INFO
        STOP 3
      END IF
      PRINT 1110
      PRINT 1080, X
      CALL DSBMV ('UPPER TRIANGLE OF A STORED', N, NDIAG, 1.0D0,
     $            A, LDA, X, 1, 0.0D0, B1, 1)
      PRINT 1120
      PRINT 1040, B1
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(2X, E15.8))
 1020 FORMAT (/1X, 'A in banded form: ("NaN" in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, F19.15)
 1050 FORMAT (1X, 'Error factoring A in DPBTRF, INFO = ', I5)
 1060 FORMAT (1X, 'Error solving Ax=b in DPBTRF, INFO = ', I5)
 1070 FORMAT (/1X, 'Initial solution for Ax=b:')
 1080 FORMAT (1X, E24.16)
 1090 FORMAT (/1X, 'Ax with initial x:')
 1100 FORMAT (1X, 'Error improving solution in DPBRFS, INFO = ',
     $        I5)
 1110 FORMAT (/1X, 'Refined solution for Ax=b:')
 1120 FORMAT (/1X, 'Ax with improved x:')
C
      END
 

Sample Output

 
 A in full form:
   0.55511151E-15   0.30814879E-30   0.00000000E+00   0.00000000E+00
   0.30814879E-30   0.55511151E-15   0.30814879E-30   0.00000000E+00
   0.00000000E+00   0.30814879E-30   0.55511151E-15   0.30814879E-30
   0.00000000E+00   0.00000000E+00   0.30814879E-30   0.55511151E-15



 A in banded form: ("NaN" in unused elements)
  NaN               0.30814879E-30   0.30814879E-30   0.30814879E-30
   0.55511151E-15   0.55511151E-15   0.55511151E-15   0.55511151E-15



 b:
   4.000000000000000
   4.000000000000000
   4.000000000000000
   4.000000000000000



 Initial solution for Ax=b:
   0.7205759403792790E+16
   0.7205759403792784E+16
   0.7205759403792784E+16
   0.7205759403792788E+16



 Ax with initial x:
   4.000000000000000
   3.999999999999999
   3.999999999999999
   3.999999999999999



 Refined solution for Ax=b:
   0.7205759403792789E+16
   0.7205759403792786E+16
   0.7205759403792786E+16
   0.7205759403792790E+16



 Ax with improved x:
   4.000000000000000
   4.000000000000000
   4.000000000000000
   4.000000000000000






Previous Next Contents Generated Index Doc Set Home