Previous Next Contents Generated Index Doc Set Home



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

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, which has been Cholesky-factored by xPOTRF, and general matrices B and X. These subroutines also compute forward error bounds and backward error estimates for the refined solution.

Calling Sequence

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






void dporfs 
(char uplo, int n, 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 sporfs 
(char uplo, int n, 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 zporfs 
(char uplo, int n, 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 cporfs 
(char uplo, int n, 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.

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 xPOTRF.

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

Sample Output

 
 A in full form:
   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



 A in symmetric form:  (* in unused elements)
   100000.0000000   **************   **************   **************
        0.0000100   100000.0000000   **************   **************
        0.0000010        0.0000010   100000.0000000   **************
        0.0000001        0.0000001        0.0000001   100000.0000000



 b:
     0.10000000000000000E+05
     0.10000000000000000E+05
     0.10000000000000000E+05
     0.10000000000000000E+05



 Initial solution to Ax=b:
     0.99999999988899982E-01
     0.99999999988899982E-01
     0.99999999997899963E-01
     0.99999999999699954E-01



 Ax with the initial x:
     0.99999999999999982E+04
     0.99999999999999982E+04
     0.99999999999999964E+04
     0.99999999999999964E+04



 Refined solution to Ax=b:
     0.99999999988899996E-01
     0.99999999988899996E-01
     0.99999999997899991E-01
     0.99999999999699968E-01



 Ax with refined x:
     0.10000000000000000E+05
     0.10000000000000000E+05
     0.10000000000000000E+05
     0.99999999999999982E+04






Previous Next Contents Generated Index Doc Set Home