Previous Next Contents Generated Index Doc Set Home



Solution to a Triangular System of Linear Equations in Packed Storage

The subroutines described in this section compute one of the following results for a triangular matrix A in packed storage and a vector y:



Calling Sequence

CALL DTPSV 
(UPLO, TRANSA, DIAG, N, DA, DY, INCY)
CALL STPSV 
(UPLO, TRANSA, DIAG, N, SA, SY, INCY)
CALL ZTPSV 
(UPLO, TRANSA, DIAG, N, ZA, ZY, INCY)
CALL CTPSV 
(UPLO, TRANSA, DIAG, N, CA, CY, INCY)






void dtpsv 
(char uplo, char trans, char diag, int n, double *da, 
double *dx, int incx)
void stpsv 
(char uplo, char trans, char diag, int n, float *sa, 
float *sx, int incx)
void ztpsv 
(char uplo, char trans, char diag, int n, doublecomplex 
*za, doublecomplex *zx, int incx)
void ctpsv 
(char uplo, char trans, char diag, int n, complex *ca, 
complex *cx, int incx)

Arguments

UPLO

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

'L' or 'l'

Only the lower triangle of the array will be referenced.

'U' or 'u'

Only the upper triangle of the array will be referenced.

TRANSA

Indicates how to use the matrix stored in the array argument. 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 the array.

'T' or 't'

Use the transpose of the matrix.

'C' or 'c'

Use the conjugate transpose of the matrix.

DIAG

Indicates whether or not a triangular matrix is unit triangular. If the matrix is unit triangular then none of the diagonal elements of the array will be accessed. The legal values for DIAG are listed below. Any value not listed below is illegal.

'N' or 'n'

The matrix is not unit triangular.

'U' or 'u'

The matrix is unit triangular.

N

Size of a matrix with N rows and N columns. N 0.

xA

One-dimensional array that contains the input matrix. The matrix is in packed storage; the array must have at least enough elements to store the non-redundant elements of the matrix.

xY

Y and INCY describe a vector of length N.

On entry, an input vector.

On exit, a result vector.

INCY

Scalar that contains the storage spacing between successive elements of the vector Y. INCY 0.

If INCY is one then elements of the vector are contiguous in memory. INCY may take on values besides 1 to allow the programmer to extract from a matrix a vector that is not stored in contiguous memory locations.

If Y is a one-dimensional array and INCY = -1 then the array will be accessed in reverse order.

If Y is a two-dimensional array and INCY = LDA then the vector will be a row of the array.

If Y is a two-dimensional array and INCY = LDA+1 then the vector will be a diagonal of the array.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      DOUBLE PRECISION  ONE
      INTEGER           LENGTA, N
      PARAMETER        (N = 4)
      PARAMETER        (LENGTA = (N * N + N) / 2)
      PARAMETER        (ONE = 1.0D0)
C
      DOUBLE PRECISION AP(LENGTA), B(N)
      INTEGER I
      EXTERNAL DTPSV
C
C     Initialize the array AP to store in packed triangular form
C     the unit diagonal triangular matrix A shown below. 
C     Initialize the array B to store the vector b shown below.
C
C         1.0                         8.0
C     A = 2.0  1.0              b =  25.0
C         3.0  5.0  1.0              79.0
C         4.0  6.0  7.0  1.0        167.0
C
      DATA AP / 8D8, 2.0D0, 3.0D0, 4.0D0, 8D8, 5.0D0,
     $          6.0D0, 8D8, 7.0D0, 1.0D0 /
      DATA B / 8.0D0, 2.5D1, 7.9D1, 1.67D2 /
C
      PRINT 1000
      PRINT 1010, ONE
      PRINT 1010, AP(2), ONE
      PRINT 1010, AP(3), AP(6), ONE
      PRINT 1010, AP(4), AP(7), AP(9), ONE
      PRINT 1020
      PRINT 1030, (AP(I), I = 1, LENGTA)
      PRINT 1040
      PRINT 1050, (B(I), I = 1, N)
      CALL DTPSV ('LOWER TRIANGULAR A', 'NOT TRANSPOSED A',
     $            'UNIT DIAGONAL A', N, AP, B, 1)
      PRINT 1060
      PRINT 1050, (B(I), I = 1, N)
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 4(2X, F5.1))
 1020 FORMAT (/1X, 'A in packed form:  (* in unused elements)')
 1030 FORMAT (1X, 9(2X, F5.1))
 1040 FORMAT (/1X, 'b:')
 1050 FORMAT (3X, F5.1)
 1060 FORMAT (/1X, 'A**(-1) * b:')
C
      END
 

Sample Output

 
 A in full form:
     1.0
     2.0    1.0
     3.0    5.0    1.0
     4.0    6.0    7.0    1.0



 A in packed form:  (* in unused elements)
   *****    2.0    3.0    4.0  *****    5.0    6.0  *****    7.0
    1.0



 b:
     8.0
    25.0
    79.0
   167.0



 A**(-1) * b:
     8.0
     9.0
    10.0
    11.0






Previous Next Contents Generated Index Doc Set Home