LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE DTPMV(UPLO,TRANS,DIAG,N,AP,X,INCX) 00002 * .. Scalar Arguments .. 00003 INTEGER INCX,N 00004 CHARACTER DIAG,TRANS,UPLO 00005 * .. 00006 * .. Array Arguments .. 00007 DOUBLE PRECISION AP(*),X(*) 00008 * .. 00009 * 00010 * Purpose 00011 * ======= 00012 * 00013 * DTPMV performs one of the matrix-vector operations 00014 * 00015 * x := A*x, or x := A**T*x, 00016 * 00017 * where x is an n element vector and A is an n by n unit, or non-unit, 00018 * upper or lower triangular matrix, supplied in packed form. 00019 * 00020 * Arguments 00021 * ========== 00022 * 00023 * UPLO - CHARACTER*1. 00024 * On entry, UPLO specifies whether the matrix is an upper or 00025 * lower triangular matrix as follows: 00026 * 00027 * UPLO = 'U' or 'u' A is an upper triangular matrix. 00028 * 00029 * UPLO = 'L' or 'l' A is a lower triangular matrix. 00030 * 00031 * Unchanged on exit. 00032 * 00033 * TRANS - CHARACTER*1. 00034 * On entry, TRANS specifies the operation to be performed as 00035 * follows: 00036 * 00037 * TRANS = 'N' or 'n' x := A*x. 00038 * 00039 * TRANS = 'T' or 't' x := A**T*x. 00040 * 00041 * TRANS = 'C' or 'c' x := A**T*x. 00042 * 00043 * Unchanged on exit. 00044 * 00045 * DIAG - CHARACTER*1. 00046 * On entry, DIAG specifies whether or not A is unit 00047 * triangular as follows: 00048 * 00049 * DIAG = 'U' or 'u' A is assumed to be unit triangular. 00050 * 00051 * DIAG = 'N' or 'n' A is not assumed to be unit 00052 * triangular. 00053 * 00054 * Unchanged on exit. 00055 * 00056 * N - INTEGER. 00057 * On entry, N specifies the order of the matrix A. 00058 * N must be at least zero. 00059 * Unchanged on exit. 00060 * 00061 * AP - DOUBLE PRECISION array of DIMENSION at least 00062 * ( ( n*( n + 1 ) )/2 ). 00063 * Before entry with UPLO = 'U' or 'u', the array AP must 00064 * contain the upper triangular matrix packed sequentially, 00065 * column by column, so that AP( 1 ) contains a( 1, 1 ), 00066 * AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 ) 00067 * respectively, and so on. 00068 * Before entry with UPLO = 'L' or 'l', the array AP must 00069 * contain the lower triangular matrix packed sequentially, 00070 * column by column, so that AP( 1 ) contains a( 1, 1 ), 00071 * AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 ) 00072 * respectively, and so on. 00073 * Note that when DIAG = 'U' or 'u', the diagonal elements of 00074 * A are not referenced, but are assumed to be unity. 00075 * Unchanged on exit. 00076 * 00077 * X - DOUBLE PRECISION array of dimension at least 00078 * ( 1 + ( n - 1 )*abs( INCX ) ). 00079 * Before entry, the incremented array X must contain the n 00080 * element vector x. On exit, X is overwritten with the 00081 * tranformed vector x. 00082 * 00083 * INCX - INTEGER. 00084 * On entry, INCX specifies the increment for the elements of 00085 * X. INCX must not be zero. 00086 * Unchanged on exit. 00087 * 00088 * Further Details 00089 * =============== 00090 * 00091 * Level 2 Blas routine. 00092 * The vector and matrix arguments are not referenced when N = 0, or M = 0 00093 * 00094 * -- Written on 22-October-1986. 00095 * Jack Dongarra, Argonne National Lab. 00096 * Jeremy Du Croz, Nag Central Office. 00097 * Sven Hammarling, Nag Central Office. 00098 * Richard Hanson, Sandia National Labs. 00099 * 00100 * ===================================================================== 00101 * 00102 * .. Parameters .. 00103 DOUBLE PRECISION ZERO 00104 PARAMETER (ZERO=0.0D+0) 00105 * .. 00106 * .. Local Scalars .. 00107 DOUBLE PRECISION TEMP 00108 INTEGER I,INFO,IX,J,JX,K,KK,KX 00109 LOGICAL NOUNIT 00110 * .. 00111 * .. External Functions .. 00112 LOGICAL LSAME 00113 EXTERNAL LSAME 00114 * .. 00115 * .. External Subroutines .. 00116 EXTERNAL XERBLA 00117 * .. 00118 * 00119 * Test the input parameters. 00120 * 00121 INFO = 0 00122 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00123 INFO = 1 00124 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. 00125 + .NOT.LSAME(TRANS,'C')) THEN 00126 INFO = 2 00127 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN 00128 INFO = 3 00129 ELSE IF (N.LT.0) THEN 00130 INFO = 4 00131 ELSE IF (INCX.EQ.0) THEN 00132 INFO = 7 00133 END IF 00134 IF (INFO.NE.0) THEN 00135 CALL XERBLA('DTPMV ',INFO) 00136 RETURN 00137 END IF 00138 * 00139 * Quick return if possible. 00140 * 00141 IF (N.EQ.0) RETURN 00142 * 00143 NOUNIT = LSAME(DIAG,'N') 00144 * 00145 * Set up the start point in X if the increment is not unity. This 00146 * will be ( N - 1 )*INCX too small for descending loops. 00147 * 00148 IF (INCX.LE.0) THEN 00149 KX = 1 - (N-1)*INCX 00150 ELSE IF (INCX.NE.1) THEN 00151 KX = 1 00152 END IF 00153 * 00154 * Start the operations. In this version the elements of AP are 00155 * accessed sequentially with one pass through AP. 00156 * 00157 IF (LSAME(TRANS,'N')) THEN 00158 * 00159 * Form x:= A*x. 00160 * 00161 IF (LSAME(UPLO,'U')) THEN 00162 KK = 1 00163 IF (INCX.EQ.1) THEN 00164 DO 20 J = 1,N 00165 IF (X(J).NE.ZERO) THEN 00166 TEMP = X(J) 00167 K = KK 00168 DO 10 I = 1,J - 1 00169 X(I) = X(I) + TEMP*AP(K) 00170 K = K + 1 00171 10 CONTINUE 00172 IF (NOUNIT) X(J) = X(J)*AP(KK+J-1) 00173 END IF 00174 KK = KK + J 00175 20 CONTINUE 00176 ELSE 00177 JX = KX 00178 DO 40 J = 1,N 00179 IF (X(JX).NE.ZERO) THEN 00180 TEMP = X(JX) 00181 IX = KX 00182 DO 30 K = KK,KK + J - 2 00183 X(IX) = X(IX) + TEMP*AP(K) 00184 IX = IX + INCX 00185 30 CONTINUE 00186 IF (NOUNIT) X(JX) = X(JX)*AP(KK+J-1) 00187 END IF 00188 JX = JX + INCX 00189 KK = KK + J 00190 40 CONTINUE 00191 END IF 00192 ELSE 00193 KK = (N* (N+1))/2 00194 IF (INCX.EQ.1) THEN 00195 DO 60 J = N,1,-1 00196 IF (X(J).NE.ZERO) THEN 00197 TEMP = X(J) 00198 K = KK 00199 DO 50 I = N,J + 1,-1 00200 X(I) = X(I) + TEMP*AP(K) 00201 K = K - 1 00202 50 CONTINUE 00203 IF (NOUNIT) X(J) = X(J)*AP(KK-N+J) 00204 END IF 00205 KK = KK - (N-J+1) 00206 60 CONTINUE 00207 ELSE 00208 KX = KX + (N-1)*INCX 00209 JX = KX 00210 DO 80 J = N,1,-1 00211 IF (X(JX).NE.ZERO) THEN 00212 TEMP = X(JX) 00213 IX = KX 00214 DO 70 K = KK,KK - (N- (J+1)),-1 00215 X(IX) = X(IX) + TEMP*AP(K) 00216 IX = IX - INCX 00217 70 CONTINUE 00218 IF (NOUNIT) X(JX) = X(JX)*AP(KK-N+J) 00219 END IF 00220 JX = JX - INCX 00221 KK = KK - (N-J+1) 00222 80 CONTINUE 00223 END IF 00224 END IF 00225 ELSE 00226 * 00227 * Form x := A**T*x. 00228 * 00229 IF (LSAME(UPLO,'U')) THEN 00230 KK = (N* (N+1))/2 00231 IF (INCX.EQ.1) THEN 00232 DO 100 J = N,1,-1 00233 TEMP = X(J) 00234 IF (NOUNIT) TEMP = TEMP*AP(KK) 00235 K = KK - 1 00236 DO 90 I = J - 1,1,-1 00237 TEMP = TEMP + AP(K)*X(I) 00238 K = K - 1 00239 90 CONTINUE 00240 X(J) = TEMP 00241 KK = KK - J 00242 100 CONTINUE 00243 ELSE 00244 JX = KX + (N-1)*INCX 00245 DO 120 J = N,1,-1 00246 TEMP = X(JX) 00247 IX = JX 00248 IF (NOUNIT) TEMP = TEMP*AP(KK) 00249 DO 110 K = KK - 1,KK - J + 1,-1 00250 IX = IX - INCX 00251 TEMP = TEMP + AP(K)*X(IX) 00252 110 CONTINUE 00253 X(JX) = TEMP 00254 JX = JX - INCX 00255 KK = KK - J 00256 120 CONTINUE 00257 END IF 00258 ELSE 00259 KK = 1 00260 IF (INCX.EQ.1) THEN 00261 DO 140 J = 1,N 00262 TEMP = X(J) 00263 IF (NOUNIT) TEMP = TEMP*AP(KK) 00264 K = KK + 1 00265 DO 130 I = J + 1,N 00266 TEMP = TEMP + AP(K)*X(I) 00267 K = K + 1 00268 130 CONTINUE 00269 X(J) = TEMP 00270 KK = KK + (N-J+1) 00271 140 CONTINUE 00272 ELSE 00273 JX = KX 00274 DO 160 J = 1,N 00275 TEMP = X(JX) 00276 IX = JX 00277 IF (NOUNIT) TEMP = TEMP*AP(KK) 00278 DO 150 K = KK + 1,KK + N - J 00279 IX = IX + INCX 00280 TEMP = TEMP + AP(K)*X(IX) 00281 150 CONTINUE 00282 X(JX) = TEMP 00283 JX = JX + INCX 00284 KK = KK + (N-J+1) 00285 160 CONTINUE 00286 END IF 00287 END IF 00288 END IF 00289 * 00290 RETURN 00291 * 00292 * End of DTPMV . 00293 * 00294 END