Previous Next Contents Generated Index Doc Set Home



Refined Solution to a Linear System in a UDU- or LDL-Factored Symmetric Matrix in Packed Storage

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

Calling Sequence

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






void dsprfs 
(char uplo, int n, int nrhs, double *da, double *daf, 
int *ipivot, double *db, int ldb, double *dx, int ldx, 
double *dferr, double *dberr, int *info)
void ssprfs 
(char uplo, int n, int nrhs, float *sa, float *saf, int 
*ipivot, float *sb, int ldb, float *sx, int ldx, float 
*sferr, float *sberr, int *info)
void zsprfs 
(char uplo, int n, int nrhs, doublecomplex *za, 
doublecomplex *zaf, int *ipivot, doublecomplex *zb, 
int ldb, doublecomplex *zx, int ldx, double *dferr, 
double *dberr, int *info)
void csprfs 
(char uplo, int n, int nrhs, complex *ca, complex *caf, 
int *ipivot, 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.
The dimension of xA is (N × N + N) / 2.

xAF

UDU or LDL factorization of the matrix A as computed by xSPTRF.

The dimension of xAF is (N × N + N) / 2.

IPIVOT

Pivot indices as computed by xSPTRF.

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           LDB, LDIWRK, LDWORK, LDX, LENGTA, N, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = LDB)
      PARAMETER        (LENGTA = (N * N + N) / 2)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LENGTA), AF(LENGTA), B(LDB,NRHS)
      DOUBLE PRECISION  BERR(NRHS), EPSLON, FERR(NRHS)
      DOUBLE PRECISION  WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DSPRFS, DSPTRF, DSPTRS
      INTRINSIC         ABS, MAX
C
C     Initialize the array A to store the coefficient matrix A
C     shown below.  Initialize the array B to store the right
C     hand side vector 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 A / 0.0D0, 0.0D0, 2.0D0, 0.0D0, 2.0D0, 2.0D0,
     $         0.0D0, 0.0D0, 0.0D0, 0.0D0 /
      DATA B / 3.0D1, 5.0D1, 7.0D1, 1.1D2 /
C
C     Slightly perturb some of the entries of A.  After this
C     code, A will resemble the matrix shown below.  Print A
C     after adding epsilon.
C
C          2e   -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))
      A(1) = A(1) + 2.0D0 * EPSLON
      A(2) = A(2) - EPSLON
      A(3) = A(3) + EPSLON
      A(5) = A(5) - EPSLON
      A(6) = A(6) + EPSLON
      A(9) = A(9) - EPSLON
      A(10) = A(10) - EPSLON
      PRINT 1000
      PRINT 1010, A(1), A(2), A(4), A(7)
      PRINT 1010, A(2), A(3), A(5), A(8)
      PRINT 1010, A(4), A(5), A(6), A(9)
      PRINT 1010, A(7), A(8), A(9), A(10)
      CALL DCOPY (LENGTA, A, 1, AF, 1)
C
C     Slightly perturb each element of B.  After this loop, B will
C     resemble the matrix shown below.  Print B after scaling.
C
C         30-small
C     B = 50-small
C         70-small
C        110-small
C
      DO 110, ICOL = 1, NRHS
        DO 100, IROW = 1, N
          B(IROW,ICOL) = B(IROW,ICOL) * (1.0D0 - EPSLON)
  100   CONTINUE
  110 CONTINUE
      CALL DCOPY (LDB * NRHS, B, 1, X, 1)
      PRINT 1020
      PRINT 1030, B
C
C     LDL factor A.
C
      CALL DSPTRF ('UPPER TRIANGLE OF A STORED', N, AF, IPIVOT,
     $             INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
C
C     Solve Ax=b and print the solution.
C
      CALL DSPTRS ('UPPER TRIANGLE OF A STORED', N, NRHS, AF,
     $             IPIVOT, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        STOP 2
      END IF
      PRINT 1060
      PRINT 1070, X
      PRINT 1080
      PRINT 1030,                 A(1) * X(1,1) + A(2) * X(2,1)
      PRINT 1030, A(2) * X(1,1) + A(3) * X(2,1) + A(5) * X(3,1)
      PRINT 1030, A(5) * X(2,1) + A(6) * X(3,1) + A(9) * X(4,1)
      PRINT 1030, A(9) * X(3,1) + A(10) * X(4,1)
C
C     Refine the solution to Ax=b and print the refined solution.
C
      CALL DSPRFS ('UPPER TRIANGLE OF A STORED', N, NRHS, A, AF,
     $             IPIVOT, B, LDB, X, LDX, FERR, BERR, WORK,
     $             IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1090, ABS(INFO)
        STOP 3
      END IF
      PRINT 1100
      PRINT 1070, X
      PRINT 1110
      PRINT 1030,                 A(1) * X(1,1) + A(2) * X(2,1)
      PRINT 1030, A(2) * X(1,1) + A(3) * X(2,1) + A(5) * X(3,1)
      PRINT 1030, A(5) * X(2,1) + A(6) * X(3,1) + A(9) * X(4,1)
      PRINT 1030, A(9) * X(3,1) + A(10) * X(4,1)
      PRINT 1120, FERR(1)
      PRINT 1130, 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, 'Error factoring A, INFO = ', I5)
 1050 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1060 FORMAT (/1X, 'Initial solution to Ax=b:')
 1070 FORMAT (1X, E25.17)
 1080 FORMAT (/1X, 'Ax with the initial x:')
 1090 FORMAT (1X, 'Illegal argument to DSPRFS, INFO = ', I2)
 1100 FORMAT (/1X, 'Refined solution to Ax=b:')
 1110 FORMAT (/1X, 'Ax with refined x:')
 1120 FORMAT (/1X, 'Forward error:  ', E14.8)
 1130 FORMAT (1X, 'Backward error: ', E14.8)
C
      END
 

Sample Output

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



 b:
  29.99999999999998934
  49.99999999999998579
  69.99999999999997158
 109.99999999999995737



 Initial solution to Ax=b:
   0.70596967131753704E+17
   0.51121941716097496E+17
  -0.51121941716097480E+17
  -0.27914203095773875E+18



 Ax with the initial x:
  30.00000000000000000
  48.00000000000000000
  92.97297297297293994
 109.99999999999995737



 Refined solution to Ax=b:
   0.77650084444450784E+17
   0.65228176341491688E+17
  -0.65228176341491680E+17
  -0.26503579633234458E+18



 Ax with refined x:
  29.99999999999998579
  48.00000000000000000
  40.27465303140976971
 109.99999999999995737



 Forward error:  0.57571539E+00
 Backward error: 0.90932126E-16






Previous Next Contents Generated Index Doc Set Home