1 | SUBROUTINE CTRMV(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 | COMPLEX A(LDA,*),X(*) |
---|
8 | * .. |
---|
9 | * |
---|
10 | * Purpose |
---|
11 | * ======= |
---|
12 | * |
---|
13 | * CTRMV performs one of the matrix-vector operations |
---|
14 | * |
---|
15 | * x := A*x, or x := A'*x, or x := conjg( 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 := conjg( 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 - COMPLEX 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 - COMPLEX 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 | COMPLEX ZERO |
---|
103 | PARAMETER (ZERO= (0.0E+0,0.0E+0)) |
---|
104 | * .. |
---|
105 | * .. Local Scalars .. |
---|
106 | COMPLEX TEMP |
---|
107 | INTEGER I,INFO,IX,J,JX,KX |
---|
108 | LOGICAL NOCONJ,NOUNIT |
---|
109 | * .. |
---|
110 | * .. External Functions .. |
---|
111 | LOGICAL LSAME |
---|
112 | EXTERNAL LSAME |
---|
113 | * .. |
---|
114 | * .. External Subroutines .. |
---|
115 | EXTERNAL XERBLA |
---|
116 | * .. |
---|
117 | * .. Intrinsic Functions .. |
---|
118 | INTRINSIC CONJG,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('CTRMV ',INFO) |
---|
140 | RETURN |
---|
141 | END IF |
---|
142 | * |
---|
143 | * Quick return if possible. |
---|
144 | * |
---|
145 | IF (N.EQ.0) RETURN |
---|
146 | * |
---|
147 | NOCONJ = LSAME(TRANS,'T') |
---|
148 | NOUNIT = LSAME(DIAG,'N') |
---|
149 | * |
---|
150 | * Set up the start point in X if the increment is not unity. This |
---|
151 | * will be ( N - 1 )*INCX too small for descending loops. |
---|
152 | * |
---|
153 | IF (INCX.LE.0) THEN |
---|
154 | KX = 1 - (N-1)*INCX |
---|
155 | ELSE IF (INCX.NE.1) THEN |
---|
156 | KX = 1 |
---|
157 | END IF |
---|
158 | * |
---|
159 | * Start the operations. In this version the elements of A are |
---|
160 | * accessed sequentially with one pass through A. |
---|
161 | * |
---|
162 | IF (LSAME(TRANS,'N')) THEN |
---|
163 | * |
---|
164 | * Form x := A*x. |
---|
165 | * |
---|
166 | IF (LSAME(UPLO,'U')) THEN |
---|
167 | IF (INCX.EQ.1) THEN |
---|
168 | DO 20 J = 1,N |
---|
169 | IF (X(J).NE.ZERO) THEN |
---|
170 | TEMP = X(J) |
---|
171 | DO 10 I = 1,J - 1 |
---|
172 | X(I) = X(I) + TEMP*A(I,J) |
---|
173 | 10 CONTINUE |
---|
174 | IF (NOUNIT) X(J) = X(J)*A(J,J) |
---|
175 | END IF |
---|
176 | 20 CONTINUE |
---|
177 | ELSE |
---|
178 | JX = KX |
---|
179 | DO 40 J = 1,N |
---|
180 | IF (X(JX).NE.ZERO) THEN |
---|
181 | TEMP = X(JX) |
---|
182 | IX = KX |
---|
183 | DO 30 I = 1,J - 1 |
---|
184 | X(IX) = X(IX) + TEMP*A(I,J) |
---|
185 | IX = IX + INCX |
---|
186 | 30 CONTINUE |
---|
187 | IF (NOUNIT) X(JX) = X(JX)*A(J,J) |
---|
188 | END IF |
---|
189 | JX = JX + INCX |
---|
190 | 40 CONTINUE |
---|
191 | END IF |
---|
192 | ELSE |
---|
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 | DO 50 I = N,J + 1,-1 |
---|
198 | X(I) = X(I) + TEMP*A(I,J) |
---|
199 | 50 CONTINUE |
---|
200 | IF (NOUNIT) X(J) = X(J)*A(J,J) |
---|
201 | END IF |
---|
202 | 60 CONTINUE |
---|
203 | ELSE |
---|
204 | KX = KX + (N-1)*INCX |
---|
205 | JX = KX |
---|
206 | DO 80 J = N,1,-1 |
---|
207 | IF (X(JX).NE.ZERO) THEN |
---|
208 | TEMP = X(JX) |
---|
209 | IX = KX |
---|
210 | DO 70 I = N,J + 1,-1 |
---|
211 | X(IX) = X(IX) + TEMP*A(I,J) |
---|
212 | IX = IX - INCX |
---|
213 | 70 CONTINUE |
---|
214 | IF (NOUNIT) X(JX) = X(JX)*A(J,J) |
---|
215 | END IF |
---|
216 | JX = JX - INCX |
---|
217 | 80 CONTINUE |
---|
218 | END IF |
---|
219 | END IF |
---|
220 | ELSE |
---|
221 | * |
---|
222 | * Form x := A'*x or x := conjg( A' )*x. |
---|
223 | * |
---|
224 | IF (LSAME(UPLO,'U')) THEN |
---|
225 | IF (INCX.EQ.1) THEN |
---|
226 | DO 110 J = N,1,-1 |
---|
227 | TEMP = X(J) |
---|
228 | IF (NOCONJ) THEN |
---|
229 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
230 | DO 90 I = J - 1,1,-1 |
---|
231 | TEMP = TEMP + A(I,J)*X(I) |
---|
232 | 90 CONTINUE |
---|
233 | ELSE |
---|
234 | IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J)) |
---|
235 | DO 100 I = J - 1,1,-1 |
---|
236 | TEMP = TEMP + CONJG(A(I,J))*X(I) |
---|
237 | 100 CONTINUE |
---|
238 | END IF |
---|
239 | X(J) = TEMP |
---|
240 | 110 CONTINUE |
---|
241 | ELSE |
---|
242 | JX = KX + (N-1)*INCX |
---|
243 | DO 140 J = N,1,-1 |
---|
244 | TEMP = X(JX) |
---|
245 | IX = JX |
---|
246 | IF (NOCONJ) THEN |
---|
247 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
248 | DO 120 I = J - 1,1,-1 |
---|
249 | IX = IX - INCX |
---|
250 | TEMP = TEMP + A(I,J)*X(IX) |
---|
251 | 120 CONTINUE |
---|
252 | ELSE |
---|
253 | IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J)) |
---|
254 | DO 130 I = J - 1,1,-1 |
---|
255 | IX = IX - INCX |
---|
256 | TEMP = TEMP + CONJG(A(I,J))*X(IX) |
---|
257 | 130 CONTINUE |
---|
258 | END IF |
---|
259 | X(JX) = TEMP |
---|
260 | JX = JX - INCX |
---|
261 | 140 CONTINUE |
---|
262 | END IF |
---|
263 | ELSE |
---|
264 | IF (INCX.EQ.1) THEN |
---|
265 | DO 170 J = 1,N |
---|
266 | TEMP = X(J) |
---|
267 | IF (NOCONJ) THEN |
---|
268 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
269 | DO 150 I = J + 1,N |
---|
270 | TEMP = TEMP + A(I,J)*X(I) |
---|
271 | 150 CONTINUE |
---|
272 | ELSE |
---|
273 | IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J)) |
---|
274 | DO 160 I = J + 1,N |
---|
275 | TEMP = TEMP + CONJG(A(I,J))*X(I) |
---|
276 | 160 CONTINUE |
---|
277 | END IF |
---|
278 | X(J) = TEMP |
---|
279 | 170 CONTINUE |
---|
280 | ELSE |
---|
281 | JX = KX |
---|
282 | DO 200 J = 1,N |
---|
283 | TEMP = X(JX) |
---|
284 | IX = JX |
---|
285 | IF (NOCONJ) THEN |
---|
286 | IF (NOUNIT) TEMP = TEMP*A(J,J) |
---|
287 | DO 180 I = J + 1,N |
---|
288 | IX = IX + INCX |
---|
289 | TEMP = TEMP + A(I,J)*X(IX) |
---|
290 | 180 CONTINUE |
---|
291 | ELSE |
---|
292 | IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J)) |
---|
293 | DO 190 I = J + 1,N |
---|
294 | IX = IX + INCX |
---|
295 | TEMP = TEMP + CONJG(A(I,J))*X(IX) |
---|
296 | 190 CONTINUE |
---|
297 | END IF |
---|
298 | X(JX) = TEMP |
---|
299 | JX = JX + INCX |
---|
300 | 200 CONTINUE |
---|
301 | END IF |
---|
302 | END IF |
---|
303 | END IF |
---|
304 | * |
---|
305 | RETURN |
---|
306 | * |
---|
307 | * End of CTRMV . |
---|
308 | * |
---|
309 | END |
---|