Previous Next Contents Generated Index Doc Set Home



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

The subroutines described in this section solve the linear system Ax = b for a matrix A in banded storage, which has been LU-factored by xGBCO or xGBFA, and vectors b and x.

Calling Sequence

CALL DGBSL 
(DA, LDA, N, NSUB, NSUPER, IPIVOT, DB, JOB)
CALL SGBSL 
(SA, LDA, N, NSUB, NSUPER, IPIVOT, SB, JOB)
CALL ZGBSL 
(ZA, LDA, N, NSUB, NSUPER, IPIVOT, ZB, JOB)
CALL CGBSL 
(CA, LDA, N, NSUB, NSUPER, IPIVOT, CB, JOB)






void dgbsl 
(double *da, int lda, int n, int nsub, int nsuper, int 
*ipivot, double *db, int job)
void sgbsl 
(float *sa, int lda, int n, int nsub, int nsuper, int 
*ipivot, float *sb, int job)
void zgbsl 
(doublecomplex *za, int lda, int n, int nsub, int 
nsuper, int *ipivot, doublecomplex *zb, int job)
void cgbsl 
(complex *ca, int lda, int n, int nsub, int nsuper, int 
*ipivot, complex *cb, int job)

Arguments

xA

LU factorization of the matrix A, as computed by xGBCO or xGBFA.

LDA

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

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.

IPIVOT

Pivot vector as computed by xGBCO or xGBFA.

xB

On entry, the right-hand side vector b.
On exit, the solution vector x.

JOB

Determines which operation this subroutine will perform:

0

solve the system Ax = b

not 0

solve the linear system AHx = b

Note that ATx = AHx for real matrices.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER          IAXEQB, LDA, LDAB, N, NDIAG, NSUB, NSUPER
      PARAMETER        (IAXEQB = 0)
      PARAMETER        (N = 4)
      PARAMETER        (LDA = N)
      PARAMETER        (NSUB = 1)
      PARAMETER        (NSUPER = 1)
      PARAMETER        (NDIAG = NSUB + 1 + NSUPER)
      PARAMETER        (LDAB = 2 * NSUB + 1 + NSUPER)
C
      DOUBLE PRECISION AB(LDAB,N), AG(LDA,N), B(N), RCOND, WORK(N)
      INTEGER          ICOL, IPIVOT(N), IROW, IROWB, I1, I2, JOB
C
      EXTERNAL         DGBCO, DGBSL
      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*8D8 /
      DATA AG /  2.0D0, -1.0D0,  2*0D0, -1.0D0,  2.0D0, -1.0D0,
     $           2*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 is taken from the
C     comment block in the original DGBFA by Cleve Moler.
C
      DO 10, ICOL = 1, N
        I1 = MAX0 (1, ICOL - NSUPER)
        I2 = MIN0 (N, ICOL + NSUB)
        DO 10, IROW = I1, I2
          IROWB = IROW - ICOL + NDIAG
          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 = 2 * NSUB, 2 * NSUB + 1 + NSUPER)
      PRINT 1030
      PRINT 1040, B
C
C     Factor the matrix in banded form.
C
      CALL DGBCO (AB, LDA, N, NSUB, NSUPER, IPIVOT, RCOND, WORK)
      PRINT 1050, RCOND
      IF ((RCOND + 1.0D0) .EQ. 1.0D0) THEN
        PRINT 1070
      END IF
      JOB = IAXEQB
      CALL DGBSL (AB, LDA, N, NSUB, NSUPER, IPIVOT, B, JOB)
      PRINT 1060
      PRINT 1040, B
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 (3X, F4.1)
 1050 FORMAT (/1X, 'Reciprocal of the condition number: ', F5.2)
 1060 FORMAT (/1X, 'A**(-1) * b:')
 1070 FORMAT (1X, 'A may be 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



 Reciprocal of the condition number:  0.08



 A**(-1) * b:
   10.0
   15.0
   15.0
   10.0






Previous Next Contents Generated Index Doc Set Home