Debian Codegraph @

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

raw
1 /* ./src_f77/zsyr2k.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 zsyr2k_(char *uplo, char *trans, integer *n, integer *k,
9 doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
10 b, integer *ldb, doublecomplex *beta, doublecomplex *c__, integer *
11 ldc, ftnlen uplo_len, ftnlen trans_len)
12 {
13 /* System generated locals */
14 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
15 i__3, i__4, i__5, i__6, i__7;
16 doublecomplex z__1, z__2, z__3, z__4, z__5;
17
18 /* Local variables */
19 static integer i__, j, l, info;
20 static doublecomplex temp1, temp2;
21 extern logical lsame_(char *, char *, ftnlen, ftnlen);
22 static integer nrowa;
23 static logical upper;
24 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
25
26 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
28 /* .. */
29
30 /* Purpose */
31 /* ======= */
32
33 /* ZSYR2K performs one of the symmetric rank 2k operations */
34
35 /* C := alpha*A*B' + alpha*B*A' + beta*C, */
36
37 /* or */
38
39 /* C := alpha*A'*B + alpha*B'*A + beta*C, */
40
41 /* where alpha and beta are scalars, C is an n by n symmetric matrix */
42 /* and A and B are n by k matrices in the first case and k by n */
43 /* matrices in the second case. */
44
45 /* Parameters */
46 /* ========== */
47
48 /* UPLO - CHARACTER*1. */
49 /* On entry, UPLO specifies whether the upper or lower */
50 /* triangular part of the array C is to be referenced as */
51 /* follows: */
52
53 /* UPLO = 'U' or 'u' Only the upper triangular part of C */
54 /* is to be referenced. */
55
56 /* UPLO = 'L' or 'l' Only the lower triangular part of C */
57 /* is to be referenced. */
58
59 /* Unchanged on exit. */
60
61 /* TRANS - CHARACTER*1. */
62 /* On entry, TRANS specifies the operation to be performed as */
63 /* follows: */
64
65 /* TRANS = 'N' or 'n' C := alpha*A*B' + alpha*B*A' + */
66 /* beta*C. */
67
68 /* TRANS = 'T' or 't' C := alpha*A'*B + alpha*B'*A + */
69 /* beta*C. */
70
71 /* Unchanged on exit. */
72
73 /* N - INTEGER. */
74 /* On entry, N specifies the order of the matrix C. N must be */
75 /* at least zero. */
76 /* Unchanged on exit. */
77
78 /* K - INTEGER. */
79 /* On entry with TRANS = 'N' or 'n', K specifies the number */
80 /* of columns of the matrices A and B, and on entry with */
81 /* TRANS = 'T' or 't', K specifies the number of rows of the */
82 /* matrices A and B. K must be at least zero. */
83 /* Unchanged on exit. */
84
85 /* ALPHA - COMPLEX*16 . */
86 /* On entry, ALPHA specifies the scalar alpha. */
87 /* Unchanged on exit. */
88
89 /* A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is */
90 /* k when TRANS = 'N' or 'n', and is n otherwise. */
91 /* Before entry with TRANS = 'N' or 'n', the leading n by k */
92 /* part of the array A must contain the matrix A, otherwise */
93 /* the leading k by n part of the array A must contain the */
94 /* matrix A. */
95 /* Unchanged on exit. */
96
97 /* LDA - INTEGER. */
98 /* On entry, LDA specifies the first dimension of A as declared */
99 /* in the calling (sub) program. When TRANS = 'N' or 'n' */
100 /* then LDA must be at least max( 1, n ), otherwise LDA must */
101 /* be at least max( 1, k ). */
102 /* Unchanged on exit. */
103
104 /* B - COMPLEX*16 array of DIMENSION ( LDB, kb ), where kb is */
105 /* k when TRANS = 'N' or 'n', and is n otherwise. */
106 /* Before entry with TRANS = 'N' or 'n', the leading n by k */
107 /* part of the array B must contain the matrix B, otherwise */
108 /* the leading k by n part of the array B must contain the */
109 /* matrix B. */
110 /* Unchanged on exit. */
111
112 /* LDB - INTEGER. */
113 /* On entry, LDB specifies the first dimension of B as declared */
114 /* in the calling (sub) program. When TRANS = 'N' or 'n' */
115 /* then LDB must be at least max( 1, n ), otherwise LDB must */
116 /* be at least max( 1, k ). */
117 /* Unchanged on exit. */
118
119 /* BETA - COMPLEX*16 . */
120 /* On entry, BETA specifies the scalar beta. */
121 /* Unchanged on exit. */
122
123 /* C - COMPLEX*16 array of DIMENSION ( LDC, n ). */
124 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
125 /* upper triangular part of the array C must contain the upper */
126 /* triangular part of the symmetric matrix and the strictly */
127 /* lower triangular part of C is not referenced. On exit, the */
128 /* upper triangular part of the array C is overwritten by the */
129 /* upper triangular part of the updated matrix. */
130 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
131 /* lower triangular part of the array C must contain the lower */
132 /* triangular part of the symmetric matrix and the strictly */
133 /* upper triangular part of C is not referenced. On exit, the */
134 /* lower triangular part of the array C is overwritten by the */
135 /* lower triangular part of the updated matrix. */
136
137 /* LDC - INTEGER. */
138 /* On entry, LDC specifies the first dimension of C as declared */
139 /* in the calling (sub) program. LDC must be at least */
140 /* max( 1, n ). */
141 /* Unchanged on exit. */
142
143
144 /* Level 3 Blas routine. */
145
146 /* -- Written on 8-February-1989. */
147 /* Jack Dongarra, Argonne National Laboratory. */
148 /* Iain Duff, AERE Harwell. */
149 /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
150 /* Sven Hammarling, Numerical Algorithms Group Ltd. */
151
152
153 /* .. External Functions .. */
154 /* .. External Subroutines .. */
155 /* .. Intrinsic Functions .. */
156 /* .. Local Scalars .. */
157 /* .. Parameters .. */
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 b_dim1 = *ldb;
168 b_offset = 1 + b_dim1;
169 b -= b_offset;
170 c_dim1 = *ldc;
171 c_offset = 1 + c_dim1;
172 c__ -= c_offset;
173
174 /* Function Body */
175 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
176 nrowa = *n;
177 } else {
178 nrowa = *k;
179 }
180 upper = lsame_(uplo, "U", (ftnlen)1, (ftnlen)1);
181
182 info = 0;
183 if (! upper && ! lsame_(uplo, "L", (ftnlen)1, (ftnlen)1)) {
184 info = 1;
185 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
186 "T", (ftnlen)1, (ftnlen)1)) {
187 info = 2;
188 } else if (*n < 0) {
189 info = 3;
190 } else if (*k < 0) {
191 info = 4;
192 } else if (*lda < max(1,nrowa)) {
193 info = 7;
194 } else if (*ldb < max(1,nrowa)) {
195 info = 9;
196 } else if (*ldc < max(1,*n)) {
197 info = 12;
198 }
199 if (info != 0) {
200 xerbla_("ZSYR2K", &info, (ftnlen)6);
201 return 0;
202 }
203
204 /* Quick return if possible. */
205
206 if (*n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) && (beta->r
207 == 1. && beta->i == 0.)) {
208 return 0;
209 }
210
211 /* And when alpha.eq.zero. */
212
213 if (alpha->r == 0. && alpha->i == 0.) {
214 if (upper) {
215 if (beta->r == 0. && beta->i == 0.) {
216 i__1 = *n;
217 for (j = 1; j <= i__1; ++j) {
218 i__2 = j;
219 for (i__ = 1; i__ <= i__2; ++i__) {
220 i__3 = i__ + j * c_dim1;
221 c__[i__3].r = 0., c__[i__3].i = 0.;
222 /* L10: */
223 }
224 /* L20: */
225 }
226 } else {
227 i__1 = *n;
228 for (j = 1; j <= i__1; ++j) {
229 i__2 = j;
230 for (i__ = 1; i__ <= i__2; ++i__) {
231 i__3 = i__ + j * c_dim1;
232 i__4 = i__ + j * c_dim1;
233 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
234 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
235 c__[i__4].r;
236 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
237 /* L30: */
238 }
239 /* L40: */
240 }
241 }
242 } else {
243 if (beta->r == 0. && beta->i == 0.) {
244 i__1 = *n;
245 for (j = 1; j <= i__1; ++j) {
246 i__2 = *n;
247 for (i__ = j; i__ <= i__2; ++i__) {
248 i__3 = i__ + j * c_dim1;
249 c__[i__3].r = 0., c__[i__3].i = 0.;
250 /* L50: */
251 }
252 /* L60: */
253 }
254 } else {
255 i__1 = *n;
256 for (j = 1; j <= i__1; ++j) {
257 i__2 = *n;
258 for (i__ = j; i__ <= i__2; ++i__) {
259 i__3 = i__ + j * c_dim1;
260 i__4 = i__ + j * c_dim1;
261 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
262 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
263 c__[i__4].r;
264 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
265 /* L70: */
266 }
267 /* L80: */
268 }
269 }
270 }
271 return 0;
272 }
273
274 /* Start the operations. */
275
276 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
277
278 /* Form C := alpha*A*B' + alpha*B*A' + C. */
279
280 if (upper) {
281 i__1 = *n;
282 for (j = 1; j <= i__1; ++j) {
283 if (beta->r == 0. && beta->i == 0.) {
284 i__2 = j;
285 for (i__ = 1; i__ <= i__2; ++i__) {
286 i__3 = i__ + j * c_dim1;
287 c__[i__3].r = 0., c__[i__3].i = 0.;
288 /* L90: */
289 }
290 } else if (beta->r != 1. || beta->i != 0.) {
291 i__2 = j;
292 for (i__ = 1; i__ <= i__2; ++i__) {
293 i__3 = i__ + j * c_dim1;
294 i__4 = i__ + j * c_dim1;
295 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
296 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
297 c__[i__4].r;
298 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
299 /* L100: */
300 }
301 }
302 i__2 = *k;
303 for (l = 1; l <= i__2; ++l) {
304 i__3 = j + l * a_dim1;
305 i__4 = j + l * b_dim1;
306 if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
307 0. || b[i__4].i != 0.)) {
308 i__3 = j + l * b_dim1;
309 z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
310 z__1.i = alpha->r * b[i__3].i + alpha->i * b[
311 i__3].r;
312 temp1.r = z__1.r, temp1.i = z__1.i;
313 i__3 = j + l * a_dim1;
314 z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
315 z__1.i = alpha->r * a[i__3].i + alpha->i * a[
316 i__3].r;
317 temp2.r = z__1.r, temp2.i = z__1.i;
318 i__3 = j;
319 for (i__ = 1; i__ <= i__3; ++i__) {
320 i__4 = i__ + j * c_dim1;
321 i__5 = i__ + j * c_dim1;
322 i__6 = i__ + l * a_dim1;
323 z__3.r = a[i__6].r * temp1.r - a[i__6].i *
324 temp1.i, z__3.i = a[i__6].r * temp1.i + a[
325 i__6].i * temp1.r;
326 z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
327 .i + z__3.i;
328 i__7 = i__ + l * b_dim1;
329 z__4.r = b[i__7].r * temp2.r - b[i__7].i *
330 temp2.i, z__4.i = b[i__7].r * temp2.i + b[
331 i__7].i * temp2.r;
332 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
333 z__4.i;
334 c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
335 /* L110: */
336 }
337 }
338 /* L120: */
339 }
340 /* L130: */
341 }
342 } else {
343 i__1 = *n;
344 for (j = 1; j <= i__1; ++j) {
345 if (beta->r == 0. && beta->i == 0.) {
346 i__2 = *n;
347 for (i__ = j; i__ <= i__2; ++i__) {
348 i__3 = i__ + j * c_dim1;
349 c__[i__3].r = 0., c__[i__3].i = 0.;
350 /* L140: */
351 }
352 } else if (beta->r != 1. || beta->i != 0.) {
353 i__2 = *n;
354 for (i__ = j; i__ <= i__2; ++i__) {
355 i__3 = i__ + j * c_dim1;
356 i__4 = i__ + j * c_dim1;
357 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
358 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
359 c__[i__4].r;
360 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
361 /* L150: */
362 }
363 }
364 i__2 = *k;
365 for (l = 1; l <= i__2; ++l) {
366 i__3 = j + l * a_dim1;
367 i__4 = j + l * b_dim1;
368 if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
369 0. || b[i__4].i != 0.)) {
370 i__3 = j + l * b_dim1;
371 z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
372 z__1.i = alpha->r * b[i__3].i + alpha->i * b[
373 i__3].r;
374 temp1.r = z__1.r, temp1.i = z__1.i;
375 i__3 = j + l * a_dim1;
376 z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
377 z__1.i = alpha->r * a[i__3].i + alpha->i * a[
378 i__3].r;
379 temp2.r = z__1.r, temp2.i = z__1.i;
380 i__3 = *n;
381 for (i__ = j; i__ <= i__3; ++i__) {
382 i__4 = i__ + j * c_dim1;
383 i__5 = i__ + j * c_dim1;
384 i__6 = i__ + l * a_dim1;
385 z__3.r = a[i__6].r * temp1.r - a[i__6].i *
386 temp1.i, z__3.i = a[i__6].r * temp1.i + a[
387 i__6].i * temp1.r;
388 z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
389 .i + z__3.i;
390 i__7 = i__ + l * b_dim1;
391 z__4.r = b[i__7].r * temp2.r - b[i__7].i *
392 temp2.i, z__4.i = b[i__7].r * temp2.i + b[
393 i__7].i * temp2.r;
394 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
395 z__4.i;
396 c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
397 /* L160: */
398 }
399 }
400 /* L170: */
401 }
402 /* L180: */
403 }
404 }
405 } else {
406
407 /* Form C := alpha*A'*B + alpha*B'*A + C. */
408
409 if (upper) {
410 i__1 = *n;
411 for (j = 1; j <= i__1; ++j) {
412 i__2 = j;
413 for (i__ = 1; i__ <= i__2; ++i__) {
414 temp1.r = 0., temp1.i = 0.;
415 temp2.r = 0., temp2.i = 0.;
416 i__3 = *k;
417 for (l = 1; l <= i__3; ++l) {
418 i__4 = l + i__ * a_dim1;
419 i__5 = l + j * b_dim1;
420 z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
421 .i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
422 .i * b[i__5].r;
423 z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
424 temp1.r = z__1.r, temp1.i = z__1.i;
425 i__4 = l + i__ * b_dim1;
426 i__5 = l + j * a_dim1;
427 z__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
428 .i, z__2.i = b[i__4].r * a[i__5].i + b[i__4]
429 .i * a[i__5].r;
430 z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
431 temp2.r = z__1.r, temp2.i = z__1.i;
432 /* L190: */
433 }
434 if (beta->r == 0. && beta->i == 0.) {
435 i__3 = i__ + j * c_dim1;
436 z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
437 z__2.i = alpha->r * temp1.i + alpha->i *
438 temp1.r;
439 z__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
440 z__3.i = alpha->r * temp2.i + alpha->i *
441 temp2.r;
442 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
443 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
444 } else {
445 i__3 = i__ + j * c_dim1;
446 i__4 = i__ + j * c_dim1;
447 z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
448 .i, z__3.i = beta->r * c__[i__4].i + beta->i *
449 c__[i__4].r;
450 z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
451 z__4.i = alpha->r * temp1.i + alpha->i *
452 temp1.r;
453 z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
454 z__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
455 z__5.i = alpha->r * temp2.i + alpha->i *
456 temp2.r;
457 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
458 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
459 }
460 /* L200: */
461 }
462 /* L210: */
463 }
464 } else {
465 i__1 = *n;
466 for (j = 1; j <= i__1; ++j) {
467 i__2 = *n;
468 for (i__ = j; i__ <= i__2; ++i__) {
469 temp1.r = 0., temp1.i = 0.;
470 temp2.r = 0., temp2.i = 0.;
471 i__3 = *k;
472 for (l = 1; l <= i__3; ++l) {
473 i__4 = l + i__ * a_dim1;
474 i__5 = l + j * b_dim1;
475 z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
476 .i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
477 .i * b[i__5].r;
478 z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
479 temp1.r = z__1.r, temp1.i = z__1.i;
480 i__4 = l + i__ * b_dim1;
481 i__5 = l + j * a_dim1;
482 z__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
483 .i, z__2.i = b[i__4].r * a[i__5].i + b[i__4]
484 .i * a[i__5].r;
485 z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
486 temp2.r = z__1.r, temp2.i = z__1.i;
487 /* L220: */
488 }
489 if (beta->r == 0. && beta->i == 0.) {
490 i__3 = i__ + j * c_dim1;
491 z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
492 z__2.i = alpha->r * temp1.i + alpha->i *
493 temp1.r;
494 z__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
495 z__3.i = alpha->r * temp2.i + alpha->i *
496 temp2.r;
497 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
498 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
499 } else {
500 i__3 = i__ + j * c_dim1;
501 i__4 = i__ + j * c_dim1;
502 z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
503 .i, z__3.i = beta->r * c__[i__4].i + beta->i *
504 c__[i__4].r;
505 z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
506 z__4.i = alpha->r * temp1.i + alpha->i *
507 temp1.r;
508 z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
509 z__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
510 z__5.i = alpha->r * temp2.i + alpha->i *
511 temp2.r;
512 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
513 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
514 }
515 /* L230: */
516 }
517 /* L240: */
518 }
519 }
520 }
521
522 return 0;
523
524 /* End of ZSYR2K. */
525
526 } /* zsyr2k_ */
527