Debian Codegraph @

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

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