Previous Next Contents Generated Index Doc Set Home



Refined Solution to a Linear System in an LU-Factored General Matrix in Banded Storage

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

Calling Sequence

CALL DGBRFS
(TRANSA, N, NSUB, NSUPER, NRHS, DA, LDA, DAF, LDAF, 
IPIVOT, DB, LDB, DX, LDX, DFERR, DBERR, DWORK, IWORK2, 
INFO)
CALL SGBRFS 
(TRANSA, N, NSUB, NSUPER, NRHS, SA, LDA, SAF, LDAF, 
IPIVOT, SB, LDB, SX, LDX, SFERR, SBERR, SWORK, IWORK2, 
INFO)
CALL ZGBRFS 
(TRANSA, N, NSUB, NSUPER, NRHS, ZA, LDA, ZAF, LDAF, 
IPIVOT, ZB, LDB, ZX, LDX, ZFERR, ZBERR, ZWORK, DWORK2, 
INFO)
CALL CGBRFS 
(TRANSA, N, NSUB, NSUPER, NRHS, CA, LDA, CAF, LDAF, 
IPIVOT, CB, LDB, CX, LDX, CFERR, CBERR, CWORK, SWORK2, 
INFO)






void dgbrfs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
double *da, int lda, double *daf, int ldaf, int 
*ipivot, double *db, int ldb, double *dx, int ldx, 
double *dferr, double *dberr, int *info)
void sgbrfs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
float *sa, int lda, float *saf, int ldaf, int *ipivot, 
float *sb, int ldb, float *sx, int ldx, float *sferr, 
float *sberr, int *info)
void zgbrfs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
doublecomplex *za, int lda, doublecomplex *zaf, int 
ldaf, int *ipivot, doublecomplex *zb, int ldb, 
doublecomplex *zx, int ldx, double *dferr, double 
*dberr, int *info)
void cgbrfs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
complex *ca, int lda, complex *caf, int ldaf, int 
*ipivot, complex *cb, int ldb, complex *cx, int ldx, 
float *sferr, float *sberr, int *info)

Arguments

TRANSA

Indicates the form of the linear system whose solution is to be refined. The legal values for TRANSA are listed below. Any values not listed below are illegal.

'N' or 'n'

No transpose, refine AX = B.

'T' or 't'

Transpose, refine ATX = B.

'C' or 'c'

Conjugate transpose, refine AHX = B.

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

N

Order of the matrix A. N 0.

NSUB

Number of subdiagonals of A. N-1 NSUB 0 but if N = 0 then NSUB = 0.

NSUPER

Number of superdiagonals of A. N-1 NSUPER 0 but if N = 0 then NSUPER = 0.

NRHS

Number of right-hand sides, equal to the number of columns in the matrices B and X. NRHS 0.

xA

Matrix A.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA NSUB + NSUPER + 1.

xAF

LU factorization of the matrix A, as computed by xGBTRF.

LDAF

Leading dimension of the array AF as specified in a dimension or type statement. LDAF 2 × NSUB + NSUPER + 1.

IPIVOT

Pivot indices as computed by xGBTRF.

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.

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, N
      INTEGER           NRHS, NSUB, NSUPER
      PARAMETER        (N = 4)
      PARAMETER        (NSUB = 1)
      PARAMETER        (NSUPER = 0)
      PARAMETER        (LDA = 2*NSUB + 1 + NSUPER)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LDA,N), AF(LDAF,N), B(LDB,NRHS)
      DOUBLE PRECISION  B1(LDB,NRHS), BERR(NRHS), EPSLON
      DOUBLE PRECISION  FERR(NRHS), WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW, IWORK(LDIWRK)
C
      EXTERNAL          DCOPY, DGBMV, DGBTRF, DGBTRS, DGBRFS
      INTRINSIC         ABS, DBLE, MAX
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                         4
C     A = 9   0                 b = 4
C             0.25   5              4
C                    0   70         4
C
      DATA A / NSUB*8D8, 0.0D0, 9.0D0, NSUB*8D8, 0.0D0, 2.5D-1,
     $         NSUB*8D8, 5.0D0, 0.0D0, NSUB*8D8, 7.0D1, 8D8 /
      DATA B / N*4.0D0 /
C
C     Add a small value to the elements of A on the diagonal and
C     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                         0+e  70+e
C
      EPSLON = ((((2.0D0 / 3.0D0) + 8.0D0) - 8.0D0) - 
     $   (2.0D0 / 3.0D0))
      DO 110, ICOL = 1, N
        DO 100, IROW = 1, NSUB + 1 + NSUPER
          A(NSUB+IROW,ICOL) = A(NSUB+IROW,ICOL) + EPSLON
  100   CONTINUE
  110 CONTINUE
      CALL DCOPY (LDA*N, A, 1, AF, 1)
C
C     Print the A array.
C
      PRINT 1000
      PRINT 1010, A(2,1), 0.0D0,  0.0D0,  0.0D0
      PRINT 1010, A(3,1), A(2,2), 0.0D0,  0.0D0
      PRINT 1010, 0.0D0,  A(3,2), A(2,3), 0.0D0
      PRINT 1010, 0.0D0,  0.0D0,  A(3,3), A(2,4)
      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     LU factor A.
C
      CALL DGBTRF (N, N, NSUB, NSUPER, AF, LDAF, IPIVOT, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        STOP 1
      END IF
C
C     Solve Ax=b and print the solution.
C
      CALL DGBTRS ('NO TRANSPOSE A', N, NSUB, NSUPER, NRHS, AF,
     $             LDAF, IPIVOT, X, LDX, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1060, INFO
        STOP 2
      END IF
      PRINT 1070
      PRINT 1080, X
      CALL DGBMV ('NO TRANSPOSE A', N, N, NSUB, NSUPER, 1.0D0,
     $            A(NSUB+1,1), LDA, X, 1, 0.0D0, B1, 1)
      PRINT 1090
      PRINT 1040, B1
C
C     Refine the initial solution and print the new solution.
C
      CALL DGBRFS ('NO TRANSPOSE A', N, NSUB, NSUPER, NRHS,
     $             A(NSUB+1,1), LDA, AF, LDAF, IPIVOT, B, LDB,
     $             X, LDX, FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1100, INFO
        STOP 3
      END IF
      PRINT 1110
      PRINT 1080, X
      CALL DGBMV ('NO TRANSPOSE A', N, N, NSUB, NSUPER, 1.0D0,
     $            A(NSUB+1,1), LDA, X, 1, 0.0D0, B1, 1)
      PRINT 1120
      PRINT 1040, B1
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(2X, F18.15))
 1020 FORMAT (/1X, 'A in banded form:  (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, F19.15)
 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, E24.16)
 1090 FORMAT (/1X, 'Ax with initial x:')
 1100 FORMAT (1X, 'Error improving solution in DGBRFS, INFO = ',
     $        I5)
 1110 FORMAT (/1X, 'Refined solution for Ax=b:')
 1120 FORMAT (/1X, 'Ax with improved x:')
C
      END
 

Sample Output

 
 A in full form:
  -0.000000000000001   0.000000000000000   0.000000000000000   0.000000000000000
   9.000000000000000  -0.000000000000001   0.000000000000000   0.000000000000000
   0.000000000000000   0.249999999999999   4.999999999999999   0.000000000000000
   0.000000000000000   0.000000000000000  -0.000000000000001  70.000000000000000



 A in banded form:  (* in unused elements)
  ******************  ******************  ******************  ******************
  -0.000000000000001  -0.000000000000001   4.999999999999999  70.000000000000000
   9.000000000000000   0.249999999999999  -0.000000000000001  ******************



 b:
   4.000000000000000
   4.000000000000000
   4.000000000000000
   4.000000000000000



 Initial solution for Ax=b:
  -0.7205759403792791E+16
  -0.1168266793170336E+33
   0.5841333965851668E+31
   0.4632273902438220E+14



 Ax with initial x:
   3.999999999999999
   8.000000000000000
   0.000000000000000
   4.000000000000000



 Refined solution for Ax=b:
  -0.7205759403792793E+16
  -0.1168266793170336E+33
   0.5841333965851669E+31
   0.4632273902438221E+14



 Ax with improved x:
   4.000000000000000
   0.000000000000000
   0.000000000000000
   4.500000000000000






Previous Next Contents Generated Index Doc Set Home