Debian Codegraph @

debian/external_deps/fetk/punc/src/blas/ctrmv.c

raw
1 /* ./src_f77/ctrmv.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Subroutine */ int ctrmv_(char *uplo, char *trans, char *diag, integer *n,
9 realcomplex *a, integer *lda, realcomplex *x, integer *incx, ftnlen uplo_len,
10 ftnlen trans_len, ftnlen diag_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
14 realcomplex q__1, q__2, q__3;
15
16 /* Builtin functions */
17 void r_cnjg(realcomplex *, realcomplex *);
18
19 /* Local variables */
20 static integer i__, j, ix, jx, kx, info;
21 static realcomplex temp;
22 extern logical lsame_(char *, char *, ftnlen, ftnlen);
23 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
24 static logical noconj, nounit;
25
26 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
28 /* .. */
29
30 /* Purpose */
31 /* ======= */
32
33 /* CTRMV performs one of the matrix-vector operations */
34
35 /* x := A*x, or x := A'*x, or x := conjg( A' )*x, */
36
37 /* where x is an n element vector and A is an n by n unit, or non-unit, */
38 /* upper or lower triangular matrix. */
39
40 /* Parameters */
41 /* ========== */
42
43 /* UPLO - CHARACTER*1. */
44 /* On entry, UPLO specifies whether the matrix is an upper or */
45 /* lower triangular matrix as follows: */
46
47 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
48
49 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
50
51 /* Unchanged on exit. */
52
53 /* TRANS - CHARACTER*1. */
54 /* On entry, TRANS specifies the operation to be performed as */
55 /* follows: */
56
57 /* TRANS = 'N' or 'n' x := A*x. */
58
59 /* TRANS = 'T' or 't' x := A'*x. */
60
61 /* TRANS = 'C' or 'c' x := conjg( A' )*x. */
62
63 /* Unchanged on exit. */
64
65 /* DIAG - CHARACTER*1. */
66 /* On entry, DIAG specifies whether or not A is unit */
67 /* triangular as follows: */
68
69 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
70
71 /* DIAG = 'N' or 'n' A is not assumed to be unit */
72 /* triangular. */
73
74 /* Unchanged on exit. */
75
76 /* N - INTEGER. */
77 /* On entry, N specifies the order of the matrix A. */
78 /* N must be at least zero. */
79 /* Unchanged on exit. */
80
81 /* A - COMPLEX array of DIMENSION ( LDA, n ). */
82 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
83 /* upper triangular part of the array A must contain the upper */
84 /* triangular matrix and the strictly lower triangular part of */
85 /* A is not referenced. */
86 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
87 /* lower triangular part of the array A must contain the lower */
88 /* triangular matrix and the strictly upper triangular part of */
89 /* A is not referenced. */
90 /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
91 /* A are not referenced either, but are assumed to be unity. */
92 /* Unchanged on exit. */
93
94 /* LDA - INTEGER. */
95 /* On entry, LDA specifies the first dimension of A as declared */
96 /* in the calling (sub) program. LDA must be at least */
97 /* max( 1, n ). */
98 /* Unchanged on exit. */
99
100 /* X - COMPLEX array of dimension at least */
101 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
102 /* Before entry, the incremented array X must contain the n */
103 /* element vector x. On exit, X is overwritten with the */
104 /* tranformed vector x. */
105
106 /* INCX - INTEGER. */
107 /* On entry, INCX specifies the increment for the elements of */
108 /* X. INCX must not be zero. */
109 /* Unchanged on exit. */
110
111
112 /* Level 2 Blas routine. */
113
114 /* -- Written on 22-October-1986. */
115 /* Jack Dongarra, Argonne National Lab. */
116 /* Jeremy Du Croz, Nag Central Office. */
117 /* Sven Hammarling, Nag Central Office. */
118 /* Richard Hanson, Sandia National Labs. */
119
120
121 /* .. Parameters .. */
122 /* .. Local Scalars .. */
123 /* .. External Functions .. */
124 /* .. External Subroutines .. */
125 /* .. Intrinsic Functions .. */
126 /* .. */
127 /* .. Executable Statements .. */
128
129 /* Test the input parameters. */
130
131 /* Parameter adjustments */
132 a_dim1 = *lda;
133 a_offset = 1 + a_dim1;
134 a -= a_offset;
135 --x;
136
137 /* Function Body */
138 info = 0;
139 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
140 ftnlen)1, (ftnlen)1)) {
141 info = 1;
142 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
143 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
144 ftnlen)1)) {
145 info = 2;
146 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
147 "N", (ftnlen)1, (ftnlen)1)) {
148 info = 3;
149 } else if (*n < 0) {
150 info = 4;
151 } else if (*lda < max(1,*n)) {
152 info = 6;
153 } else if (*incx == 0) {
154 info = 8;
155 }
156 if (info != 0) {
157 xerbla_("CTRMV ", &info, (ftnlen)6);
158 return 0;
159 }
160
161 /* Quick return if possible. */
162
163 if (*n == 0) {
164 return 0;
165 }
166
167 noconj = lsame_(trans, "T", (ftnlen)1, (ftnlen)1);
168 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
169
170 /* Set up the start point in X if the increment is not unity. This */
171 /* will be ( N - 1 )*INCX too small for descending loops. */
172
173 if (*incx <= 0) {
174 kx = 1 - (*n - 1) * *incx;
175 } else if (*incx != 1) {
176 kx = 1;
177 }
178
179 /* Start the operations. In this version the elements of A are */
180 /* accessed sequentially with one pass through A. */
181
182 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
183
184 /* Form x := A*x. */
185
186 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
187 if (*incx == 1) {
188 i__1 = *n;
189 for (j = 1; j <= i__1; ++j) {
190 i__2 = j;
191 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
192 i__2 = j;
193 temp.r = x[i__2].r, temp.i = x[i__2].i;
194 i__2 = j - 1;
195 for (i__ = 1; i__ <= i__2; ++i__) {
196 i__3 = i__;
197 i__4 = i__;
198 i__5 = i__ + j * a_dim1;
199 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
200 q__2.i = temp.r * a[i__5].i + temp.i * a[
201 i__5].r;
202 q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i +
203 q__2.i;
204 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
205 /* L10: */
206 }
207 if (nounit) {
208 i__2 = j;
209 i__3 = j;
210 i__4 = j + j * a_dim1;
211 q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
212 i__4].i, q__1.i = x[i__3].r * a[i__4].i +
213 x[i__3].i * a[i__4].r;
214 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
215 }
216 }
217 /* L20: */
218 }
219 } else {
220 jx = kx;
221 i__1 = *n;
222 for (j = 1; j <= i__1; ++j) {
223 i__2 = jx;
224 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
225 i__2 = jx;
226 temp.r = x[i__2].r, temp.i = x[i__2].i;
227 ix = kx;
228 i__2 = j - 1;
229 for (i__ = 1; i__ <= i__2; ++i__) {
230 i__3 = ix;
231 i__4 = ix;
232 i__5 = i__ + j * a_dim1;
233 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
234 q__2.i = temp.r * a[i__5].i + temp.i * a[
235 i__5].r;
236 q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i +
237 q__2.i;
238 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
239 ix += *incx;
240 /* L30: */
241 }
242 if (nounit) {
243 i__2 = jx;
244 i__3 = jx;
245 i__4 = j + j * a_dim1;
246 q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
247 i__4].i, q__1.i = x[i__3].r * a[i__4].i +
248 x[i__3].i * a[i__4].r;
249 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
250 }
251 }
252 jx += *incx;
253 /* L40: */
254 }
255 }
256 } else {
257 if (*incx == 1) {
258 for (j = *n; j >= 1; --j) {
259 i__1 = j;
260 if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
261 i__1 = j;
262 temp.r = x[i__1].r, temp.i = x[i__1].i;
263 i__1 = j + 1;
264 for (i__ = *n; i__ >= i__1; --i__) {
265 i__2 = i__;
266 i__3 = i__;
267 i__4 = i__ + j * a_dim1;
268 q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
269 q__2.i = temp.r * a[i__4].i + temp.i * a[
270 i__4].r;
271 q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i +
272 q__2.i;
273 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
274 /* L50: */
275 }
276 if (nounit) {
277 i__1 = j;
278 i__2 = j;
279 i__3 = j + j * a_dim1;
280 q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
281 i__3].i, q__1.i = x[i__2].r * a[i__3].i +
282 x[i__2].i * a[i__3].r;
283 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
284 }
285 }
286 /* L60: */
287 }
288 } else {
289 kx += (*n - 1) * *incx;
290 jx = kx;
291 for (j = *n; j >= 1; --j) {
292 i__1 = jx;
293 if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
294 i__1 = jx;
295 temp.r = x[i__1].r, temp.i = x[i__1].i;
296 ix = kx;
297 i__1 = j + 1;
298 for (i__ = *n; i__ >= i__1; --i__) {
299 i__2 = ix;
300 i__3 = ix;
301 i__4 = i__ + j * a_dim1;
302 q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
303 q__2.i = temp.r * a[i__4].i + temp.i * a[
304 i__4].r;
305 q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i +
306 q__2.i;
307 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
308 ix -= *incx;
309 /* L70: */
310 }
311 if (nounit) {
312 i__1 = jx;
313 i__2 = jx;
314 i__3 = j + j * a_dim1;
315 q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
316 i__3].i, q__1.i = x[i__2].r * a[i__3].i +
317 x[i__2].i * a[i__3].r;
318 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
319 }
320 }
321 jx -= *incx;
322 /* L80: */
323 }
324 }
325 }
326 } else {
327
328 /* Form x := A'*x or x := conjg( A' )*x. */
329
330 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
331 if (*incx == 1) {
332 for (j = *n; j >= 1; --j) {
333 i__1 = j;
334 temp.r = x[i__1].r, temp.i = x[i__1].i;
335 if (noconj) {
336 if (nounit) {
337 i__1 = j + j * a_dim1;
338 q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
339 q__1.i = temp.r * a[i__1].i + temp.i * a[
340 i__1].r;
341 temp.r = q__1.r, temp.i = q__1.i;
342 }
343 for (i__ = j - 1; i__ >= 1; --i__) {
344 i__1 = i__ + j * a_dim1;
345 i__2 = i__;
346 q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
347 i__2].i, q__2.i = a[i__1].r * x[i__2].i +
348 a[i__1].i * x[i__2].r;
349 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
350 q__2.i;
351 temp.r = q__1.r, temp.i = q__1.i;
352 /* L90: */
353 }
354 } else {
355 if (nounit) {
356 r_cnjg(&q__2, &a[j + j * a_dim1]);
357 q__1.r = temp.r * q__2.r - temp.i * q__2.i,
358 q__1.i = temp.r * q__2.i + temp.i *
359 q__2.r;
360 temp.r = q__1.r, temp.i = q__1.i;
361 }
362 for (i__ = j - 1; i__ >= 1; --i__) {
363 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
364 i__1 = i__;
365 q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i,
366 q__2.i = q__3.r * x[i__1].i + q__3.i * x[
367 i__1].r;
368 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
369 q__2.i;
370 temp.r = q__1.r, temp.i = q__1.i;
371 /* L100: */
372 }
373 }
374 i__1 = j;
375 x[i__1].r = temp.r, x[i__1].i = temp.i;
376 /* L110: */
377 }
378 } else {
379 jx = kx + (*n - 1) * *incx;
380 for (j = *n; j >= 1; --j) {
381 i__1 = jx;
382 temp.r = x[i__1].r, temp.i = x[i__1].i;
383 ix = jx;
384 if (noconj) {
385 if (nounit) {
386 i__1 = j + j * a_dim1;
387 q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
388 q__1.i = temp.r * a[i__1].i + temp.i * a[
389 i__1].r;
390 temp.r = q__1.r, temp.i = q__1.i;
391 }
392 for (i__ = j - 1; i__ >= 1; --i__) {
393 ix -= *incx;
394 i__1 = i__ + j * a_dim1;
395 i__2 = ix;
396 q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
397 i__2].i, q__2.i = a[i__1].r * x[i__2].i +
398 a[i__1].i * x[i__2].r;
399 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
400 q__2.i;
401 temp.r = q__1.r, temp.i = q__1.i;
402 /* L120: */
403 }
404 } else {
405 if (nounit) {
406 r_cnjg(&q__2, &a[j + j * a_dim1]);
407 q__1.r = temp.r * q__2.r - temp.i * q__2.i,
408 q__1.i = temp.r * q__2.i + temp.i *
409 q__2.r;
410 temp.r = q__1.r, temp.i = q__1.i;
411 }
412 for (i__ = j - 1; i__ >= 1; --i__) {
413 ix -= *incx;
414 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
415 i__1 = ix;
416 q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i,
417 q__2.i = q__3.r * x[i__1].i + q__3.i * x[
418 i__1].r;
419 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
420 q__2.i;
421 temp.r = q__1.r, temp.i = q__1.i;
422 /* L130: */
423 }
424 }
425 i__1 = jx;
426 x[i__1].r = temp.r, x[i__1].i = temp.i;
427 jx -= *incx;
428 /* L140: */
429 }
430 }
431 } else {
432 if (*incx == 1) {
433 i__1 = *n;
434 for (j = 1; j <= i__1; ++j) {
435 i__2 = j;
436 temp.r = x[i__2].r, temp.i = x[i__2].i;
437 if (noconj) {
438 if (nounit) {
439 i__2 = j + j * a_dim1;
440 q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
441 q__1.i = temp.r * a[i__2].i + temp.i * a[
442 i__2].r;
443 temp.r = q__1.r, temp.i = q__1.i;
444 }
445 i__2 = *n;
446 for (i__ = j + 1; i__ <= i__2; ++i__) {
447 i__3 = i__ + j * a_dim1;
448 i__4 = i__;
449 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
450 i__4].i, q__2.i = a[i__3].r * x[i__4].i +
451 a[i__3].i * x[i__4].r;
452 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
453 q__2.i;
454 temp.r = q__1.r, temp.i = q__1.i;
455 /* L150: */
456 }
457 } else {
458 if (nounit) {
459 r_cnjg(&q__2, &a[j + j * a_dim1]);
460 q__1.r = temp.r * q__2.r - temp.i * q__2.i,
461 q__1.i = temp.r * q__2.i + temp.i *
462 q__2.r;
463 temp.r = q__1.r, temp.i = q__1.i;
464 }
465 i__2 = *n;
466 for (i__ = j + 1; i__ <= i__2; ++i__) {
467 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
468 i__3 = i__;
469 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
470 q__2.i = q__3.r * x[i__3].i + q__3.i * x[
471 i__3].r;
472 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
473 q__2.i;
474 temp.r = q__1.r, temp.i = q__1.i;
475 /* L160: */
476 }
477 }
478 i__2 = j;
479 x[i__2].r = temp.r, x[i__2].i = temp.i;
480 /* L170: */
481 }
482 } else {
483 jx = kx;
484 i__1 = *n;
485 for (j = 1; j <= i__1; ++j) {
486 i__2 = jx;
487 temp.r = x[i__2].r, temp.i = x[i__2].i;
488 ix = jx;
489 if (noconj) {
490 if (nounit) {
491 i__2 = j + j * a_dim1;
492 q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
493 q__1.i = temp.r * a[i__2].i + temp.i * a[
494 i__2].r;
495 temp.r = q__1.r, temp.i = q__1.i;
496 }
497 i__2 = *n;
498 for (i__ = j + 1; i__ <= i__2; ++i__) {
499 ix += *incx;
500 i__3 = i__ + j * a_dim1;
501 i__4 = ix;
502 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
503 i__4].i, q__2.i = a[i__3].r * x[i__4].i +
504 a[i__3].i * x[i__4].r;
505 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
506 q__2.i;
507 temp.r = q__1.r, temp.i = q__1.i;
508 /* L180: */
509 }
510 } else {
511 if (nounit) {
512 r_cnjg(&q__2, &a[j + j * a_dim1]);
513 q__1.r = temp.r * q__2.r - temp.i * q__2.i,
514 q__1.i = temp.r * q__2.i + temp.i *
515 q__2.r;
516 temp.r = q__1.r, temp.i = q__1.i;
517 }
518 i__2 = *n;
519 for (i__ = j + 1; i__ <= i__2; ++i__) {
520 ix += *incx;
521 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
522 i__3 = ix;
523 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
524 q__2.i = q__3.r * x[i__3].i + q__3.i * x[
525 i__3].r;
526 q__1.r = temp.r + q__2.r, q__1.i = temp.i +
527 q__2.i;
528 temp.r = q__1.r, temp.i = q__1.i;
529 /* L190: */
530 }
531 }
532 i__2 = jx;
533 x[i__2].r = temp.r, x[i__2].i = temp.i;
534 jx += *incx;
535 /* L200: */
536 }
537 }
538 }
539 }
540
541 return 0;
542
543 /* End of CTRMV . */
544
545 } /* ctrmv_ */
546