1 SUBROUTINE DTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX) 2* .. Scalar Arguments .. 3 INTEGER INCX,N 4 CHARACTER DIAG,TRANS,UPLO 5* .. 6* .. Array Arguments .. 7 DOUBLE PRECISION AP(*),X(*) 8* .. 9* 10* Purpose 11* ======= 12* 13* DTPMV performs one of the matrix-vector operations 14* 15* x := A*x, or x := A'*x, 16* 17* where x is an n element vector and A is an n by n unit, or non-unit, 18* upper or lower triangular matrix, supplied in packed form. 19* 20* Arguments 21* ========== 22* 23* UPLO - CHARACTER*1. 24* On entry, UPLO specifies whether the matrix is an upper or 25* lower triangular matrix as follows: 26* 27* UPLO = 'U' or 'u' A is an upper triangular matrix. 28* 29* UPLO = 'L' or 'l' A is a lower triangular matrix. 30* 31* Unchanged on exit. 32* 33* TRANS - CHARACTER*1. 34* On entry, TRANS specifies the operation to be performed as 35* follows: 36* 37* TRANS = 'N' or 'n' x := A*x. 38* 39* TRANS = 'T' or 't' x := A'*x. 40* 41* TRANS = 'C' or 'c' x := A'*x. 42* 43* Unchanged on exit. 44* 45* DIAG - CHARACTER*1. 46* On entry, DIAG specifies whether or not A is unit 47* triangular as follows: 48* 49* DIAG = 'U' or 'u' A is assumed to be unit triangular. 50* 51* DIAG = 'N' or 'n' A is not assumed to be unit 52* triangular. 53* 54* Unchanged on exit. 55* 56* N - INTEGER. 57* On entry, N specifies the order of the matrix A. 58* N must be at least zero. 59* Unchanged on exit. 60* 61* AP - DOUBLE PRECISION array of DIMENSION at least 62* ( ( n*( n + 1 ) )/2 ). 63* Before entry with UPLO = 'U' or 'u', the array AP must 64* contain the upper triangular matrix packed sequentially, 65* column by column, so that AP( 1 ) contains a( 1, 1 ), 66* AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 ) 67* respectively, and so on. 68* Before entry with UPLO = 'L' or 'l', the array AP must 69* contain the lower triangular matrix packed sequentially, 70* column by column, so that AP( 1 ) contains a( 1, 1 ), 71* AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 ) 72* respectively, and so on. 73* Note that when DIAG = 'U' or 'u', the diagonal elements of 74* A are not referenced, but are assumed to be unity. 75* Unchanged on exit. 76* 77* X - DOUBLE PRECISION array of dimension at least 78* ( 1 + ( n - 1 )*abs( INCX ) ). 79* Before entry, the incremented array X must contain the n 80* element vector x. On exit, X is overwritten with the 81* tranformed vector x. 82* 83* INCX - INTEGER. 84* On entry, INCX specifies the increment for the elements of 85* X. INCX must not be zero. 86* Unchanged on exit. 87* 88* Further Details 89* =============== 90* 91* Level 2 Blas routine. 92* 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. 98* 99* ===================================================================== 100* 101* .. Parameters .. 102 DOUBLE PRECISION ZERO 103 PARAMETER (ZERO=0.0D+0) 104* .. 105* .. Local Scalars .. 106 DOUBLE PRECISION TEMP 107 INTEGER I,INFO,IX,J,JX,K,KK,KX 108 LOGICAL NOUNIT 109* .. 110* .. External Functions .. 111 LOGICAL LSAME 112 EXTERNAL LSAME 113* .. 114* .. External Subroutines .. 115 EXTERNAL XERBLA 116* .. 117* 118* Test the input parameters. 119* 120 INFO = 0 121 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 122 INFO = 1 123 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. 124 + .NOT.LSAME(TRANS,'C')) THEN 125 INFO = 2 126 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN 127 INFO = 3 128 ELSE IF (N.LT.0) THEN 129 INFO = 4 130 ELSE IF (INCX.EQ.0) THEN 131 INFO = 7 132 END IF 133 IF (INFO.NE.0) THEN 134 CALL XERBLA('DTPMV ',INFO) 135 RETURN 136 END IF 137* 138* Quick return if possible. 139* 140 IF (N.EQ.0) RETURN 141* 142 NOUNIT = LSAME(DIAG,'N') 143* 144* Set up the start point in X if the increment is not unity. This 145* will be ( N - 1 )*INCX too small for descending loops. 146* 147 IF (INCX.LE.0) THEN 148 KX = 1 - (N-1)*INCX 149 ELSE IF (INCX.NE.1) THEN 150 KX = 1 151 END IF 152* 153* Start the operations. In this version the elements of AP are 154* accessed sequentially with one pass through AP. 155* 156 IF (LSAME(TRANS,'N')) THEN 157* 158* Form x:= A*x. 159* 160 IF (LSAME(UPLO,'U')) THEN 161 KK = 1 162 IF (INCX.EQ.1) THEN 163 DO 20 J = 1,N 164 IF (X(J).NE.ZERO) THEN 165 TEMP = X(J) 166 K = KK 167 DO 10 I = 1,J - 1 168 X(I) = X(I) + TEMP*AP(K) 169 K = K + 1 170 10 CONTINUE 171 IF (NOUNIT) X(J) = X(J)*AP(KK+J-1) 172 END IF 173 KK = KK + J 174 20 CONTINUE 175 ELSE 176 JX = KX 177 DO 40 J = 1,N 178 IF (X(JX).NE.ZERO) THEN 179 TEMP = X(JX) 180 IX = KX 181 DO 30 K = KK,KK + J - 2 182 X(IX) = X(IX) + TEMP*AP(K) 183 IX = IX + INCX 184 30 CONTINUE 185 IF (NOUNIT) X(JX) = X(JX)*AP(KK+J-1) 186 END IF 187 JX = JX + INCX 188 KK = KK + J 189 40 CONTINUE 190 END IF 191 ELSE 192 KK = (N* (N+1))/2 193 IF (INCX.EQ.1) THEN 194 DO 60 J = N,1,-1 195 IF (X(J).NE.ZERO) THEN 196 TEMP = X(J) 197 K = KK 198 DO 50 I = N,J + 1,-1 199 X(I) = X(I) + TEMP*AP(K) 200 K = K - 1 201 50 CONTINUE 202 IF (NOUNIT) X(J) = X(J)*AP(KK-N+J) 203 END IF 204 KK = KK - (N-J+1) 205 60 CONTINUE 206 ELSE 207 KX = KX + (N-1)*INCX 208 JX = KX 209 DO 80 J = N,1,-1 210 IF (X(JX).NE.ZERO) THEN 211 TEMP = X(JX) 212 IX = KX 213 DO 70 K = KK,KK - (N- (J+1)),-1 214 X(IX) = X(IX) + TEMP*AP(K) 215 IX = IX - INCX 216 70 CONTINUE 217 IF (NOUNIT) X(JX) = X(JX)*AP(KK-N+J) 218 END IF 219 JX = JX - INCX 220 KK = KK - (N-J+1) 221 80 CONTINUE 222 END IF 223 END IF 224 ELSE 225* 226* Form x := A'*x. 227* 228 IF (LSAME(UPLO,'U')) THEN 229 KK = (N* (N+1))/2 230 IF (INCX.EQ.1) THEN 231 DO 100 J = N,1,-1 232 TEMP = X(J) 233 IF (NOUNIT) TEMP = TEMP*AP(KK) 234 K = KK - 1 235 DO 90 I = J - 1,1,-1 236 TEMP = TEMP + AP(K)*X(I) 237 K = K - 1 238 90 CONTINUE 239 X(J) = TEMP 240 KK = KK - J 241 100 CONTINUE 242 ELSE 243 JX = KX + (N-1)*INCX 244 DO 120 J = N,1,-1 245 TEMP = X(JX) 246 IX = JX 247 IF (NOUNIT) TEMP = TEMP*AP(KK) 248 DO 110 K = KK - 1,KK - J + 1,-1 249 IX = IX - INCX 250 TEMP = TEMP + AP(K)*X(IX) 251 110 CONTINUE 252 X(JX) = TEMP 253 JX = JX - INCX 254 KK = KK - J 255 120 CONTINUE 256 END IF 257 ELSE 258 KK = 1 259 IF (INCX.EQ.1) THEN 260 DO 140 J = 1,N 261 TEMP = X(J) 262 IF (NOUNIT) TEMP = TEMP*AP(KK) 263 K = KK + 1 264 DO 130 I = J + 1,N 265 TEMP = TEMP + AP(K)*X(I) 266 K = K + 1 267 130 CONTINUE 268 X(J) = TEMP 269 KK = KK + (N-J+1) 270 140 CONTINUE 271 ELSE 272 JX = KX 273 DO 160 J = 1,N 274 TEMP = X(JX) 275 IX = JX 276 IF (NOUNIT) TEMP = TEMP*AP(KK) 277 DO 150 K = KK + 1,KK + N - J 278 IX = IX + INCX 279 TEMP = TEMP + AP(K)*X(IX) 280 150 CONTINUE 281 X(JX) = TEMP 282 JX = JX + INCX 283 KK = KK + (N-J+1) 284 160 CONTINUE 285 END IF 286 END IF 287 END IF 288* 289 RETURN 290* 291* End of DTPMV . 292* 293 END 294