Debian Codegraph @

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

raw
1 /* ./src_f77/zgbmv.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 zgbmv_(char *trans, integer *m, integer *n, integer *kl,
9 integer *ku, doublecomplex *alpha, doublecomplex *a, integer *lda,
10 doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *
11 y, integer *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, i__6;
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, k, ix, iy, jx, jy, kx, ky, kup1, 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 /* ZGBMV 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 band matrix, with kl sub-diagonals and ku super-diagonals. */
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 /* KL - INTEGER. */
70 /* On entry, KL specifies the number of sub-diagonals of the */
71 /* matrix A. KL must satisfy 0 .le. KL. */
72 /* Unchanged on exit. */
73
74 /* KU - INTEGER. */
75 /* On entry, KU specifies the number of super-diagonals of the */
76 /* matrix A. KU must satisfy 0 .le. KU. */
77 /* Unchanged on exit. */
78
79 /* ALPHA - COMPLEX*16 . */
80 /* On entry, ALPHA specifies the scalar alpha. */
81 /* Unchanged on exit. */
82
83 /* A - COMPLEX*16 array of DIMENSION ( LDA, n ). */
84 /* Before entry, the leading ( kl + ku + 1 ) by n part of the */
85 /* array A must contain the matrix of coefficients, supplied */
86 /* column by column, with the leading diagonal of the matrix in */
87 /* row ( ku + 1 ) of the array, the first super-diagonal */
88 /* starting at position 2 in row ku, the first sub-diagonal */
89 /* starting at position 1 in row ( ku + 2 ), and so on. */
90 /* Elements in the array A that do not correspond to elements */
91 /* in the band matrix (such as the top left ku by ku triangle) */
92 /* are not referenced. */
93 /* The following program segment will transfer a band matrix */
94 /* from conventional full matrix storage to band storage: */
95
96 /* DO 20, J = 1, N */
97 /* K = KU + 1 - J */
98 /* DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL ) */
99 /* A( K + I, J ) = matrix( I, J ) */
100 /* 10 CONTINUE */
101 /* 20 CONTINUE */
102
103 /* Unchanged on exit. */
104
105 /* LDA - INTEGER. */
106 /* On entry, LDA specifies the first dimension of A as declared */
107 /* in the calling (sub) program. LDA must be at least */
108 /* ( kl + ku + 1 ). */
109 /* Unchanged on exit. */
110
111 /* X - COMPLEX*16 array of DIMENSION at least */
112 /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
113 /* and at least */
114 /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
115 /* Before entry, the incremented array X must contain the */
116 /* vector x. */
117 /* Unchanged on exit. */
118
119 /* INCX - INTEGER. */
120 /* On entry, INCX specifies the increment for the elements of */
121 /* X. INCX must not be zero. */
122 /* Unchanged on exit. */
123
124 /* BETA - COMPLEX*16 . */
125 /* On entry, BETA specifies the scalar beta. When BETA is */
126 /* supplied as zero then Y need not be set on input. */
127 /* Unchanged on exit. */
128
129 /* Y - COMPLEX*16 array of DIMENSION at least */
130 /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
131 /* and at least */
132 /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
133 /* Before entry, the incremented array Y must contain the */
134 /* vector y. On exit, Y is overwritten by the updated vector y. */
135
136
137 /* INCY - INTEGER. */
138 /* On entry, INCY specifies the increment for the elements of */
139 /* Y. INCY must not be zero. */
140 /* Unchanged on exit. */
141
142
143 /* Level 2 Blas routine. */
144
145 /* -- Written on 22-October-1986. */
146 /* Jack Dongarra, Argonne National Lab. */
147 /* Jeremy Du Croz, Nag Central Office. */
148 /* Sven Hammarling, Nag Central Office. */
149 /* Richard Hanson, Sandia National Labs. */
150
151
152 /* .. Parameters .. */
153 /* .. Local Scalars .. */
154 /* .. External Functions .. */
155 /* .. External Subroutines .. */
156 /* .. Intrinsic Functions .. */
157 /* .. */
158 /* .. Executable Statements .. */
159
160 /* Test the input parameters. */
161
162 /* Parameter adjustments */
163 a_dim1 = *lda;
164 a_offset = 1 + a_dim1;
165 a -= a_offset;
166 --x;
167 --y;
168
169 /* Function Body */
170 info = 0;
171 if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "T", (
172 ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (ftnlen)1)
173 ) {
174 info = 1;
175 } else if (*m < 0) {
176 info = 2;
177 } else if (*n < 0) {
178 info = 3;
179 } else if (*kl < 0) {
180 info = 4;
181 } else if (*ku < 0) {
182 info = 5;
183 } else if (*lda < *kl + *ku + 1) {
184 info = 8;
185 } else if (*incx == 0) {
186 info = 10;
187 } else if (*incy == 0) {
188 info = 13;
189 }
190 if (info != 0) {
191 xerbla_("ZGBMV ", &info, (ftnlen)6);
192 return 0;
193 }
194
195 /* Quick return if possible. */
196
197 if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0. && (beta->r ==
198 1. && beta->i == 0.)) {
199 return 0;
200 }
201
202 noconj = lsame_(trans, "T", (ftnlen)1, (ftnlen)1);
203
204 /* Set LENX and LENY, the lengths of the vectors x and y, and set */
205 /* up the start points in X and Y. */
206
207 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
208 lenx = *n;
209 leny = *m;
210 } else {
211 lenx = *m;
212 leny = *n;
213 }
214 if (*incx > 0) {
215 kx = 1;
216 } else {
217 kx = 1 - (lenx - 1) * *incx;
218 }
219 if (*incy > 0) {
220 ky = 1;
221 } else {
222 ky = 1 - (leny - 1) * *incy;
223 }
224
225 /* Start the operations. In this version the elements of A are */
226 /* accessed sequentially with one pass through the band part of A. */
227
228 /* First form y := beta*y. */
229
230 if (beta->r != 1. || beta->i != 0.) {
231 if (*incy == 1) {
232 if (beta->r == 0. && beta->i == 0.) {
233 i__1 = leny;
234 for (i__ = 1; i__ <= i__1; ++i__) {
235 i__2 = i__;
236 y[i__2].r = 0., y[i__2].i = 0.;
237 /* L10: */
238 }
239 } else {
240 i__1 = leny;
241 for (i__ = 1; i__ <= i__1; ++i__) {
242 i__2 = i__;
243 i__3 = i__;
244 z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
245 z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
246 .r;
247 y[i__2].r = z__1.r, y[i__2].i = z__1.i;
248 /* L20: */
249 }
250 }
251 } else {
252 iy = ky;
253 if (beta->r == 0. && beta->i == 0.) {
254 i__1 = leny;
255 for (i__ = 1; i__ <= i__1; ++i__) {
256 i__2 = iy;
257 y[i__2].r = 0., y[i__2].i = 0.;
258 iy += *incy;
259 /* L30: */
260 }
261 } else {
262 i__1 = leny;
263 for (i__ = 1; i__ <= i__1; ++i__) {
264 i__2 = iy;
265 i__3 = iy;
266 z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
267 z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
268 .r;
269 y[i__2].r = z__1.r, y[i__2].i = z__1.i;
270 iy += *incy;
271 /* L40: */
272 }
273 }
274 }
275 }
276 if (alpha->r == 0. && alpha->i == 0.) {
277 return 0;
278 }
279 kup1 = *ku + 1;
280 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
281
282 /* Form y := alpha*A*x + y. */
283
284 jx = kx;
285 if (*incy == 1) {
286 i__1 = *n;
287 for (j = 1; j <= i__1; ++j) {
288 i__2 = jx;
289 if (x[i__2].r != 0. || x[i__2].i != 0.) {
290 i__2 = jx;
291 z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
292 z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
293 .r;
294 temp.r = z__1.r, temp.i = z__1.i;
295 k = kup1 - j;
296 /* Computing MAX */
297 i__2 = 1, i__3 = j - *ku;
298 /* Computing MIN */
299 i__5 = *m, i__6 = j + *kl;
300 i__4 = min(i__5,i__6);
301 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
302 i__2 = i__;
303 i__3 = i__;
304 i__5 = k + i__ + j * a_dim1;
305 z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
306 z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
307 .r;
308 z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i +
309 z__2.i;
310 y[i__2].r = z__1.r, y[i__2].i = z__1.i;
311 /* L50: */
312 }
313 }
314 jx += *incx;
315 /* L60: */
316 }
317 } else {
318 i__1 = *n;
319 for (j = 1; j <= i__1; ++j) {
320 i__4 = jx;
321 if (x[i__4].r != 0. || x[i__4].i != 0.) {
322 i__4 = jx;
323 z__1.r = alpha->r * x[i__4].r - alpha->i * x[i__4].i,
324 z__1.i = alpha->r * x[i__4].i + alpha->i * x[i__4]
325 .r;
326 temp.r = z__1.r, temp.i = z__1.i;
327 iy = ky;
328 k = kup1 - j;
329 /* Computing MAX */
330 i__4 = 1, i__2 = j - *ku;
331 /* Computing MIN */
332 i__5 = *m, i__6 = j + *kl;
333 i__3 = min(i__5,i__6);
334 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
335 i__4 = iy;
336 i__2 = iy;
337 i__5 = k + i__ + j * a_dim1;
338 z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
339 z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
340 .r;
341 z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i +
342 z__2.i;
343 y[i__4].r = z__1.r, y[i__4].i = z__1.i;
344 iy += *incy;
345 /* L70: */
346 }
347 }
348 jx += *incx;
349 if (j > *ku) {
350 ky += *incy;
351 }
352 /* L80: */
353 }
354 }
355 } else {
356
357 /* Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. */
358
359 jy = ky;
360 if (*incx == 1) {
361 i__1 = *n;
362 for (j = 1; j <= i__1; ++j) {
363 temp.r = 0., temp.i = 0.;
364 k = kup1 - j;
365 if (noconj) {
366 /* Computing MAX */
367 i__3 = 1, i__4 = j - *ku;
368 /* Computing MIN */
369 i__5 = *m, i__6 = j + *kl;
370 i__2 = min(i__5,i__6);
371 for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
372 i__3 = k + i__ + j * a_dim1;
373 i__4 = i__;
374 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
375 .i, z__2.i = a[i__3].r * x[i__4].i + a[i__3]
376 .i * x[i__4].r;
377 z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
378 temp.r = z__1.r, temp.i = z__1.i;
379 /* L90: */
380 }
381 } else {
382 /* Computing MAX */
383 i__2 = 1, i__3 = j - *ku;
384 /* Computing MIN */
385 i__5 = *m, i__6 = j + *kl;
386 i__4 = min(i__5,i__6);
387 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
388 d_cnjg(&z__3, &a[k + i__ + j * a_dim1]);
389 i__2 = i__;
390 z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i,
391 z__2.i = z__3.r * x[i__2].i + z__3.i * x[i__2]
392 .r;
393 z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
394 temp.r = z__1.r, temp.i = z__1.i;
395 /* L100: */
396 }
397 }
398 i__4 = jy;
399 i__2 = jy;
400 z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i =
401 alpha->r * temp.i + alpha->i * temp.r;
402 z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + z__2.i;
403 y[i__4].r = z__1.r, y[i__4].i = z__1.i;
404 jy += *incy;
405 /* L110: */
406 }
407 } else {
408 i__1 = *n;
409 for (j = 1; j <= i__1; ++j) {
410 temp.r = 0., temp.i = 0.;
411 ix = kx;
412 k = kup1 - j;
413 if (noconj) {
414 /* Computing MAX */
415 i__4 = 1, i__2 = j - *ku;
416 /* Computing MIN */
417 i__5 = *m, i__6 = j + *kl;
418 i__3 = min(i__5,i__6);
419 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
420 i__4 = k + i__ + j * a_dim1;
421 i__2 = ix;
422 z__2.r = a[i__4].r * x[i__2].r - a[i__4].i * x[i__2]
423 .i, z__2.i = a[i__4].r * x[i__2].i + a[i__4]
424 .i * x[i__2].r;
425 z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
426 temp.r = z__1.r, temp.i = z__1.i;
427 ix += *incx;
428 /* L120: */
429 }
430 } else {
431 /* Computing MAX */
432 i__3 = 1, i__4 = j - *ku;
433 /* Computing MIN */
434 i__5 = *m, i__6 = j + *kl;
435 i__2 = min(i__5,i__6);
436 for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
437 d_cnjg(&z__3, &a[k + i__ + j * a_dim1]);
438 i__3 = ix;
439 z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
440 z__2.i = z__3.r * x[i__3].i + z__3.i * x[i__3]
441 .r;
442 z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
443 temp.r = z__1.r, temp.i = z__1.i;
444 ix += *incx;
445 /* L130: */
446 }
447 }
448 i__2 = jy;
449 i__3 = jy;
450 z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i =
451 alpha->r * temp.i + alpha->i * temp.r;
452 z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
453 y[i__2].r = z__1.r, y[i__2].i = z__1.i;
454 jy += *incy;
455 if (j > *ku) {
456 kx += *incx;
457 }
458 /* L140: */
459 }
460 }
461 }
462
463 return 0;
464
465 /* End of ZGBMV . */
466
467 } /* zgbmv_ */
468