Debian Codegraph @

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

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