Previous Next Contents Generated Index Doc Set Home



Solution for a Triangular System of Equations

This subroutines described in this section compute the following functions of the triangular matrix A and the general matrix B:

Operation
TRANSA
SIDE
Matrix A

'N' or 'n'

'L' or 'l'

m x m

'T' or 't'

'L' or 'l'

m x m

'C' or 'c'

'L' or 'l'

m x m

'N' or 'n'

'R' or 'r'

n x n

'T' or 't'

'R' or 'r'

n x n

'C' or 'c'

'R' or 'r'

n x n

Calling Sequence

CALL DTRSM 
(SIDE, UPLO, TRANSA, DIAG, M, N, DALPHA, DA, LDA, DB, 
LDB)
CALL STRSM 
(SIDE, UPLO, TRANSA, DIAG, M, N, SALPHA, SA, LDA, SB, 
LDB)
CALL ZTRSM 
(SIDE, UPLO, TRANSA, DIAG, M, N, ZALPHA, ZA, LDA, ZB, 
LDB)
CALL CTRSM 
(SIDE, UPLO, TRANSA, DIAG, M, N, CALPHA, CA, LDA, CB, 
LDB)






void dtrsm 
(char side, char uplo, char transa, char diag, int m, 
int n, double dalpha, double *da, int lda, double *db, 
int ldb)
void strsm 
(char side, char uplo, char transa, char diag, int m, 
int n, float salpha, float *sa, int lda, float *sb, int 
ldb)
void ztrsm 
(char side, char uplo, char transa, char diag, int m, 
int n, doublecomplex *zalpha, doublecomplex *za, int 
lda, doublecomplex *zb, int ldb)
void ctrsm 
(char side, char uplo, char transa, char diag, int m, 
int n, complex *calpha, complex *ca, int lda, complex 
*cb, int ldb)

Arguments

SIDE

Indicates how to multiply matrices:

'L' or 'l'

Multiply general matrix by triangular matrix on the left.

'R' or 'r'

Multiply general matrix by triangular matrix on the right.

UPLO

Indicates whether the values in a matrix reside in the upper or lower triangle of the array in which it is stored. The legal values for UPLO are listed below. Any value not listed below is illegal.

'L' or 'l'

Only lower triangle of array will be referenced.

'U' or 'u'

Only upper triangle of array will be referenced.

TRANSA

Indicates how to use the matrix stored in A. The legal values for TRANSA are listed below. Any value not listed below is illegal.

'N' or 'n'

Use the matrix as it is stored in A.

'T' or 't'

Use the transpose of the matrix stored in A.

'C' or 'c'

Use the conjugate transpose of the matrix stored in A.

DIAG

Indicates whether the matrix is unit triangular:

'U' or 'u'

Unit triangular

'N' or 'n'

Not unit triangular

M, N

Indicate the size of matrix A as shown in the table above.

xALPHA

Scalar that scales the input value of the matrix stored in A.

xA

Two-dimensional array in which one of the input matrices is stored.

LDA

Leading dimension of the array A as specified in the dimension or type statement. LDA max(1,N).

If SIDE = 'L' or 'l', LDA max(1,M).

xB

Two-dimensional array.

On entry, one of the input matrices.

On exit, the result matrix.

LDB

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

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDB, M, N
      PARAMETER        (M = 3)
      PARAMETER        (LDA = M)
      PARAMETER        (LDB = M)
      PARAMETER        (N = 2)
C
      DOUBLE PRECISION  A(LDA,M), ALPHA, B(LDB,N)
      INTEGER           I, J
C
      EXTERNAL          DTRSM
      INTRINSIC         DBLE
C
C     Initialize the array A to store in triangular form the
C     matrix A shown below.  Initialize the array B to store
C     the matrix B shown below.
C
C          1  2  4        1  2
C     A =     3  5   B =  1  4
C                6        1  6
C
      DATA A / 1.0D0, 8D8, 8D8, 2.0D0, 3.0D0, 8D8, 4.0D0, 5.0D0, 
     $         6.0D0 /
      DATA B / 7.0D0, 8.0D0, 6.0D0, 3.4D1, 4.2D1, 3.6D1 /
C
      PRINT 1000
      PRINT 1010, A(1,1), A(1,2), A(1,3)
      PRINT 1020, A(2,2), A(2,3)
      PRINT 1030, A(3,3)
      PRINT 1040
      PRINT 1050, ((B(I,J), J = 1, N), I = 1, M)
      ALPHA = 1.0D0
      CALL DTRSM ('LEFT SIDE A', 'UPPER TRIANGULAR A',
     $            'NOT TRANSPOSED A', 'NOT UNIT DIAGONAL A', M, N,
     $            ALPHA, A, LDA, B, LDB)
      PRINT 1060
      PRINT 1050, ((B(I,J), J = 1, N), I = 1, M)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (1X, 3(2X, F5.1))
 1020 FORMAT (1X, 7X, 2(2X, F5.1))
 1030 FORMAT (1X, 14X, 2X, F5.1)
 1040 FORMAT (/1X, 'B:')
 1050 FORMAT (2(2X, F5.1))
 1060 FORMAT (/1X, 'A**(-1) * B:')
C
      END
 

Sample Output

 
 A:
     1.0    2.0    4.0
            3.0    5.0
                   6.0



 B:
    7.0   34.0
    8.0   42.0
    6.0   36.0



 A**(-1) * B:
    1.0    2.0
    1.0    4.0
    1.0    6.0






Previous Next Contents Generated Index Doc Set Home