Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a General Matrix in Banded Storage (Expert Driver)

The subroutines described in this section solve a linear system AX = B, ATX = B, or AHX = B for a general matrix A in banded storage, and general matrices B and X. These subroutines also compute forward error bounds and backward error estimates for the solution, estimate the condition number of the matrix A and, optionally, equilibrate the system before computing a solution. Note that the simple driver xGBSV is also available.

Calling Sequence

CALL DGBSVX
(FACT, TRANSA, N, NSUB, NSUPER, NRHS, DA, LDA, DAF, 
LDAF, IPIVOT, EQUED, DROWSC, DCOLSC, DB, LDB, DX, LDX, 
DRCOND, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL SGBSVX
(FACT, TRANSA, N, NSUB, NSUPER, NRHS, SA, LDA, SAF, 
LDAF,IPIVOT, EQUED, SROWSC, SCOLSC, SB, LDB, SX, LDX, 
SRCOND, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZGBSVX
(FACT, TRANSA, N, NSUB, NSUPER, NRHS, ZA, LDA, ZAF, 
LDAF, IPIVOT, EQUED, DROWSC, DCOLSC, ZB, LDB, ZX, LDX, 
DRCOND, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CGBSVX
(FACT, TRANSA, N, NSUB, NSUPER, NRHS, CA, LDA, CAF, 
LDAF, IPIVOT, EQUED, SROWSC, SCOLSC, CB, LDB, CX, LDX, 
SRCOND, SFERR, SBERR, CWORK, SWORK2, INFO)






void dgbsvx
(char fact, char trans, int n, int nsub, int nsuper, 
int nrhs, double *da, int lda, double *daf, int ldaf, 
int *ipivot, char *equed, double *drowsc, double 
*dcolsc, double *db, int ldb, double *dx, int ldx, 
double *drcond, double *dferr, double *dberr, int 
*info)
void sgbsvx
(char fact, char trans, int n, int nsub, int nsuper, 
int nrhs, float *sa, int lda, float *saf, int ldaf, int 
*ipivot, char *equed, float *srowsc, float *scolsc, 
float *sb, int ldb, float *sx, int ldx, float *srcond, 
float *sferr, float *sberr, int *info)
void zgbsvx
(char fact, char trans, int n, int nsub, int nsuper, 
int nrhs, doublecomplex *za, int lda, doublecomplex 
*zaf, int ldaf, int *ipivot, char *equed, double 
*drowsc, double *dcolsc, doublecomplex *zb, int ldb, 
doublecomplex *zx, int ldx, double *drcond, double 
*dferr, double *dberr, int *info)
void cgbsvx
(char fact, char trans, int n, int nsub, int nsuper, 
int nrhs, complex *ca, int lda, complex *caf, int ldaf, 
int *ipivot, char *equed, float *srowsc, float *scolsc, 
complex *cb, int ldb, complex *cx, int ldx, float 
*srcond, float *sferr, float *sberr, int *info)

Arguments

FACT

Indicates whether or not the factored form of the matrix A is supplied on entry, and if not, whether the matrix A will be equilibrated before it is factored. FACT interacts with EQUED, A, and AF as shown in this table. FACT also affects the contents of IPIVOT; see its description below.



FACT
EQUED entry
EQUED exit
A entry
A exit
AF entry
AF exit

'F', 'f'

'B', 'b'

Unchanged

Row- and col-equilibrated A

Unchanged

LU-factored row- and col-equilibrated A

Unchanged

'F', 'f'

'C','c'

Unchanged

Col-equilibrated A

Unchanged

LU-factored col-equilibrated A

Unchanged

'F', 'f'

'N', 'n'

Unchanged

Matrix A

Unchanged

LU-factored A

Unchanged

'F', 'f'

'R', 'r'

Unchanged

Row-equilibrated A

Unchanged

LU-factored row-equilibrated A

Unchanged

'E', 'e'

Not used

'B'

Matrix A

Row- and col-equilibrated A

Not used

LU-factored row- and col-equilibrated A

'E', 'e'

Not used

'C'

Matrix A

Col-equilibrated A

Not used

LU-factored col-equilibrated A

'E', 'e'

Not used

'N'

Matrix A

Unchanged

Not used

LU-factored A

'E', 'e'

Not used

'R'

Matrix A

Row-equilibrated A

Not used

LU-factored row-equilibrated A

'N', 'n'

Not used

'N'

Matrix A

Unchanged

Not used

LU-factored A



The above table uses the following abbreviations:
LU-factored = the factored form of A as computed by xGBTRF
Row-equilibrated A = diag(ROWSC) × A
Col-equilibrated A = A × diag(COLSC)
Row- and col-equilibrated A = diag(ROWSC) × A × diag(COLSC)

TRANSA

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

'N' or 'n'

No transpose, solve AX = B.

'T' or 't'

Transpose, solve ATX = B.

'C' or 'c'

Conjugate transpose, solve 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

The contents of A vary depending on the values of FACT and EQUED. See the table for the argument FACT above.

LDA

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

xAF

The contents of AF vary depending on the values of FACT and EQUED. See the table for the argument FACT above.

LDAF

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

IPIVOT

Pivot indices; values vary depending on FACT and EQUED as shown below:



FACT
EQUED Entry
EQUED Exit
IPIVOT Entry
IPIVOT Exit

'F' or 'f'

'B', 'b', 'C', 'c', 'R', 'r'

Not used

Pivot indices from LU factorization of equilibrated A as computed by xGBTRF

Unchanged

'F' or 'f'

'N' or 'n'

Not used

Pivot indices from LU factorization of A as computed by xGBTRF

Unchanged

'E' or 'e'

Not used

'B', 'C', 'R'

Not used

Pivot indices from LU factorization of equilibrated A as computed by xGBTRF

'E' or 'e'

Not used

'N'

Not used

Pivot indices from LU factorization of A as computed by xGBTRF

'N' or 'n'

Not used

'B', 'C', 'R'

Not used

Pivot indices from LU factorization of equilibrated A as computed by xGBTRF

'N' or 'n'

Not used

'N'

Not used

Pivot indices from LU factorization of A as computed by xGBTRF



EQUED

EQUED interacts with FACT and IPIVOT as shown in the tables above.
Note that one must be careful about specifying lowercase letters for the entry value of EQUED when FACT = 'F' or 'f' because ordinarily LAPACK will always return a capital letter. If the caller specifies 'b', 'c', 'n', or 'r' on entry then the lowercase letter will still be in EQUED on exit. The caller may later draw incorrect conclusions if the code contains a series of IF statements to determine whether EQUED = 'B', 'C', 'N', or 'R'.

xROWSC

On entry, if FACT = 'F' or 'f' and EQUED = 'R', 'r', 'B', or 'b', then ROWSC contains the N row scale factors that were used to equilibrate A. Each element of ROWSC must be positive. If FACT or EQUED have other values, the entry values of ROWSC are not used.
On exit, if FACT = 'E' or 'e' and EQUED = 'R' or 'B', then ROWSC contains the N row scale factors that were used to equilibrate A. If FACT or EQUED have other values, ROWSC is unchanged.

xCOLSC

On entry, if FACT = 'F' or 'f' and EQUED = 'C', 'c', 'B', or 'b', then COLSC contains the N column scale factors that were used to equilibrate A. Each element of COLSC must be positive. If FACT or EQUED have other values, the entry values of COLSC are not used.
On exit, if FACT = 'E' or 'e' and EQUED = 'C' or 'B', then COLSC contains the N column scale factors that were used to equilibrate A. If FACT or EQUED have other values, COLSC is unchanged.

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, the value of B is determined by the input value TRANSA and the output value of EQUED as shown below. For combinations of TRANSA and EQUED not shown below, B is not changed.

TRANSA

EQUED

Output value of B

'N', 'n'

'R' or 'B'

diag(R) × B

'T', 't', 'C', 'c'

'C' or 'B'

diag(C) × B

LDB

Leading dimension of the array B as specified in a dimension or type statement. LDB max(1, N).

xX

On exit, the N×NRHS solution matrix for the original problem. Note that the solution to the original problem may differ from the solution to the equilibrated system for the cases shown below:

TRANSA

EQUED

Solution to equilibrated system

'N', 'n'

'C' or 'B'

diag(C)-1 × X

'T', 't', 'C', 'c'

'R' or 'B'

diag(R)-1 × X

LDX

Leading dimension of the array X as specified in a dimension or type statement. LDX max(1, N).

xRCOND

On exit, an estimate of the reciprocal condition number of the matrix A after equilibration, if any, where the reciprocal condition number is defined to be 1 / (||A|| × ||A-1||). The reciprocal of the condition number is estimated instead of the condition number itself to avoid overflow or division by zero. If RCOND is less than machine precision (in particular, if RCOND = 0) then A is singular to working precision. In this case, INFO > 0 is returned and the solution and error bounds are not computed.

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.

1 INFO N

U(i,i), where i = INFO, is exactly zero and U is therefore singular. The LU factorization of A has been completed, but the solution and error bounds could not be computed.

INFO = N+1

RCOND is less than machine precision. The LU factorization of A has been completed but A is singular to working precision and so the solution and error bounds could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDAB, LDAFB, LDB, LDX, N, NRHS, NSUB
      INTEGER           NSUPER, SIZEAB, SIZEB, SIZEX
      PARAMETER        (NSUB = 1)
      PARAMETER        (NSUPER = 1)
      PARAMETER        (N = 4)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDAB = NSUB + NSUPER + 1)
      PARAMETER        (LDAFB = 2*NSUB + NSUPER + 1)
      PARAMETER        (LDB = N)
      PARAMETER        (LDX = N)
      PARAMETER        (SIZEAB = LDAB * N)
      PARAMETER        (SIZEB = LDB * NRHS)
      PARAMETER        (SIZEX = LDX * NRHS)
C
      DOUBLE PRECISION  AB(LDAB,N), AFB(LDAFB,N), B(LDB,NRHS)
      DOUBLE PRECISION  BERR(NRHS), COLSCA(N), FERR(NRHS), RCOND
      DOUBLE PRECISION  ROWSCA(N), WORK(3*N), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW, IWORK(N)
      CHARACTER*1       EQUED
C
      EXTERNAL          DGBSVX
      INTRINSIC         MAX0, MIN0
C
C     Initialize the array AB to store in banded storage mode the
C     4x4 matrix A with one subdiagonal and one superdiagonal
C     shown below. Initialize the array B to store the vector b 
C     shown below.
C
C          2  -1                5
C     A = -1   2  -1        b = 5
C             -1   2  -1        5
C                 -1   2        5
C
      DATA AB /  8.8D8, 2.0D0, -1.0D0, -1.0D0, 2.0D0, -1.0D0,
     $          -1.0D0, 2.0D0, -1.0D0, -1.0D0, 2.0D0, 8.8D8 /
      DATA B / SIZEB*5.0D0 /
      DATA X / SIZEX*9.9D9 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      PRINT 1010, AB(2,1), AB(1,2), 0.0D0,   0.0D0
      PRINT 1010, AB(3,1), AB(2,2), AB(1,3), 0.0D0
      PRINT 1010, 0.0D0,   AB(3,2), AB(2,3), AB(1,4)
      PRINT 1010, 0.0D0,   0.0D0,   AB(3,3), AB(2,4)
      PRINT 1020
      PRINT 1010, ((AB(IROW,ICOL), ICOL = 1, N), IROW = 1, LDAB)
      PRINT 1030
      PRINT 1040, B
C
C     Solve the system Ax=b.
C
      CALL DGBSVX ('EQUILIBRATE A', 'NO TRANSPOSE A', N, NSUB,
     $             NSUPER, NRHS, AB, LDAB, AFB, LDAFB, IPIVOT,
     $             EQUED, ROWSCA, COLSCA, B, LDB, X, LDX, RCOND,
     $             FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .EQ. 0) THEN
        PRINT 1050
        PRINT 1040, X
        PRINT 1060, 1.0D0 / RCOND
        IF (EQUED .EQ. 'N') PRINT 1070
        IF (EQUED .EQ. 'R') PRINT 1080
        IF (EQUED .EQ. 'C') PRINT 1090
        IF (EQUED .EQ. 'B') PRINT 1100
        PRINT 1110, (IROW, BERR(IROW), IROW = 1, NRHS)
        PRINT 1120, (IROW, FERR(IROW), IROW = 1, NRHS)
      ELSE
        PRINT 1130, INFO
        IF (INFO .EQ. (N + 1)) THEN
          PRINT 1140
        END IF
      END IF
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(3X, F4.1))
 1020 FORMAT (/1X, 'A in banded form:  (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, 2X, F4.1)
 1050 FORMAT (/1X, 'x:')
 1060 FORMAT (/1X, 'Estimated condition number of A: ', F7.2)
 1070 FORMAT (1X, 'No equilibration was required for A.')
 1080 FORMAT (1X, 'Row equilibration was done on A.')
 1090 FORMAT (1X, 'Column equilibration was done on A.')
 1100 FORMAT (1X, 'Row and column equilibration was done on A.')
 1110 FORMAT (/1X, 'Backward error for system #', I1, ': ', E12.6)
 1120 FORMAT (1X, 'Forward error for system #', I1, ': ', E12.6)
 1130 FORMAT (1X, 'Error in solving system, INFO = ', I3)
 1140 FORMAT (1X, 'Matrix is singular to working precision.')
C
      END
 

Sample Output

 
 A in full form:
    2.0   -1.0    0.0    0.0
   -1.0    2.0   -1.0    0.0
    0.0   -1.0    2.0   -1.0
    0.0    0.0   -1.0    2.0



 A in banded form:  (* in unused elements)
   ****   -1.0   -1.0   -1.0
    2.0    2.0    2.0    2.0
   -1.0   -1.0   -1.0   ****



 b:
    5.0
    5.0
    5.0
    5.0



 x:
   10.0
   15.0
   15.0
   10.0



 Estimated condition number of A:   12.00
 No equilibration was required for A.



 Backward error for system #1: 0.592119E-16
 Forward error for system #1: 0.511591E-14






Previous Next Contents Generated Index Doc Set Home