Debian Codegraph @

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

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