Previous Next Contents Generated Index Doc Set Home



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

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 DTRRFS 
(UPLO, TRANSA, DIAG, N, NRHS, DA, LDA, DB, LDB, DX, 
LDX, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL STRRFS 
(UPLO, TRANSA, DIAG, N, NRHS, SA, LDA, SB, LDB, SX, 
LDX, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZTRRFS 
(UPLO, TRANSA, DIAG, N, NRHS, ZA, LDA, ZB, LDB, ZX, 
LDX, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CTRRFS 
(UPLO, TRANSA, DIAG, N, NRHS, CA, LDA, CB, LDB, CX, 
LDX, SFERR, SBERR, CWORK, SWORK2, INFO)






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

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

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA 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

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
      INTEGER           LDA, LDB, LDIWRK, LDWORK, LDX, N, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LDA,N), B(LDB,NRHS), BERR(NRHS), EPSLON
      DOUBLE PRECISION  FERR(NRHS), WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DTRMV, DTRRFS, DTRTRS
      INTRINSIC         ABS, DBLE
C
C     Initialize the array A to store in the matrix A shown below.
C     Initialize the array B to store the right hand side vector b
C     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,
     $         8.8D8, 0.0D0, 1.0D0, 0.0D0,
     $         8.8D8, 8.8D8, 0.0D0, 1.0D0,
     $         8.8D8, 8.8D8, 8.8D8, 0.0D0 /
      DATA B / N*4.0D0 /
C
C     Add a small value to the elements of A on and below 
C     the 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 110, ICOL = 1, N
        DO 100, IROW = ICOL, N
          A(IROW,ICOL) = A(IROW,ICOL) + EPSLON
  100   CONTINUE
  110 CONTINUE
C
C     Print the A array.
C
      PRINT 1000
      DO 120, IROW = 1, N
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, IROW),
     $              (0.0D0, ICOL = IROW + 1, N)
  120 CONTINUE
      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     Solve Ax=b and print the solution.
C
      CALL DTRTRS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NO UNIT DIAGONAL A', N, NRHS, A, LDA, X, LDX,
     $             INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        STOP 1
      END IF
      PRINT 1060
      PRINT 1070, X
C
C     Estimate the error bounds for the computed solution.
C
      CALL DTRRFS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NO UNIT DIAGONAL A', N, NRHS, A, LDA, B, LDB,
     $             X, LDX, FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1080, ABS(INFO)
        STOP 1
      END IF
      CALL DTRMV ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $            'NO UNIT DIAGONAL A', N, A, LDA, X, 1)
      PRINT 1090
      PRINT 1040, X
      PRINT 1100, (IROW, BERR(IROW), IROW = 1, NRHS)
      PRINT 1110, (IROW, FERR(IROW), IROW = 1, NRHS)
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(1X, F17.15))
 1020 FORMAT (/1X, 'A in triangular form: ',
     $        ' (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, F21.18)
 1050 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1060 FORMAT (/1X, 'x:')
 1070 FORMAT (1X, E16.8)
 1080 FORMAT (1X, 'Illegal argument to DTRRFS, argument #', I5)
 1090 FORMAT (/1X, 'Ax:')
 1110 FORMAT (/1X, 'Backward error bound for system #', I2, ' =',
     $        E15.8)
 1100 FORMAT (1X, 'Forward error bound for system #', I2, ' = ',
     $        E15.8)
C
      END
 

Sample Output

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



 A in triangular form:  (* in unused elements)
 1.000000000000001 ***************** ***************** *****************
 1.000000000000001 0.000000000000001 ***************** *****************
 0.000000000000001 1.000000000000001 0.000000000000001 *****************
 0.000000000000001 0.000000000000001 1.000000000000001 0.000000000000001



 b:
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000



 x:
   0.40000000E+01
   0.00000000E+00
   0.32753452E+16
  -0.26819715E+31



 Ax:
  4.000000000000000000
  4.000000000000000000
  4.000000000000000000
  4.000000000000004441
 Forward error bound for system # 1 =  0.67792734E-30



 Backward error bound for system # 1 = 0.18181818E+01






Previous Next Contents Generated Index Doc Set Home