Debian Codegraph @

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

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