Previous Next Contents Generated Index Doc Set Home



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

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

Calling Sequence

CALL DPPRFS 
(UPLO, N, NRHS, DA, DAF, DB, LDB, DX, LDX, DFERR, 
DBERR, DWORK, IWORK2, INFO)
CALL SPPRFS 
(UPLO, N, NRHS, SA, SAF, SB, LDB, SX, LDX, SFERR, 
SBERR, SWORK, IWORK2, INFO)
CALL ZPPRFS 
(UPLO, N, NRHS, ZA, ZAF, ZB, LDB, ZX, LDX, DFERR, 
DBERR, ZWORK, DWORK2, INFO)
CALL CPPRFS 
(UPLO, N, NRHS, CA, CAF, CB, LDB, CX, LDX, SFERR, 
SBERR, CWORK, SWORK2, INFO)






void dpprfs 
(char uplo, int n, int nrhs, double *da, double *daf, 
double *db, int ldb, double *dx, int ldx, double 
*dferr, double *dberr, int *info)
void spprfs 
(char uplo, int n, int nrhs, float *sa, float *saf, 
float *sb, int ldb, float *sx, int ldx, float *sferr, 
float *sberr, int *info)
void zpprfs 
(char uplo, int n, int nrhs, doublecomplex *za, 
doublecomplex *zaf, doublecomplex *zb, int ldb, 
doublecomplex *zx, int ldx, double *dferr, double 
*dberr, int *info)
void cpprfs 
(char uplo, int n, int nrhs, complex *ca, complex *caf, 
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.

NRHS

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

xA

Upper or lower triangle of the matrix A.
The dimension of xA is (N × N + N) / 2.

xAF

Cholesky factorization of A as computed by xPPTRF. The dimension of xAF is (N × N + N) / 2.

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
      PARAMETER        (N = 4)
      PARAMETER        (LDA = (N * (N + 1)) / 2)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = LDB)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LDA), AF(LDAF), B(LDB,NRHS)
      DOUBLE PRECISION  B1(LDB,NRHS), BERR(NRHS), FERR(NRHS)
      DOUBLE PRECISION  WORK(LDWORK), X(LDX,NRHS)
      INTEGER           INFO, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DPPRFS, DPPTRF, DPPTRS, DSPMV
      INTRINSIC         ABS
C
C     Initialize the array A to store in symmetric form the
C     coefficient matrix A shown below.  Initialize the array
C     B to store the right hand side vector b shown below.
C
C         10**5   10**-5  10**-6  10**-7         3 * 10**4
C     A = 10**-5  10**5   10**-6  10**-7     b = 3 * 10**3
C         10**-6  10**-6  10**5   10**-7         3 * 10**2
C         10**-7  10**-7  10**-7  10**5          3 * 10**1
C
      DATA A / 1.0D5, 1.0D-5, 1.0D-6, 1.0D-7, 1.0D5, 1.0D-6,
     $         1.0D-7, 1.0D5, 1.0D-7, 1.0D5 /
      DATA B / 3.0D4, 3.0D3, 3.0D2, 3.0D1 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      PRINT 1010, A(1), A(2), A(3), A(4)
      PRINT 1010, A(2), A(5), A(6), A(7)
      PRINT 1010, A(3), A(6), A(8), A(9)
      PRINT 1010, A(4), A(7), A(9), A(10)
      CALL DCOPY (LDA, A, 1, AF, 1)
      PRINT 1020
      PRINT 1030, B
      CALL DCOPY (LDB*NRHS, B, 1, X, 1)
C
C     Cholesky factor A.
C
      CALL DPPTRF ('LOWER TRIANGLE OF A STORED', N, AF, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
C
C     Solve Ax=b and print the solution.
C
      CALL DPPTRS ('LOWER TRIANGLE OF A STORED', N, NRHS, AF,
     $             X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, ABS(INFO)
        STOP 2
      END IF
      PRINT 1060
      PRINT 1030, X
      CALL DSPMV ('LOWER TRIANGLE OF A STORED', N, 1.0D0, A, X, 1,
     $            0.0D0, B1, 1)
      PRINT 1070
      PRINT 1030, B1
C
C     Refine the solution to Ax=b and print the refined solution.
C
      CALL DPPRFS ('LOWER TRIANGLE OF A STORED', N, NRHS, A, AF,
     $             B, LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1080, ABS(INFO)
        STOP 3
      END IF
      PRINT 1090
      PRINT 1030, X
      CALL DSPMV ('LOWER TRIANGLE OF A STORED', N, 1.0D0, A, X, 1,
     $            0.0D0, B1, 1)
      PRINT 1100
      PRINT 1030, B1
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F14.7))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (3X, E25.17)
 1040 FORMAT (1X, 'Error factoring A, INFO = ', I5)
 1050 FORMAT (1X, 'Illegal argument to DPPTRS, argument #', I2)
 1060 FORMAT (/1X, 'Initial solution to Ax=b:')
 1070 FORMAT (/1X, 'Ax with the initial x:')
 1080 FORMAT (1X, 'Illegal argument to DPPRFS, INFO = ', I2)
 1090 FORMAT (/1X, 'Refined solution to Ax=b:')
 1100 FORMAT (/1X, 'Ax with refined x:')
C
      END
 

Sample Output

 
 A:
   100000.0000000        0.0000100        0.0000010        0.0000001
        0.0000100   100000.0000000        0.0000010        0.0000001
        0.0000010        0.0000010   100000.0000000        0.0000001
        0.0000001        0.0000001        0.0000001   100000.0000000



 b:
     0.30000000000000000E+05
     0.30000000000000000E+04
     0.30000000000000000E+03
     0.30000000000000000E+02



 Initial solution to Ax=b:
     0.29999999999696958E+00
     0.29999999969969694E-01
     0.29999999966996991E-02
     0.29999999966700002E-03



 Ax with the initial x:
     0.29999999999999985E+05
     0.29999999999999995E+04
     0.29999999999999989E+03
     0.30000000000000004E+02



 Refined solution to Ax=b:
     0.29999999999696969E+00
     0.29999999969969698E-01
     0.29999999966996999E-02
     0.29999999966700002E-03



 Ax with refined x:
     0.29999999999999996E+05
     0.30000000000000000E+04
     0.30000000000000000E+03
     0.30000000000000004E+02






Previous Next Contents Generated Index Doc Set Home