Debian Codegraph @

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

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