Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Triangular Matrix in Banded Storage

The subroutines described in this section solve a linear system AX = B, ATX = B, or AHX = B for a triangular matrix A in banded storage and general matrices B and X.

Calling Sequence

CALL DTBTRS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, DA, LDA, DB, LDB, 
INFO)
CALL STBTRS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, SA, LDA, SB, LDB, 
INFO)
CALL ZTBTRS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, ZA, LDA, ZB, LDB, 
INFO)
CALL CTBTRS 
(UPLO, TRANSA, DIAG, N, NDIAG, NRHS, CA, LDA, CB, LDB, 
INFO)






void dtbtrs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, double *da, int lda, double *db, int ldb, int 
*info)
void stbtrs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, float *sa, int lda, float *sb, int ldb, int 
*info)
void ztbtrs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, doublecomplex *za, int lda, doublecomplex 
*zb, int ldb, int *info)
void ctbtrs 
(char uplo, char trans, char diag, int n, int ndiag, 
int nrhs, complex *ca, int lda, complex *cb, int ldb, 
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 the system of equations. 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.

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 matrix B. 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

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.

INFO > 0

The ith diagonal element, where i = INFO, of A is zero. The matrix is therefore singular and the solution could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDB, N, NRHS, NSUB
      PARAMETER        (NSUB = 1)
      PARAMETER        (N = 4)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = NSUB + 1)
      PARAMETER        (LDB = N)
C
      DOUBLE PRECISION  A(LDA,N), B(LDB,NRHS)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DTBTRS
      INTRINSIC         MAX
C
C     Initialize the array A to store in banded triangular form
C     the 4x4 coefficient matrix A with one subdiagonal as shown
C     below.  Initialize the array B to store the right hand side
C     vector b shown below.
C
C          2                    8
C     A = -1   2            b = 8
C             -1   2            6
C                 -1   2        4
C
      DATA A / 2.0D0, -1.0D0, 2.0D0, -1.0D0, 2.0D0, -1.0D0, 2.0D0,
     $         8D8 /
      DATA B / 8.0D0, 8.0D0, 6.0D0, 4.0D0 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - NSUB - 1),
     $              (A(1 + IROW - ICOL, ICOL),
     $               ICOL = MAX(1,IROW - NSUB), IROW),
     $              (0.0D0, ICOL = IROW + 1, N)
  100 CONTINUE
      PRINT 1020
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, LDA)
      PRINT 1030
      PRINT 1040, B
C
C     Solve the system and print the results.
C
      CALL DTBTRS ('LOWER TRIANGULAR A', 'NO TRANSPOSE A',
     $             'NOT UNIT DIAGONAL A', N, NSUB, NRHS, A, LDA,
     $             B, LDB, INFO)
      IF (INFO .EQ. 0) THEN
        PRINT 1050
        PRINT 1040, B
      ELSE
        PRINT 1060, 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 (3X, F4.1)
 1050 FORMAT (/1X, 'x:')
 1060 FORMAT (1X, 'Error in solving system, INFO = ', I4)
C
      END
 

Sample Output

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



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



 b:
    8.0
    8.0
    6.0
    4.0



 x:
    4.0
    6.0
    6.0
    5.0






Previous Next Contents Generated Index Doc Set Home