Previous Next Contents Generated Index Doc Set Home



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

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, which has been LU-factored by xGBTRF, and general matrices B and X.

Calling Sequence

CALL DGBTRS 
(TRANSA, N, NSUB, NSUPER, NRHS, DA, LDA, IPIVOT, DB, 
LDB, INFO)
CALL SGBTRS 
(TRANSA, N, NSUB, NSUPER, NRHS, SA, LDA, IPIVOT, SB, 
LDB, INFO)
CALL ZGBTRS 
(TRANSA, N, NSUB, NSUPER, NRHS, ZA, LDA, IPIVOT, ZB, 
LDB, INFO)
CALL CGBTRS 
(TRANSA, N, NSUB, NSUPER, NRHS, CA, LDA, IPIVOT, CB, 
LDB, INFO)






void dgbtrs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
double *da, int lda, int *ipivot, double *db, int ldb, 
int *info)
void sgbtrs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
float *sa, int lda, int *ipivot, float *sb, int ldb, 
int *info)
void zgbtrs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
doublecomplex *za, int lda, int *ipivot, doublecomplex 
*zb, int ldb, int *info)
void cgbtrs 
(char trans, int n, int nsub, int nsuper, int nrhs, 
complex *ca, int lda, int *ipivot, complex *cb, int 
ldb, int *info)

Arguments

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 = AH 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 matrix B. NRHS 0.

xA

LU factorization of the matrix A as computed by xGBTRF.

LDA

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

IPIVOT

Pivot indices as computed by xGBTRF.

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, the N×NRHS solution matrix X.

LDB

Leading dimension of the array B as specified in a dimension or type statement. LDB max(1, 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           LDAB, LDAG, LDB, M, N, NRHS, NSUB, NSUPER
      PARAMETER        (NSUB = 1)
      PARAMETER        (NSUPER = 1)
      PARAMETER        (M = 4)
      PARAMETER        (N = 4)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDAB = 2*NSUB + NSUPER + 1)
      PARAMETER        (LDAG = M)
      PARAMETER        (LDB = N)
C
      DOUBLE PRECISION  AB(LDAB,N), AG(LDAG,N), B(LDB,NRHS)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW, IROWB, I1, I2
      INTEGER           M1
C
      EXTERNAL          DGBTRF, DGBTRS
      INTRINSIC         MAX0, MIN0
C
C     Initialize the array AG to store the 4x4 matrix A with one
C     subdiagonal and one superdiagonal shown below.  Initialize
C     the array B to store the vector b shown below.
C
C           2  -1                5
C     AG = -1   2  -1        b = 5
C              -1   2  -1        5
C                  -1   2        5
C
      DATA AB / 16 * 8.0D8 /
      DATA AG / 2.0D0, -1.0D0, 2*0.0, -1.0D0, 2.0D0, -1.0D0,
     $          0.0D0, 0.0D0, -1.0D0, 2.0D0, -1.0D0, 2*0D0,
     $         -1.0D0, 2.0D0 /
      DATA B / N*5.0D0 /
C
C     Copy the matrix A from the array AG to the array AB.  The
C     matrix is stored in general storage mode in AG and it will
C     be stored in banded storage mode in AB.  The code to copy
C     from general to banded storage mode was written for LINPACK
C     by Cleve Moler.
C
      M1 = NSUB + NSUPER + 1
      DO 20, ICOL = 1, N
        I1 = MAX0 (1, ICOL - NSUPER)
        I2 = MIN0 (N, ICOL + NSUB)
        DO 10, IROW = I1, I2
          IROWB = IROW - ICOL + M1
          AB(IROWB,ICOL) = AG(IROW,ICOL)
   10   CONTINUE
   20 CONTINUE
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      PRINT 1010, ((AG(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
      PRINT 1020
      PRINT 1010, ((AB(IROW,ICOL), ICOL = 1, N), IROW = 1, LDAB)
      PRINT 1030
      PRINT 1040, B
C
C     Factor the matrix in banded form and print the results.
C
      CALL DGBTRF (M, N, NSUB, NSUPER, AB, LDAB, IPIVOT, INFO)
      IF (INFO .EQ. 0) THEN
        CALL DGBTRS ('NO TRANSPOSE A', N, NSUB, NSUPER, NRHS,
     $               AB, LDAB, IPIVOT, B, LDB, INFO)
        IF (INFO .EQ. 0) THEN
          PRINT 1050
          PRINT 1040, B
        ELSE
          PRINT 1060, INFO
        END IF
      ELSE
        PRINT 1070, INFO
      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, 'Error in solving system, INFO = ', I4)
 1070 FORMAT (1X, 'Error in factoring system, INFO = ', I4)
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






Previous Next Contents Generated Index Doc Set Home