Debian Codegraph @

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

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