Debian Codegraph @

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

raw
1 /* ./src_f77/dsyrk.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 dsyrk_(char *uplo, char *trans, integer *n, integer *k,
9 doublereal *alpha, doublereal *a, integer *lda, doublereal *beta,
10 doublereal *c__, 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;
14
15 /* Local variables */
16 static integer i__, j, l, info;
17 static doublereal temp;
18 extern logical lsame_(char *, char *, ftnlen, ftnlen);
19 static integer nrowa;
20 static logical upper;
21 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
22
23 /* .. Scalar Arguments .. */
24 /* .. Array Arguments .. */
25 /* .. */
26
27 /* Purpose */
28 /* ======= */
29
30 /* DSYRK performs one of the symmetric rank k operations */
31
32 /* C := alpha*A*A' + beta*C, */
33
34 /* or */
35
36 /* C := alpha*A'*A + beta*C, */
37
38 /* where alpha and beta are scalars, C is an n by n symmetric matrix */
39 /* and A is an n by k matrix in the first case and a k by n matrix */
40 /* in the second case. */
41
42 /* Parameters */
43 /* ========== */
44
45 /* UPLO - CHARACTER*1. */
46 /* On entry, UPLO specifies whether the upper or lower */
47 /* triangular part of the array C is to be referenced as */
48 /* follows: */
49
50 /* UPLO = 'U' or 'u' Only the upper triangular part of C */
51 /* is to be referenced. */
52
53 /* UPLO = 'L' or 'l' Only the lower triangular part of C */
54 /* is to be referenced. */
55
56 /* Unchanged on exit. */
57
58 /* TRANS - CHARACTER*1. */
59 /* On entry, TRANS specifies the operation to be performed as */
60 /* follows: */
61
62 /* TRANS = 'N' or 'n' C := alpha*A*A' + beta*C. */
63
64 /* TRANS = 'T' or 't' C := alpha*A'*A + beta*C. */
65
66 /* TRANS = 'C' or 'c' 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' or 'C' or 'c', K specifies the number */
79 /* of rows of the matrix A. K must be at least zero. */
80 /* Unchanged on exit. */
81
82 /* ALPHA - DOUBLE PRECISION. */
83 /* On entry, ALPHA specifies the scalar alpha. */
84 /* Unchanged on exit. */
85
86 /* A - DOUBLE PRECISION 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 - DOUBLE PRECISION. */
102 /* On entry, BETA specifies the scalar beta. */
103 /* Unchanged on exit. */
104
105 /* C - DOUBLE PRECISION 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) && ! lsame_(trans, "C", (ftnlen)1, (
166 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_("DSYRK ", &info, (ftnlen)6);
179 return 0;
180 }
181
182 /* Quick return if possible. */
183
184 if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
185 return 0;
186 }
187
188 /* And when alpha.eq.zero. */
189
190 if (*alpha == 0.) {
191 if (upper) {
192 if (*beta == 0.) {
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 c__[i__ + j * c_dim1] = 0.;
198 /* L10: */
199 }
200 /* L20: */
201 }
202 } else {
203 i__1 = *n;
204 for (j = 1; j <= i__1; ++j) {
205 i__2 = j;
206 for (i__ = 1; i__ <= i__2; ++i__) {
207 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
208 /* L30: */
209 }
210 /* L40: */
211 }
212 }
213 } else {
214 if (*beta == 0.) {
215 i__1 = *n;
216 for (j = 1; j <= i__1; ++j) {
217 i__2 = *n;
218 for (i__ = j; i__ <= i__2; ++i__) {
219 c__[i__ + j * c_dim1] = 0.;
220 /* L50: */
221 }
222 /* L60: */
223 }
224 } else {
225 i__1 = *n;
226 for (j = 1; j <= i__1; ++j) {
227 i__2 = *n;
228 for (i__ = j; i__ <= i__2; ++i__) {
229 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
230 /* L70: */
231 }
232 /* L80: */
233 }
234 }
235 }
236 return 0;
237 }
238
239 /* Start the operations. */
240
241 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
242
243 /* Form C := alpha*A*A' + beta*C. */
244
245 if (upper) {
246 i__1 = *n;
247 for (j = 1; j <= i__1; ++j) {
248 if (*beta == 0.) {
249 i__2 = j;
250 for (i__ = 1; i__ <= i__2; ++i__) {
251 c__[i__ + j * c_dim1] = 0.;
252 /* L90: */
253 }
254 } else if (*beta != 1.) {
255 i__2 = j;
256 for (i__ = 1; i__ <= i__2; ++i__) {
257 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
258 /* L100: */
259 }
260 }
261 i__2 = *k;
262 for (l = 1; l <= i__2; ++l) {
263 if (a[j + l * a_dim1] != 0.) {
264 temp = *alpha * a[j + l * a_dim1];
265 i__3 = j;
266 for (i__ = 1; i__ <= i__3; ++i__) {
267 c__[i__ + j * c_dim1] += temp * a[i__ + l *
268 a_dim1];
269 /* L110: */
270 }
271 }
272 /* L120: */
273 }
274 /* L130: */
275 }
276 } else {
277 i__1 = *n;
278 for (j = 1; j <= i__1; ++j) {
279 if (*beta == 0.) {
280 i__2 = *n;
281 for (i__ = j; i__ <= i__2; ++i__) {
282 c__[i__ + j * c_dim1] = 0.;
283 /* L140: */
284 }
285 } else if (*beta != 1.) {
286 i__2 = *n;
287 for (i__ = j; i__ <= i__2; ++i__) {
288 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
289 /* L150: */
290 }
291 }
292 i__2 = *k;
293 for (l = 1; l <= i__2; ++l) {
294 if (a[j + l * a_dim1] != 0.) {
295 temp = *alpha * a[j + l * a_dim1];
296 i__3 = *n;
297 for (i__ = j; i__ <= i__3; ++i__) {
298 c__[i__ + j * c_dim1] += temp * a[i__ + l *
299 a_dim1];
300 /* L160: */
301 }
302 }
303 /* L170: */
304 }
305 /* L180: */
306 }
307 }
308 } else {
309
310 /* Form C := alpha*A'*A + beta*C. */
311
312 if (upper) {
313 i__1 = *n;
314 for (j = 1; j <= i__1; ++j) {
315 i__2 = j;
316 for (i__ = 1; i__ <= i__2; ++i__) {
317 temp = 0.;
318 i__3 = *k;
319 for (l = 1; l <= i__3; ++l) {
320 temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
321 /* L190: */
322 }
323 if (*beta == 0.) {
324 c__[i__ + j * c_dim1] = *alpha * temp;
325 } else {
326 c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
327 i__ + j * c_dim1];
328 }
329 /* L200: */
330 }
331 /* L210: */
332 }
333 } else {
334 i__1 = *n;
335 for (j = 1; j <= i__1; ++j) {
336 i__2 = *n;
337 for (i__ = j; i__ <= i__2; ++i__) {
338 temp = 0.;
339 i__3 = *k;
340 for (l = 1; l <= i__3; ++l) {
341 temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
342 /* L220: */
343 }
344 if (*beta == 0.) {
345 c__[i__ + j * c_dim1] = *alpha * temp;
346 } else {
347 c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
348 i__ + j * c_dim1];
349 }
350 /* L230: */
351 }
352 /* L240: */
353 }
354 }
355 }
356
357 return 0;
358
359 /* End of DSYRK . */
360
361 } /* dsyrk_ */
362