Debian Codegraph @

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

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