LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE ZTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX) 00002 * .. Scalar Arguments .. 00003 INTEGER INCX,LDA,N 00004 CHARACTER DIAG,TRANS,UPLO 00005 * .. 00006 * .. Array Arguments .. 00007 DOUBLE COMPLEX A(LDA,*),X(*) 00008 * .. 00009 * 00010 * Purpose 00011 * ======= 00012 * 00013 * ZTRMV performs one of the matrix-vector operations 00014 * 00015 * x := A*x, or x := A**T*x, or x := A**H*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. 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**H*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 * A - COMPLEX*16 array of DIMENSION ( LDA, n ). 00062 * Before entry with UPLO = 'U' or 'u', the leading n by n 00063 * upper triangular part of the array A must contain the upper 00064 * triangular matrix and the strictly lower triangular part of 00065 * A is not referenced. 00066 * Before entry with UPLO = 'L' or 'l', the leading n by n 00067 * lower triangular part of the array A must contain the lower 00068 * triangular matrix and the strictly upper triangular part of 00069 * A is not referenced. 00070 * Note that when DIAG = 'U' or 'u', the diagonal elements of 00071 * A are not referenced either, but are assumed to be unity. 00072 * Unchanged on exit. 00073 * 00074 * LDA - INTEGER. 00075 * On entry, LDA specifies the first dimension of A as declared 00076 * in the calling (sub) program. LDA must be at least 00077 * max( 1, n ). 00078 * Unchanged on exit. 00079 * 00080 * X - COMPLEX*16 array of dimension at least 00081 * ( 1 + ( n - 1 )*abs( INCX ) ). 00082 * Before entry, the incremented array X must contain the n 00083 * element vector x. On exit, X is overwritten with the 00084 * tranformed vector x. 00085 * 00086 * INCX - INTEGER. 00087 * On entry, INCX specifies the increment for the elements of 00088 * X. INCX must not be zero. 00089 * Unchanged on exit. 00090 * 00091 * Further Details 00092 * =============== 00093 * 00094 * Level 2 Blas routine. 00095 * The vector and matrix arguments are not referenced when N = 0, or M = 0 00096 * 00097 * -- Written on 22-October-1986. 00098 * Jack Dongarra, Argonne National Lab. 00099 * Jeremy Du Croz, Nag Central Office. 00100 * Sven Hammarling, Nag Central Office. 00101 * Richard Hanson, Sandia National Labs. 00102 * 00103 * ===================================================================== 00104 * 00105 * .. Parameters .. 00106 DOUBLE COMPLEX ZERO 00107 PARAMETER (ZERO= (0.0D+0,0.0D+0)) 00108 * .. 00109 * .. Local Scalars .. 00110 DOUBLE COMPLEX TEMP 00111 INTEGER I,INFO,IX,J,JX,KX 00112 LOGICAL NOCONJ,NOUNIT 00113 * .. 00114 * .. External Functions .. 00115 LOGICAL LSAME 00116 EXTERNAL LSAME 00117 * .. 00118 * .. External Subroutines .. 00119 EXTERNAL XERBLA 00120 * .. 00121 * .. Intrinsic Functions .. 00122 INTRINSIC DCONJG,MAX 00123 * .. 00124 * 00125 * Test the input parameters. 00126 * 00127 INFO = 0 00128 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00129 INFO = 1 00130 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. 00131 + .NOT.LSAME(TRANS,'C')) THEN 00132 INFO = 2 00133 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN 00134 INFO = 3 00135 ELSE IF (N.LT.0) THEN 00136 INFO = 4 00137 ELSE IF (LDA.LT.MAX(1,N)) THEN 00138 INFO = 6 00139 ELSE IF (INCX.EQ.0) THEN 00140 INFO = 8 00141 END IF 00142 IF (INFO.NE.0) THEN 00143 CALL XERBLA('ZTRMV ',INFO) 00144 RETURN 00145 END IF 00146 * 00147 * Quick return if possible. 00148 * 00149 IF (N.EQ.0) RETURN 00150 * 00151 NOCONJ = LSAME(TRANS,'T') 00152 NOUNIT = LSAME(DIAG,'N') 00153 * 00154 * Set up the start point in X if the increment is not unity. This 00155 * will be ( N - 1 )*INCX too small for descending loops. 00156 * 00157 IF (INCX.LE.0) THEN 00158 KX = 1 - (N-1)*INCX 00159 ELSE IF (INCX.NE.1) THEN 00160 KX = 1 00161 END IF 00162 * 00163 * Start the operations. In this version the elements of A are 00164 * accessed sequentially with one pass through A. 00165 * 00166 IF (LSAME(TRANS,'N')) THEN 00167 * 00168 * Form x := A*x. 00169 * 00170 IF (LSAME(UPLO,'U')) THEN 00171 IF (INCX.EQ.1) THEN 00172 DO 20 J = 1,N 00173 IF (X(J).NE.ZERO) THEN 00174 TEMP = X(J) 00175 DO 10 I = 1,J - 1 00176 X(I) = X(I) + TEMP*A(I,J) 00177 10 CONTINUE 00178 IF (NOUNIT) X(J) = X(J)*A(J,J) 00179 END IF 00180 20 CONTINUE 00181 ELSE 00182 JX = KX 00183 DO 40 J = 1,N 00184 IF (X(JX).NE.ZERO) THEN 00185 TEMP = X(JX) 00186 IX = KX 00187 DO 30 I = 1,J - 1 00188 X(IX) = X(IX) + TEMP*A(I,J) 00189 IX = IX + INCX 00190 30 CONTINUE 00191 IF (NOUNIT) X(JX) = X(JX)*A(J,J) 00192 END IF 00193 JX = JX + INCX 00194 40 CONTINUE 00195 END IF 00196 ELSE 00197 IF (INCX.EQ.1) THEN 00198 DO 60 J = N,1,-1 00199 IF (X(J).NE.ZERO) THEN 00200 TEMP = X(J) 00201 DO 50 I = N,J + 1,-1 00202 X(I) = X(I) + TEMP*A(I,J) 00203 50 CONTINUE 00204 IF (NOUNIT) X(J) = X(J)*A(J,J) 00205 END IF 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 I = N,J + 1,-1 00215 X(IX) = X(IX) + TEMP*A(I,J) 00216 IX = IX - INCX 00217 70 CONTINUE 00218 IF (NOUNIT) X(JX) = X(JX)*A(J,J) 00219 END IF 00220 JX = JX - INCX 00221 80 CONTINUE 00222 END IF 00223 END IF 00224 ELSE 00225 * 00226 * Form x := A**T*x or x := A**H*x. 00227 * 00228 IF (LSAME(UPLO,'U')) THEN 00229 IF (INCX.EQ.1) THEN 00230 DO 110 J = N,1,-1 00231 TEMP = X(J) 00232 IF (NOCONJ) THEN 00233 IF (NOUNIT) TEMP = TEMP*A(J,J) 00234 DO 90 I = J - 1,1,-1 00235 TEMP = TEMP + A(I,J)*X(I) 00236 90 CONTINUE 00237 ELSE 00238 IF (NOUNIT) TEMP = TEMP*DCONJG(A(J,J)) 00239 DO 100 I = J - 1,1,-1 00240 TEMP = TEMP + DCONJG(A(I,J))*X(I) 00241 100 CONTINUE 00242 END IF 00243 X(J) = TEMP 00244 110 CONTINUE 00245 ELSE 00246 JX = KX + (N-1)*INCX 00247 DO 140 J = N,1,-1 00248 TEMP = X(JX) 00249 IX = JX 00250 IF (NOCONJ) THEN 00251 IF (NOUNIT) TEMP = TEMP*A(J,J) 00252 DO 120 I = J - 1,1,-1 00253 IX = IX - INCX 00254 TEMP = TEMP + A(I,J)*X(IX) 00255 120 CONTINUE 00256 ELSE 00257 IF (NOUNIT) TEMP = TEMP*DCONJG(A(J,J)) 00258 DO 130 I = J - 1,1,-1 00259 IX = IX - INCX 00260 TEMP = TEMP + DCONJG(A(I,J))*X(IX) 00261 130 CONTINUE 00262 END IF 00263 X(JX) = TEMP 00264 JX = JX - INCX 00265 140 CONTINUE 00266 END IF 00267 ELSE 00268 IF (INCX.EQ.1) THEN 00269 DO 170 J = 1,N 00270 TEMP = X(J) 00271 IF (NOCONJ) THEN 00272 IF (NOUNIT) TEMP = TEMP*A(J,J) 00273 DO 150 I = J + 1,N 00274 TEMP = TEMP + A(I,J)*X(I) 00275 150 CONTINUE 00276 ELSE 00277 IF (NOUNIT) TEMP = TEMP*DCONJG(A(J,J)) 00278 DO 160 I = J + 1,N 00279 TEMP = TEMP + DCONJG(A(I,J))*X(I) 00280 160 CONTINUE 00281 END IF 00282 X(J) = TEMP 00283 170 CONTINUE 00284 ELSE 00285 JX = KX 00286 DO 200 J = 1,N 00287 TEMP = X(JX) 00288 IX = JX 00289 IF (NOCONJ) THEN 00290 IF (NOUNIT) TEMP = TEMP*A(J,J) 00291 DO 180 I = J + 1,N 00292 IX = IX + INCX 00293 TEMP = TEMP + A(I,J)*X(IX) 00294 180 CONTINUE 00295 ELSE 00296 IF (NOUNIT) TEMP = TEMP*DCONJG(A(J,J)) 00297 DO 190 I = J + 1,N 00298 IX = IX + INCX 00299 TEMP = TEMP + DCONJG(A(I,J))*X(IX) 00300 190 CONTINUE 00301 END IF 00302 X(JX) = TEMP 00303 JX = JX + INCX 00304 200 CONTINUE 00305 END IF 00306 END IF 00307 END IF 00308 * 00309 RETURN 00310 * 00311 * End of ZTRMV . 00312 * 00313 END