Debian Codegraph @

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

raw
1 /* ./src_f77/cgemv.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 cgemv_(char *trans, integer *m, integer *n, realcomplex *
9 alpha, realcomplex *a, integer *lda, realcomplex *x, integer *incx, realcomplex *
10 beta, realcomplex *y, integer *incy, ftnlen trans_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, iy, jx, jy, kx, ky, info;
21 static realcomplex temp;
22 static integer lenx, leny;
23 extern logical lsame_(char *, char *, ftnlen, ftnlen);
24 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
25 static logical noconj;
26
27 /* .. Scalar Arguments .. */
28 /* .. Array Arguments .. */
29 /* .. */
30
31 /* Purpose */
32 /* ======= */
33
34 /* CGEMV performs one of the matrix-vector operations */
35
36 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or */
37
38 /* y := alpha*conjg( A' )*x + beta*y, */
39
40 /* where alpha and beta are scalars, x and y are vectors and A is an */
41 /* m by n matrix. */
42
43 /* Parameters */
44 /* ========== */
45
46 /* TRANS - CHARACTER*1. */
47 /* On entry, TRANS specifies the operation to be performed as */
48 /* follows: */
49
50 /* TRANS = 'N' or 'n' y := alpha*A*x + beta*y. */
51
52 /* TRANS = 'T' or 't' y := alpha*A'*x + beta*y. */
53
54 /* TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y. */
55
56 /* Unchanged on exit. */
57
58 /* M - INTEGER. */
59 /* On entry, M specifies the number of rows of the matrix A. */
60 /* M must be at least zero. */
61 /* Unchanged on exit. */
62
63 /* N - INTEGER. */
64 /* On entry, N specifies the number of columns of the matrix A. */
65 /* N must be at least zero. */
66 /* Unchanged on exit. */
67
68 /* ALPHA - COMPLEX . */
69 /* On entry, ALPHA specifies the scalar alpha. */
70 /* Unchanged on exit. */
71
72 /* A - COMPLEX array of DIMENSION ( LDA, n ). */
73 /* Before entry, the leading m by n part of the array A must */
74 /* contain the matrix of coefficients. */
75 /* Unchanged on exit. */
76
77 /* LDA - INTEGER. */
78 /* On entry, LDA specifies the first dimension of A as declared */
79 /* in the calling (sub) program. LDA must be at least */
80 /* max( 1, m ). */
81 /* Unchanged on exit. */
82
83 /* X - COMPLEX array of DIMENSION at least */
84 /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
85 /* and at least */
86 /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
87 /* Before entry, the incremented array X must contain the */
88 /* vector x. */
89 /* Unchanged on exit. */
90
91 /* INCX - INTEGER. */
92 /* On entry, INCX specifies the increment for the elements of */
93 /* X. INCX must not be zero. */
94 /* Unchanged on exit. */
95
96 /* BETA - COMPLEX . */
97 /* On entry, BETA specifies the scalar beta. When BETA is */
98 /* supplied as zero then Y need not be set on input. */
99 /* Unchanged on exit. */
100
101 /* Y - COMPLEX array of DIMENSION at least */
102 /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
103 /* and at least */
104 /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
105 /* Before entry with BETA non-zero, the incremented array Y */
106 /* must contain the vector y. On exit, Y is overwritten by the */
107 /* updated vector y. */
108
109 /* INCY - INTEGER. */
110 /* On entry, INCY specifies the increment for the elements of */
111 /* Y. INCY must not be zero. */
112 /* Unchanged on exit. */
113
114
115 /* Level 2 Blas routine. */
116
117 /* -- Written on 22-October-1986. */
118 /* Jack Dongarra, Argonne National Lab. */
119 /* Jeremy Du Croz, Nag Central Office. */
120 /* Sven Hammarling, Nag Central Office. */
121 /* Richard Hanson, Sandia National Labs. */
122
123
124 /* .. Parameters .. */
125 /* .. Local Scalars .. */
126 /* .. External Functions .. */
127 /* .. External Subroutines .. */
128 /* .. Intrinsic Functions .. */
129 /* .. */
130 /* .. Executable Statements .. */
131
132 /* Test the input parameters. */
133
134 /* Parameter adjustments */
135 a_dim1 = *lda;
136 a_offset = 1 + a_dim1;
137 a -= a_offset;
138 --x;
139 --y;
140
141 /* Function Body */
142 info = 0;
143 if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "T", (
144 ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (ftnlen)1)
145 ) {
146 info = 1;
147 } else if (*m < 0) {
148 info = 2;
149 } else if (*n < 0) {
150 info = 3;
151 } else if (*lda < max(1,*m)) {
152 info = 6;
153 } else if (*incx == 0) {
154 info = 8;
155 } else if (*incy == 0) {
156 info = 11;
157 }
158 if (info != 0) {
159 xerbla_("CGEMV ", &info, (ftnlen)6);
160 return 0;
161 }
162
163 /* Quick return if possible. */
164
165 if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r
166 == 1.f && beta->i == 0.f)) {
167 return 0;
168 }
169
170 noconj = lsame_(trans, "T", (ftnlen)1, (ftnlen)1);
171
172 /* Set LENX and LENY, the lengths of the vectors x and y, and set */
173 /* up the start points in X and Y. */
174
175 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
176 lenx = *n;
177 leny = *m;
178 } else {
179 lenx = *m;
180 leny = *n;
181 }
182 if (*incx > 0) {
183 kx = 1;
184 } else {
185 kx = 1 - (lenx - 1) * *incx;
186 }
187 if (*incy > 0) {
188 ky = 1;
189 } else {
190 ky = 1 - (leny - 1) * *incy;
191 }
192
193 /* Start the operations. In this version the elements of A are */
194 /* accessed sequentially with one pass through A. */
195
196 /* First form y := beta*y. */
197
198 if (beta->r != 1.f || beta->i != 0.f) {
199 if (*incy == 1) {
200 if (beta->r == 0.f && beta->i == 0.f) {
201 i__1 = leny;
202 for (i__ = 1; i__ <= i__1; ++i__) {
203 i__2 = i__;
204 y[i__2].r = 0.f, y[i__2].i = 0.f;
205 /* L10: */
206 }
207 } else {
208 i__1 = leny;
209 for (i__ = 1; i__ <= i__1; ++i__) {
210 i__2 = i__;
211 i__3 = i__;
212 q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
213 q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
214 .r;
215 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
216 /* L20: */
217 }
218 }
219 } else {
220 iy = ky;
221 if (beta->r == 0.f && beta->i == 0.f) {
222 i__1 = leny;
223 for (i__ = 1; i__ <= i__1; ++i__) {
224 i__2 = iy;
225 y[i__2].r = 0.f, y[i__2].i = 0.f;
226 iy += *incy;
227 /* L30: */
228 }
229 } else {
230 i__1 = leny;
231 for (i__ = 1; i__ <= i__1; ++i__) {
232 i__2 = iy;
233 i__3 = iy;
234 q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
235 q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
236 .r;
237 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
238 iy += *incy;
239 /* L40: */
240 }
241 }
242 }
243 }
244 if (alpha->r == 0.f && alpha->i == 0.f) {
245 return 0;
246 }
247 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
248
249 /* Form y := alpha*A*x + y. */
250
251 jx = kx;
252 if (*incy == 1) {
253 i__1 = *n;
254 for (j = 1; j <= i__1; ++j) {
255 i__2 = jx;
256 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
257 i__2 = jx;
258 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
259 q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
260 .r;
261 temp.r = q__1.r, temp.i = q__1.i;
262 i__2 = *m;
263 for (i__ = 1; i__ <= i__2; ++i__) {
264 i__3 = i__;
265 i__4 = i__;
266 i__5 = i__ + j * a_dim1;
267 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
268 q__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
269 .r;
270 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i +
271 q__2.i;
272 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
273 /* L50: */
274 }
275 }
276 jx += *incx;
277 /* L60: */
278 }
279 } else {
280 i__1 = *n;
281 for (j = 1; j <= i__1; ++j) {
282 i__2 = jx;
283 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
284 i__2 = jx;
285 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
286 q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
287 .r;
288 temp.r = q__1.r, temp.i = q__1.i;
289 iy = ky;
290 i__2 = *m;
291 for (i__ = 1; i__ <= i__2; ++i__) {
292 i__3 = iy;
293 i__4 = iy;
294 i__5 = i__ + j * a_dim1;
295 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
296 q__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
297 .r;
298 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i +
299 q__2.i;
300 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
301 iy += *incy;
302 /* L70: */
303 }
304 }
305 jx += *incx;
306 /* L80: */
307 }
308 }
309 } else {
310
311 /* Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. */
312
313 jy = ky;
314 if (*incx == 1) {
315 i__1 = *n;
316 for (j = 1; j <= i__1; ++j) {
317 temp.r = 0.f, temp.i = 0.f;
318 if (noconj) {
319 i__2 = *m;
320 for (i__ = 1; i__ <= i__2; ++i__) {
321 i__3 = i__ + j * a_dim1;
322 i__4 = i__;
323 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
324 .i, q__2.i = a[i__3].r * x[i__4].i + a[i__3]
325 .i * x[i__4].r;
326 q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
327 temp.r = q__1.r, temp.i = q__1.i;
328 /* L90: */
329 }
330 } else {
331 i__2 = *m;
332 for (i__ = 1; i__ <= i__2; ++i__) {
333 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
334 i__3 = i__;
335 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
336 q__2.i = q__3.r * x[i__3].i + q__3.i * x[i__3]
337 .r;
338 q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
339 temp.r = q__1.r, temp.i = q__1.i;
340 /* L100: */
341 }
342 }
343 i__2 = jy;
344 i__3 = jy;
345 q__2.r = alpha->r * temp.r - alpha->i * temp.i, q__2.i =
346 alpha->r * temp.i + alpha->i * temp.r;
347 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
348 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
349 jy += *incy;
350 /* L110: */
351 }
352 } else {
353 i__1 = *n;
354 for (j = 1; j <= i__1; ++j) {
355 temp.r = 0.f, temp.i = 0.f;
356 ix = kx;
357 if (noconj) {
358 i__2 = *m;
359 for (i__ = 1; i__ <= i__2; ++i__) {
360 i__3 = i__ + j * a_dim1;
361 i__4 = ix;
362 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
363 .i, q__2.i = a[i__3].r * x[i__4].i + a[i__3]
364 .i * x[i__4].r;
365 q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
366 temp.r = q__1.r, temp.i = q__1.i;
367 ix += *incx;
368 /* L120: */
369 }
370 } else {
371 i__2 = *m;
372 for (i__ = 1; i__ <= i__2; ++i__) {
373 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
374 i__3 = ix;
375 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
376 q__2.i = q__3.r * x[i__3].i + q__3.i * x[i__3]
377 .r;
378 q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
379 temp.r = q__1.r, temp.i = q__1.i;
380 ix += *incx;
381 /* L130: */
382 }
383 }
384 i__2 = jy;
385 i__3 = jy;
386 q__2.r = alpha->r * temp.r - alpha->i * temp.i, q__2.i =
387 alpha->r * temp.i + alpha->i * temp.r;
388 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
389 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
390 jy += *incy;
391 /* L140: */
392 }
393 }
394 }
395
396 return 0;
397
398 /* End of CGEMV . */
399
400 } /* cgemv_ */
401