Previous Next Contents Generated Index Doc Set Home



Error Bounds and Estimates for the Solution to a Linear System in a Triangular Matrix in Banded Storage

The subroutines described in this section compute the 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 in banded storage and general matrices B and X. Note that these subroutines do not refine the computed solution as other xxxRFS subroutines do.

Calling Sequence

CALL DTBRFS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, DA, LDA, DB, LDB, 
DX, LDX, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL STBRFS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, SA, LDA, SB, LDB, 
SX, LDX, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZTBRFS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, ZA, LDA, ZB, LDB, 
ZX, LDX, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CTBRFS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, CA, LDA, CB, LDB, 
CX, LDX, SFERR, SBERR, CWORK, SWORK2, INFO)






void dtbrfs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, double *da, int lda, double *db, int ldb, 
double *dx, int ldx, double *dferr, double *dberr, int 
*info)
void stbrfs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, float *sa, int lda, float *sb, int ldb, float 
*sx, int ldx, float *sferr, float *sberr, int *info)
void ztbrfs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, doublecomplex *za, int lda, doublecomplex 
*zb, int ldb, doublecomplex *zx, int ldx, double 
*dferr, double *dberr, int *info)
void ctbrfs 
(char uplo, char trans, char diag, int n, int ndiag, 
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.

NDIAG

Number of superdiagonals or subdiagonals of the triangular matrix A. N-1 NDIAG 0 but if N = 0 then NDIAG = 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 NDIAG + 1.

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
      INTEGER           NDIAG
      PARAMETER        (N = 4)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (LDA = NDIAG + 1)
      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), B1(LDB,NRHS)
      DOUBLE PRECISION  BERR(NRHS), EPSLON, FERR(NRHS)
      DOUBLE PRECISION  WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DTBMV, DTBRFS, DTBTRS
      INTRINSIC         MAX, SQRT
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         0                        3
C     A = 9   0                b = 5
C             0.25   5             7
C                    7   0        11
C
      DATA A / 0.0D0, 9.0D0, 0.0D0, 2.5D-1, 5.0D0, 7.0D0, 0.0D0,
     $         8D8 /
      DATA B / 3.0D0, 5.0D0, 7.0D0, 1.1D1 /
C
C     Add a small value to the elements of A on the diagonal 
C     and on the subdiagonal.  After this loop, A will contain
C     something similar to:
C
C          e
C     A = 9+e      e
C               0.25+e   5+e
C                         e    7+e
C
      EPSLON = ((((2.0D0 / 3.0D0) + 2.0D0) - 2.0D0) -
     $         (2.0D0 / 3.0D0))
      DO 110, ICOL = 1, N
        DO 100, IROW = 1, NDIAG + 1
          A(IROW,ICOL) = A(IROW,ICOL) + EPSLON
          A(1,ICOL) = A(1,ICOL) + EPSLON
  100   CONTINUE
  110 CONTINUE
      A(LDA,N) = SQRT(-1.0D0)
C
C     Print the A array.
C
      PRINT 1000
      DO 120, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - NDIAG - 1),
     $              (A(1 + IROW - ICOL, ICOL),
     $               ICOL = MAX(1,IROW - NDIAG), 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 DTBTRS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NOT UNIT DIAGONAL A', N, NDIAG, NRHS, A,
     $             LDA, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1060, INFO
        STOP 2
      END IF
      PRINT 1070
      PRINT 1080, X
      CALL DCOPY (N, X, 1, B1, 1)
      CALL DTBMV ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $            'NOT UNIT DIAGONAL A', N, NDIAG, A, LDA, B1, 1)
      PRINT 1090
      PRINT 1040, B1
C
C     Refine the initial solution and print the new solution.
C
      CALL DTBRFS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NOT UNIT TRIANGULAR A', N, NDIAG, NRHS,
     $             A, LDA, B, LDB, X, LDX, FERR, BERR, WORK,
     $             IWORK, INFO)
      IF (INFO .EQ. 0) THEN
        PRINT 1100, (IROW, BERR(IROW), IROW = 1, NRHS)
        PRINT 1110, (IROW, FERR(IROW), IROW = 1, NRHS)
      ELSE
        PRINT 1120, INFO
        STOP 3
      END IF
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(2X, E14.8))
 1020 FORMAT (/1X, 'A in banded form: ("NaN" in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, F20.17)
 1050 FORMAT (1X, 'Error factoring A in DGBTRF, INFO = ', I5)
 1060 FORMAT (1X, 'Error solving Ax=b in DGBTRF, INFO = ', I5)
 1070 FORMAT (/1X, 'Initial solution for Ax=b:')
 1080 FORMAT (1X, E22.16)
 1090 FORMAT (/1X, 'Ax with initial x:')
 1110 FORMAT (/1X, 'Backward error bound for system #', I2, ' =',
     $        E15.8)
 1100 FORMAT (1X, 'Forward error bound for system #', I2, ' = ',
     $        E15.8)
 1120 FORMAT (1X, 'Error estimating error bounds, INFO = ', I5)
C
      END
 

Sample Output

 
 A in full form:
  -.33306691E-15  0.00000000E+00  0.00000000E+00  0.00000000E+00
  0.90000000E+01  -.33306691E-15  0.00000000E+00  0.00000000E+00
  0.00000000E+00  0.25000000E+00  0.50000000E+01  0.00000000E+00
  0.00000000E+00  0.00000000E+00  0.70000000E+01  -.33306691E-15



 A in banded form: ("NaN" in unused elements)
  -.33306691E-15  -.33306691E-15  0.50000000E+01  -.33306691E-15
  0.90000000E+01  0.25000000E+00  0.70000000E+01  NaN           



 b:
  3.00000000000000000
  5.00000000000000000
  7.00000000000000000
 11.00000000000000000



 Initial solution for Ax=b:
 -.9007199254740992E+16
 -.2433889152438200E+33
 0.1216944576219100E+32
 0.2557627865329079E+48



 Ax with initial x:
  3.00000000000000000
  0.00000000000000000
  0.00000000000000000
  0.00000000000000000
 Forward error bound for system # 1 =  0.30839528E-16



 Backward error bound for system # 1 = 0.27262143E-14






Previous Next Contents Generated Index Doc Set Home