Previous Next Contents Generated Index Doc Set Home



Error Bounds and Estimates for the Solution of a Linear System in a Triangular Matrix in Packed Storage

The subroutines described in this section compute forward error bounds and backward error estimates for the solution to a linear system AX = B, ATX = B, or AHX = B for a triangular matrix A and general matrices B and X. Note that these subroutines do not refine the computed solution as other xxxRFS subroutines do.

Calling Sequence

CALL DTPRFS 
(UPLO, TRANSA, DIAG, N, NRHS, DA, DB, LDB, DX, LDX, 
DFERR, DBERR, DWORK, IWORK2, INFO)
CALL STPRFS 
(UPLO, TRANSA, DIAG, N, NRHS, SA, SB, LDB, SX, LDX, 
SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZTPRFS 
(UPLO, TRANSA, DIAG, N, NRHS, ZA, ZB, LDB, ZX, LDX, 
DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CTPRFS 
(UPLO, TRANSA, DIAG, N, NRHS, CA, CB, LDB, CX, LDX, 
SFERR, SBERR, CWORK, SWORK2, INFO)






void dtprfs 
(char uplo, char trans, char diag, int n, int nrhs, 
double *da, double *db, int ldb, double *dx, int ldx, 
double *dferr, double *dberr, int *info)
void stprfs 
(char uplo, char trans, char diag, int n, int nrhs, 
float *sa, float *sb, int ldb, float *sx, int ldx, 
float *sferr, float *sberr, int *info)
void ztprfs 
(char uplo, char trans, char diag, int n, int nrhs, 
doublecomplex *za, doublecomplex *zb, int ldb, 
doublecomplex *zx, int ldx, double *dferr, double 
*dberr, int *info)
void ctprfs 
(char uplo, char trans, char diag, int n, int nrhs, 
complex *ca, 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.

TRANSA

Indicates the form of the system of equations. The legal values for TRANSA are listed below. Any values not listed below are illegal.

'N' or 'n'

No transpose, use AX = B.

'T' or 't'

Transpose, use ATX = B.

'C' or 'c'

Conjugate transpose, use AHX = B.

Note that AT and AH are the same for real matrices.

DIAG

Indicates whether or not A is unit triangular. The legal values for DIAG are listed below. Any values not listed below are illegal.

'N' or 'n'

A is not unit triangular.

'U' or 'u'

A is unit triangular.

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 triangular matrix A.
The dimension of xA is (N × N + N) / 2.

If DIAG = 'U' or 'u', the diagonal elements of A are assumed to be 1 and are not used.

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

The 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
      DOUBLE PRECISION  ZERO
      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)
      PARAMETER        (ZERO = 0.0D0)
C
      DOUBLE PRECISION  A(LENGTA), B(LDB,NRHS), BERR(NRHS), EPSLON
      DOUBLE PRECISION  FERR(NRHS), WORK(LDWORK), X(LDX,NRHS)
      INTEGER           I, INFO, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DTPMV, DTPRFS, DTPTRS
      INTRINSIC         ABS, DBLE
C
C     Initialize the array A to store in banded form the matrix A
C     shown below.  Initialize the array B to store the right hand
C     side vector b shown below.
C
C         1                    4
C     A = 1   0            b = 4
C         0   1   0            4
C         0   0   1   0        4
C
      DATA A / 1.0D0, 1.0D0, 0.0D0, 0.0D0, 0.0D0, 1.0D0, 0.0D0,
     $         0.0D0, 1.0D0, 0.0D0 /
      DATA B / N*4.0D0 /
C
C     Add a small value to the elements of A on and below the
C     diagonal. After this loop, A will contain something
C     similar to:
C
C         1+e
C     A = 1+e   e
C         e     1+e   e
C         e     e     1+e   e
C
      EPSLON = ((((2.0D0 / 3.0D0) + 1.6D1) - 1.6D1) -
     $         (2.0D0 / 3.0D0))
      DO 100, I = 1, LENGTA
        A(I) = A(I) + EPSLON
  100 CONTINUE
C
C     Print the initial value of A.
C
      PRINT 1000
      PRINT 1010, A(1), ZERO, ZERO, ZERO
      PRINT 1010, A(2), A(5), ZERO, ZERO
      PRINT 1010, A(3), A(6), A(8), ZERO
      PRINT 1010, A(4), A(7), A(9), A(10)
C
C     Make a copy of B and then print B.
C
      CALL DCOPY (LDB * NRHS, B, 1, X, 1)
      PRINT 1020
      PRINT 1030, B
C
C     Solve Ax=b and print the solution.
C
      CALL DTPTRS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NO UNIT DIAGONAL A', N, NRHS, A, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
      PRINT 1050
      PRINT 1060, X
C
C     Estimate the error bounds for the computed solution.
C
      CALL DTPRFS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NO UNIT DIAGONAL A', N, NRHS, A, B, LDB,
     $             X, LDX, FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1070, ABS(INFO)
        STOP 2
      END IF
      CALL DTPMV ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $            'NO UNIT DIAGONAL A', N, A, X, 1)
      PRINT 1080
      PRINT 1030, X
      PRINT 1090, (I, BERR(I), I = 1, NRHS)
      PRINT 1100, (I, FERR(I), I = 1, NRHS)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(2X, F17.15))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F21.18)
 1040 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1050 FORMAT (/1X, 'Initial solution for Ax=b:')
 1060 FORMAT (1X, E16.8)
 1070 FORMAT (1X, 'Illegal argument to DTPRFS, argument #', I5)
 1080 FORMAT (/1X, 'Ax:')
 1090 FORMAT (/1X, 'Backward error bound for system #', I2, ' =',
     $        E14.7)
 1100 FORMAT (1X, 'Forward error bound for system #', I2, ' = ',
     $        E14.7)
C
      END
 

Sample Output

 
 A:
  1.000000000000001  0.000000000000000  0.000000000000000  0.000000000000000
  1.000000000000001  0.000000000000001  0.000000000000000  0.000000000000000
  0.000000000000001  1.000000000000001  0.000000000000001  0.000000000000000
  0.000000000000001  0.000000000000001  1.000000000000001  0.000000000000001



 b:
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000



 Initial solution for Ax=b:
   0.40000000E+01
   0.00000000E+00
   0.32753452E+16
  -0.26819715E+31



 Ax:
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000
  4.000000000000004441



 Backward error bound for system # 1 = 0.6779273E-30
 Forward error bound for system # 1 =  0.1818182E+01






Previous Next Contents Generated Index Doc Set Home