Debian Codegraph @

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

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