1 | SUBROUTINE DTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX) |
---|
2 | * .. Scalar Arguments .. |
---|
3 | INTEGER INCX,LDA,N |
---|
4 | CHARACTER DIAG,TRANS,UPLO |
---|
5 | * .. |
---|
6 | * .. Array Arguments .. |
---|
7 | DOUBLE PRECISION A(LDA,*),X(*) |
---|
8 | * .. |
---|
9 | * |
---|
10 | * Purpose |
---|
11 | * ======= |
---|
12 | * |
---|
13 | * DTRMV 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. |
---|
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 | * A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). |
---|
62 | * Before entry with UPLO = 'U' or 'u', the leading n by n |
---|
63 | * upper triangular part of the array A must contain the upper |
---|
64 | * triangular matrix and the strictly lower triangular part of |
---|
65 | * A is not referenced. |
---|
66 | * Before entry with UPLO = 'L' or 'l', the leading n by n |
---|
67 | * lower triangular part of the array A must contain the lower |
---|
68 | * triangular matrix and the strictly upper triangular part of |
---|
69 | * A is not referenced. |
---|
70 | * Note that when DIAG = 'U' or 'u', the diagonal elements of |
---|
71 | * A are not referenced either, but are assumed to be unity. |
---|
72 | * Unchanged on exit. |
---|
73 | * |
---|
74 | * LDA - INTEGER. |
---|
75 | * On entry, LDA specifies the first dimension of A as declared |
---|
76 | * in the calling (sub) program. LDA must be at least |
---|
77 | * max( 1, n ). |
---|
78 | * Unchanged on exit. |
---|
79 | * |
---|
80 | * X - DOUBLE PRECISION array of dimension at least |
---|
81 | * ( 1 + ( n - 1 )*abs( INCX ) ). |
---|
82 | * Before entry, the incremented array X must contain the n |
---|
83 | * element vector x. On exit, X is overwritten with the |
---|
84 | * tranformed vector x. |
---|
85 | * |
---|
86 | * INCX - INTEGER. |
---|
87 | * On entry, INCX specifies the increment for the elements of |
---|
88 | * X. INCX must not be zero. |
---|
89 | * Unchanged on exit. |
---|
90 | * |
---|
91 | * |
---|
92 | * Level 2 Blas routine. |
---|
93 | * |
---|
94 | * -- Written on 22-October-1986. |
---|
95 | * Jack Dongarra, Argonne National Lab. |
---|
96 | * Jeremy Du Croz, Nag Central Office. |
---|
97 | * Sven Hammarling, Nag Central Office. |
---|
98 | * Richard Hanson, Sandia National Labs. |
---|
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,KX |
---|
108 | LOGICAL NOUNIT |
---|
109 | * .. |
---|
110 | * .. External Functions .. |
---|
111 | LOGICAL LSAME |
---|
112 | EXTERNAL LSAME |
---|
113 | * .. |
---|
114 | * .. External Subroutines .. |
---|
115 | EXTERNAL XERBLA |
---|
116 | * .. |
---|
117 | * .. Intrinsic Functions .. |
---|
118 | INTRINSIC MAX |
---|
119 | * .. |
---|
120 | * |
---|
121 | * Test the input parameters. |
---|
122 | * |
---|
123 | INFO = 0 |
---|
124 | IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN |
---|
125 | INFO = 1 |
---|
126 | ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. |
---|
127 | + .NOT.LSAME(TRANS,'C')) THEN |
---|
128 | INFO = 2 |
---|
129 | ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN |
---|
130 | INFO = 3 |
---|
131 | ELSE IF (N.LT.0) THEN |
---|
132 | INFO = 4 |
---|
133 | ELSE IF (LDA.LT.MAX(1,N)) THEN |
---|
134 | INFO = 6 |
---|
135 | ELSE IF (INCX.EQ.0) THEN |
---|
136 | INFO = 8 |
---|
137 | END IF |
---|
138 | IF (INFO.NE.0) THEN |
---|
139 | CALL XERBLA('DTRMV ',INFO) |
---|
140 | RETURN |
---|
141 | END IF |
---|
142 | * |
---|
143 | * Quick return if possible. |
---|
144 | * |
---|
145 | IF (N.EQ.0) RETURN |
---|
146 | * |
---|
147 | NOUNIT = LSAME(DIAG,'N') |
---|
148 | * |
---|
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. |
---|
151 | * |
---|
152 | IF (INCX.LE.0) THEN |
---|
153 | KX = 1 - (N-1)*INCX |
---|
154 | ELSE IF (INCX.NE.1) THEN |
---|
155 | KX = 1 |
---|
156 | END IF |
---|
157 | * |
---|
158 | * Start the operations. In this version the elements of A are |
---|
159 | * accessed sequentially with one pass through A. |
---|
160 | * |
---|
161 | IF (LSAME(TRANS,'N')) THEN |
---|
162 | * |
---|
163 | * Form x := A*x. |
---|
164 | * |
---|
165 | IF (LSAME(UPLO,'U')) THEN |
---|
166 | IF (INCX.EQ.1) THEN |
---|
167 | DO 20 J = 1,N |
---|
168 | IF (X(J).NE.ZERO) THEN |
---|
169 | TEMP = X(J) |
---|
170 | DO 10 I = 1,J - 1 |
---|
171 | X(I) = X(I) + TEMP*A(I,J) |
---|
172 | 10 CONTINUE |
---|
173 | IF (NOUNIT) X(J) = X(J)*A(J,J) |
---|
174 | END IF |
---|
175 | 20 CONTINUE |
---|
176 | ELSE |
---|
177 | JX = KX |
---|
178 | DO 40 J = 1,N |
---|
179 | IF (X(JX).NE.ZERO) THEN |
---|
180 | TEMP = X(JX) |
---|
181 | IX = KX |
---|
182 | DO 30 I = 1,J - 1 |
---|
183 | X(IX) = X(IX) + TEMP*A(I,J) |
---|
184 | IX = IX + INCX |
---|
185 | 30 CONTINUE |
---|
186 | IF (NOUNIT) X(JX) = X(JX)*A(J,J) |
---|
187 | END IF |
---|
188 | JX = JX + INCX |
---|
189 | 40 CONTINUE |
---|
190 | END IF |
---|
191 | ELSE |
---|
192 | IF (INCX.EQ.1) THEN |
---|
193 | DO 60 J = N,1,-1 |
---|
194 | IF (X(J).NE.ZERO) THEN |
---|
195 | TEMP = X(J) |
---|
196 | DO 50 I = N,J + 1,-1 |
---|
197 | X(I) = X(I) + TEMP*A(I,J) |
---|
198 | 50 CONTINUE |
---|
199 | IF (NOUNIT) X(J) = X(J)*A(J,J) |
---|
200 | END IF |
---|
201 | 60 CONTINUE |
---|
202 | ELSE |
---|
203 | KX = KX + (N-1)*INCX |
---|
204 | JX = KX |
---|
205 | DO 80 J = N,1,-1 |
---|
206 | IF (X(JX).NE.ZERO) THEN |
---|
207 | TEMP = X(JX) |
---|
208 | IX = KX |
---|
209 | DO 70 I = N,J + 1,-1 |
---|
210 | X(IX) = X(IX) + TEMP*A(I,J) |
---|
211 | IX = IX - INCX |
---|
212 | 70 CONTINUE |
---|
213 | IF (NOUNIT) X(JX) = X(JX)*A(J,J) |
---|
214 | END IF |
---|
215 | JX = JX - INCX |
---|
216 | 80 CONTINUE |
---|
217 | END IF |
---|
218 | END IF |
---|
219 | ELSE |
---|
220 | * |
---|
221 | * Form x := A'*x. |
---|
222 | * |
---|
223 | IF (LSAME(UPLO,'U')) THEN |
---|
224 | IF (INCX.EQ.1) THEN |
---|
225 | DO 100 J = N,1,-1 |
---|
226 | TEMP = X(J) |
---|
227 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
228 | DO 90 I = J - 1,1,-1 |
---|
229 | TEMP = TEMP + A(I,J)*X(I) |
---|
230 | 90 CONTINUE |
---|
231 | X(J) = TEMP |
---|
232 | 100 CONTINUE |
---|
233 | ELSE |
---|
234 | JX = KX + (N-1)*INCX |
---|
235 | DO 120 J = N,1,-1 |
---|
236 | TEMP = X(JX) |
---|
237 | IX = JX |
---|
238 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
239 | DO 110 I = J - 1,1,-1 |
---|
240 | IX = IX - INCX |
---|
241 | TEMP = TEMP + A(I,J)*X(IX) |
---|
242 | 110 CONTINUE |
---|
243 | X(JX) = TEMP |
---|
244 | JX = JX - INCX |
---|
245 | 120 CONTINUE |
---|
246 | END IF |
---|
247 | ELSE |
---|
248 | IF (INCX.EQ.1) THEN |
---|
249 | DO 140 J = 1,N |
---|
250 | TEMP = X(J) |
---|
251 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
252 | DO 130 I = J + 1,N |
---|
253 | TEMP = TEMP + A(I,J)*X(I) |
---|
254 | 130 CONTINUE |
---|
255 | X(J) = TEMP |
---|
256 | 140 CONTINUE |
---|
257 | ELSE |
---|
258 | JX = KX |
---|
259 | DO 160 J = 1,N |
---|
260 | TEMP = X(JX) |
---|
261 | IX = JX |
---|
262 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
263 | DO 150 I = J + 1,N |
---|
264 | IX = IX + INCX |
---|
265 | TEMP = TEMP + A(I,J)*X(IX) |
---|
266 | 150 CONTINUE |
---|
267 | X(JX) = TEMP |
---|
268 | JX = JX + INCX |
---|
269 | 160 CONTINUE |
---|
270 | END IF |
---|
271 | END IF |
---|
272 | END IF |
---|
273 | * |
---|
274 | RETURN |
---|
275 | * |
---|
276 | * End of DTRMV . |
---|
277 | * |
---|
278 | END |
---|