1 SUBROUTINE DTRMV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX )
2 ! .. Scalar Arguments ..
4 CHARACTER*1 DIAG, TRANS, UPLO
5 ! .. Array Arguments ..
6 DOUBLE PRECISION A( LDA, * ), X( * )
12 ! DTRMV performs one of the matrix-vector operations
14 ! x := A*x, or x := A'*x,
16 ! where x is an n element vector and A is an n by n unit, or non-unit,
17 ! upper or lower triangular matrix.
23 ! On entry, UPLO specifies whether the matrix is an upper or
24 ! lower triangular matrix as follows:
26 ! UPLO = 'U' or 'u' A is an upper triangular matrix.
28 ! UPLO = 'L' or 'l' A is a lower triangular matrix.
32 ! TRANS - CHARACTER*1.
33 ! On entry, TRANS specifies the operation to be performed as
36 ! TRANS = 'N' or 'n' x := A*x.
38 ! TRANS = 'T' or 't' x := A'*x.
40 ! TRANS = 'C' or 'c' x := A'*x.
45 ! On entry, DIAG specifies whether or not A is unit
46 ! triangular as follows:
48 ! DIAG = 'U' or 'u' A is assumed to be unit triangular.
50 ! DIAG = 'N' or 'n' A is not assumed to be unit
56 ! On entry, N specifies the order of the matrix A.
57 ! N must be at least zero.
60 ! A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
61 ! Before entry with UPLO = 'U' or 'u', the leading n by n
62 ! upper triangular part of the array A must contain the upper
63 ! triangular matrix and the strictly lower triangular part of
64 ! A is not referenced.
65 ! Before entry with UPLO = 'L' or 'l', the leading n by n
66 ! lower triangular part of the array A must contain the lower
67 ! triangular matrix and the strictly upper triangular part of
68 ! A is not referenced.
69 ! Note that when DIAG = 'U' or 'u', the diagonal elements of
70 ! A are not referenced either, but are assumed to be unity.
74 ! On entry, LDA specifies the first dimension of A as declared
75 ! in the calling (sub) program. LDA must be at least
79 ! X - DOUBLE PRECISION array of dimension at least
80 ! ( 1 + ( n - 1 )*abs( INCX ) ).
81 ! Before entry, the incremented array X must contain the n
82 ! element vector x. On exit, X is overwritten with the
83 ! tranformed vector x.
86 ! On entry, INCX specifies the increment for the elements of
87 ! X. INCX must not be zero.
91 ! Level 2 Blas routine.
93 ! -- Written on 22-October-1986.
94 ! Jack Dongarra, Argonne National Lab.
95 ! Jeremy Du Croz, Nag Central Office.
96 ! Sven Hammarling, Nag Central Office.
97 ! Richard Hanson, Sandia National Labs.
101 DOUBLE PRECISION ZERO
102 PARAMETER ( ZERO = 0.0D+0 )
103 ! .. Local Scalars ..
104 DOUBLE PRECISION TEMP
105 INTEGER I, INFO, IX, J, JX, KX
107 ! .. External Functions ..
110 ! .. External Subroutines ..
112 ! .. Intrinsic Functions ..
115 ! .. Executable Statements ..
117 ! Test the input parameters.
120 IF ( .NOT.LSAME( UPLO , 'U' ).AND. &
121 .NOT.LSAME( UPLO , 'L' ) )THEN
123 ELSE IF( .NOT.LSAME( TRANS, 'N' ).AND. &
124 .NOT.LSAME( TRANS, 'T' ).AND. &
125 .NOT.LSAME( TRANS, 'C' ) )THEN
127 ELSE IF( .NOT.LSAME( DIAG , 'U' ).AND. &
128 .NOT.LSAME( DIAG , 'N' ) )THEN
130 ELSE IF( N.LT.0 )THEN
132 ELSE IF( LDA.LT.MAX( 1, N ) )THEN
134 ELSE IF( INCX.EQ.0 )THEN
138 CALL XERBLA( 'DTRMV ', INFO )
142 ! Quick return if possible.
147 NOUNIT = LSAME( DIAG, 'N' )
149 ! Set up the start point in X if the increment is not unity. This
150 ! will be ( N - 1 )*INCX too small for descending loops.
153 KX = 1 - ( N - 1 )*INCX
154 ELSE IF( INCX.NE.1 )THEN
158 ! Start the operations. In this version the elements of A are
159 ! accessed sequentially with one pass through A.
161 IF( LSAME( TRANS, 'N' ) )THEN
165 IF( LSAME( UPLO, 'U' ) )THEN
168 IF( X( J ).NE.ZERO )THEN
171 X( I ) = X( I ) + TEMP*A( I, J )
174 X( J ) = X( J )*A( J, J )
180 IF( X( JX ).NE.ZERO )THEN
184 X( IX ) = X( IX ) + TEMP*A( I, J )
188 X( JX ) = X( JX )*A( J, J )
196 IF( X( J ).NE.ZERO )THEN
198 DO 50, I = N, J + 1, -1
199 X( I ) = X( I ) + TEMP*A( I, J )
202 X( J ) = X( J )*A( J, J )
206 KX = KX + ( N - 1 )*INCX
209 IF( X( JX ).NE.ZERO )THEN
212 DO 70, I = N, J + 1, -1
213 X( IX ) = X( IX ) + TEMP*A( I, J )
217 X( JX ) = X( JX )*A( J, J )
227 IF( LSAME( UPLO, 'U' ) )THEN
232 TEMP = TEMP*A( J, J )
233 DO 90, I = J - 1, 1, -1
234 TEMP = TEMP + A( I, J )*X( I )
239 JX = KX + ( N - 1 )*INCX
244 TEMP = TEMP*A( J, J )
245 DO 110, I = J - 1, 1, -1
247 TEMP = TEMP + A( I, J )*X( IX )
258 TEMP = TEMP*A( J, J )
260 TEMP = TEMP + A( I, J )*X( I )
270 TEMP = TEMP*A( J, J )
273 TEMP = TEMP + A( I, J )*X( IX )