Debian Codegraph @

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

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