Previous Next Contents Generated Index Doc Set Home



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

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

Calling Sequence

CALL DTPTRS 
(UPLO, TRANSA, DIAG, N, NRHS, DA, DB, LDB, INFO)
CALL STPTRS 
(UPLO, TRANSA, DIAG, N, NRHS, SA, SB, LDB, INFO)
CALL ZTPTRS 
(UPLO, TRANSA, DIAG, N, NRHS, ZA, ZB, LDB, INFO)
CALL CTPTRS 
(UPLO, TRANSA, DIAG, N, NRHS, CA, CB, LDB, INFO)






void dtptrs 
(char uplo, char trans, char diag, int n, int nrhs, 
double *da, double *db, int ldb, int *info)
void stptrs 
(char uplo, char trans, char diag, int n, int nrhs, 
float *sa, float *sb, int ldb, int *info)
void ztptrs 
(char uplo, char trans, char diag, int n, int nrhs, 
doublecomplex *za, doublecomplex *zb, int ldb, int 
*info)
void ctptrs 
(char uplo, char trans, char diag, int n, int nrhs, 
complex *ca, 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 of 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.

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.
The dimension of xA is (N × N + N) / 2.

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
      DOUBLE PRECISION  ZERO
      INTEGER           LDA, LDB, N, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (LDA = ((N + 1) * N) / 2)
      PARAMETER        (LDB = N)
      PARAMETER        (NRHS = 1)
      PARAMETER        (ZERO = 0.0D0)
C
      DOUBLE PRECISION  A(LDA), B(LDB,NRHS)
      INTEGER           INFO
C
      EXTERNAL          DTPTRS
C
C     Initialize the array A to store in packed triangular
C     form the coefficient matrix A shown below.  Store A in
C     such a way as to take advantage of the fact that A is 
C     unit diagonal. Initialize the array B to store the right
C     hand side vector b shown below.
C
C         1                     4
C     A = 1   1             b = 3
C         1   1   1             2
C         1   1   1   1         1
C
      DATA A / 8D8, 1.0D0, 1.0D0, 1.0D0, 8D8, 1.0D0, 1.0D0,
     $         8D8, 1.0D0, 8D8 /
      DATA B / 4.0D0, 3.0D0, 2.0D0, 1.0D0 /
C
C     Print the A array.
C
      PRINT 1000
      PRINT 1010, A(1)
      PRINT 1010, A(2), A(5)
      PRINT 1010, A(3), A(6), A(8)
      PRINT 1010, A(4), A(7), A(9), A(10)
      PRINT 1020
      PRINT 1030, B
C
C     Solve Ax=b and print the result.
C
      CALL DTPTRS ('LOWER TRIANGULAR A', 'TRANSPOSE A',
     $             'UNIT DIAGONAL A', N, NRHS, A, B, LDB, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 1
      END IF
      PRINT 1050
      PRINT 1030, B
C
 1000 FORMAT (1X, 'Unit diagonal A:  ',
     $        '(* in entries assumed to be 1.0)')
 1010 FORMAT (4(3X, F8.4))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F8.4)
 1040 FORMAT (/1X, 'Error solving Ax=b, INFO = ', I5)
 1050 FORMAT (/1X, 'x:')
C
      END
 

Sample Output

 
 Unit diagonal A:  (* in entries assumed to be 1.0)
   ********
     1.0000   ********
     1.0000     1.0000   ********
     1.0000     1.0000     1.0000   ********



 b:
   4.0000
   3.0000
   2.0000
   1.0000



 x:
   1.0000
   1.0000
   1.0000
   1.0000






Previous Next Contents Generated Index Doc Set Home