LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE DTRMV(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 PRECISION A(LDA,*),X(*) 00008 * .. 00009 * 00010 * Purpose 00011 * ======= 00012 * 00013 * DTRMV 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. 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 * A - DOUBLE PRECISION 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 - DOUBLE PRECISION 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 PRECISION ZERO 00107 PARAMETER (ZERO=0.0D+0) 00108 * .. 00109 * .. Local Scalars .. 00110 DOUBLE PRECISION TEMP 00111 INTEGER I,INFO,IX,J,JX,KX 00112 LOGICAL NOUNIT 00113 * .. 00114 * .. External Functions .. 00115 LOGICAL LSAME 00116 EXTERNAL LSAME 00117 * .. 00118 * .. External Subroutines .. 00119 EXTERNAL XERBLA 00120 * .. 00121 * .. Intrinsic Functions .. 00122 INTRINSIC 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('DTRMV ',INFO) 00144 RETURN 00145 END IF 00146 * 00147 * Quick return if possible. 00148 * 00149 IF (N.EQ.0) RETURN 00150 * 00151 NOUNIT = LSAME(DIAG,'N') 00152 * 00153 * Set up the start point in X if the increment is not unity. This 00154 * will be ( N - 1 )*INCX too small for descending loops. 00155 * 00156 IF (INCX.LE.0) THEN 00157 KX = 1 - (N-1)*INCX 00158 ELSE IF (INCX.NE.1) THEN 00159 KX = 1 00160 END IF 00161 * 00162 * Start the operations. In this version the elements of A are 00163 * accessed sequentially with one pass through A. 00164 * 00165 IF (LSAME(TRANS,'N')) THEN 00166 * 00167 * Form x := A*x. 00168 * 00169 IF (LSAME(UPLO,'U')) THEN 00170 IF (INCX.EQ.1) THEN 00171 DO 20 J = 1,N 00172 IF (X(J).NE.ZERO) THEN 00173 TEMP = X(J) 00174 DO 10 I = 1,J - 1 00175 X(I) = X(I) + TEMP*A(I,J) 00176 10 CONTINUE 00177 IF (NOUNIT) X(J) = X(J)*A(J,J) 00178 END IF 00179 20 CONTINUE 00180 ELSE 00181 JX = KX 00182 DO 40 J = 1,N 00183 IF (X(JX).NE.ZERO) THEN 00184 TEMP = X(JX) 00185 IX = KX 00186 DO 30 I = 1,J - 1 00187 X(IX) = X(IX) + TEMP*A(I,J) 00188 IX = IX + INCX 00189 30 CONTINUE 00190 IF (NOUNIT) X(JX) = X(JX)*A(J,J) 00191 END IF 00192 JX = JX + INCX 00193 40 CONTINUE 00194 END IF 00195 ELSE 00196 IF (INCX.EQ.1) THEN 00197 DO 60 J = N,1,-1 00198 IF (X(J).NE.ZERO) THEN 00199 TEMP = X(J) 00200 DO 50 I = N,J + 1,-1 00201 X(I) = X(I) + TEMP*A(I,J) 00202 50 CONTINUE 00203 IF (NOUNIT) X(J) = X(J)*A(J,J) 00204 END IF 00205 60 CONTINUE 00206 ELSE 00207 KX = KX + (N-1)*INCX 00208 JX = KX 00209 DO 80 J = N,1,-1 00210 IF (X(JX).NE.ZERO) THEN 00211 TEMP = X(JX) 00212 IX = KX 00213 DO 70 I = N,J + 1,-1 00214 X(IX) = X(IX) + TEMP*A(I,J) 00215 IX = IX - INCX 00216 70 CONTINUE 00217 IF (NOUNIT) X(JX) = X(JX)*A(J,J) 00218 END IF 00219 JX = JX - INCX 00220 80 CONTINUE 00221 END IF 00222 END IF 00223 ELSE 00224 * 00225 * Form x := A**T*x. 00226 * 00227 IF (LSAME(UPLO,'U')) THEN 00228 IF (INCX.EQ.1) THEN 00229 DO 100 J = N,1,-1 00230 TEMP = X(J) 00231 IF (NOUNIT) TEMP = TEMP*A(J,J) 00232 DO 90 I = J - 1,1,-1 00233 TEMP = TEMP + A(I,J)*X(I) 00234 90 CONTINUE 00235 X(J) = TEMP 00236 100 CONTINUE 00237 ELSE 00238 JX = KX + (N-1)*INCX 00239 DO 120 J = N,1,-1 00240 TEMP = X(JX) 00241 IX = JX 00242 IF (NOUNIT) TEMP = TEMP*A(J,J) 00243 DO 110 I = J - 1,1,-1 00244 IX = IX - INCX 00245 TEMP = TEMP + A(I,J)*X(IX) 00246 110 CONTINUE 00247 X(JX) = TEMP 00248 JX = JX - INCX 00249 120 CONTINUE 00250 END IF 00251 ELSE 00252 IF (INCX.EQ.1) THEN 00253 DO 140 J = 1,N 00254 TEMP = X(J) 00255 IF (NOUNIT) TEMP = TEMP*A(J,J) 00256 DO 130 I = J + 1,N 00257 TEMP = TEMP + A(I,J)*X(I) 00258 130 CONTINUE 00259 X(J) = TEMP 00260 140 CONTINUE 00261 ELSE 00262 JX = KX 00263 DO 160 J = 1,N 00264 TEMP = X(JX) 00265 IX = JX 00266 IF (NOUNIT) TEMP = TEMP*A(J,J) 00267 DO 150 I = J + 1,N 00268 IX = IX + INCX 00269 TEMP = TEMP + A(I,J)*X(IX) 00270 150 CONTINUE 00271 X(JX) = TEMP 00272 JX = JX + INCX 00273 160 CONTINUE 00274 END IF 00275 END IF 00276 END IF 00277 * 00278 RETURN 00279 * 00280 * End of DTRMV . 00281 * 00282 END