3 /* Subroutine */ int dsyr2k_(char *uplo, char *trans, integer *n, integer *k,
4 doublereal *alpha, doublereal *a, integer *lda, doublereal *b,
5 integer *ldb, doublereal *beta, doublereal *c__, integer *ldc)
7 /* System generated locals */
8 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
12 integer i__, j, l, info;
13 doublereal temp1, temp2;
14 extern logical lsame_(char *, char *);
17 extern /* Subroutine */ int xerbla_(char *, integer *);
19 /* .. Scalar Arguments .. */
21 /* .. Array Arguments .. */
27 /* DSYR2K performs one of the symmetric rank 2k operations */
29 /* C := alpha*A*B' + alpha*B*A' + beta*C, */
33 /* C := alpha*A'*B + alpha*B'*A + beta*C, */
35 /* where alpha and beta are scalars, C is an n by n symmetric matrix */
36 /* and A and B are n by k matrices in the first case and k by n */
37 /* matrices in the second case. */
42 /* UPLO - CHARACTER*1. */
43 /* On entry, UPLO specifies whether the upper or lower */
44 /* triangular part of the array C is to be referenced as */
47 /* UPLO = 'U' or 'u' Only the upper triangular part of C */
48 /* is to be referenced. */
50 /* UPLO = 'L' or 'l' Only the lower triangular part of C */
51 /* is to be referenced. */
53 /* Unchanged on exit. */
55 /* TRANS - CHARACTER*1. */
56 /* On entry, TRANS specifies the operation to be performed as */
59 /* TRANS = 'N' or 'n' C := alpha*A*B' + alpha*B*A' + */
62 /* TRANS = 'T' or 't' C := alpha*A'*B + alpha*B'*A + */
65 /* TRANS = 'C' or 'c' C := alpha*A'*B + alpha*B'*A + */
68 /* Unchanged on exit. */
71 /* On entry, N specifies the order of the matrix C. N must be */
73 /* Unchanged on exit. */
76 /* On entry with TRANS = 'N' or 'n', K specifies the number */
77 /* of columns of the matrices A and B, and on entry with */
78 /* TRANS = 'T' or 't' or 'C' or 'c', K specifies the number */
79 /* of rows of the matrices A and B. K must be at least zero. */
80 /* Unchanged on exit. */
82 /* ALPHA - DOUBLE PRECISION. */
83 /* On entry, ALPHA specifies the scalar alpha. */
84 /* Unchanged on exit. */
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 */
92 /* Unchanged on exit. */
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. */
101 /* B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is */
102 /* k when TRANS = 'N' or 'n', and is n otherwise. */
103 /* Before entry with TRANS = 'N' or 'n', the leading n by k */
104 /* part of the array B must contain the matrix B, otherwise */
105 /* the leading k by n part of the array B must contain the */
107 /* Unchanged on exit. */
110 /* On entry, LDB specifies the first dimension of B as declared */
111 /* in the calling (sub) program. When TRANS = 'N' or 'n' */
112 /* then LDB must be at least max( 1, n ), otherwise LDB must */
113 /* be at least max( 1, k ). */
114 /* Unchanged on exit. */
116 /* BETA - DOUBLE PRECISION. */
117 /* On entry, BETA specifies the scalar beta. */
118 /* Unchanged on exit. */
120 /* C - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */
121 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
122 /* upper triangular part of the array C must contain the upper */
123 /* triangular part of the symmetric matrix and the strictly */
124 /* lower triangular part of C is not referenced. On exit, the */
125 /* upper triangular part of the array C is overwritten by the */
126 /* upper triangular part of the updated matrix. */
127 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
128 /* lower triangular part of the array C must contain the lower */
129 /* triangular part of the symmetric matrix and the strictly */
130 /* upper triangular part of C is not referenced. On exit, the */
131 /* lower triangular part of the array C is overwritten by the */
132 /* lower triangular part of the updated matrix. */
135 /* On entry, LDC specifies the first dimension of C as declared */
136 /* in the calling (sub) program. LDC must be at least */
138 /* Unchanged on exit. */
141 /* Level 3 Blas routine. */
144 /* -- Written on 8-February-1989. */
145 /* Jack Dongarra, Argonne National Laboratory. */
146 /* Iain Duff, AERE Harwell. */
147 /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
148 /* Sven Hammarling, Numerical Algorithms Group Ltd. */
151 /* .. External Functions .. */
153 /* .. External Subroutines .. */
155 /* .. Intrinsic Functions .. */
157 /* .. Local Scalars .. */
159 /* .. Parameters .. */
162 /* Test the input parameters. */
164 /* Parameter adjustments */
166 a_offset = 1 + a_dim1;
169 b_offset = 1 + b_dim1;
172 c_offset = 1 + c_dim1;
176 if (lsame_(trans, "N")) {
181 upper = lsame_(uplo, "U");
184 if (! upper && ! lsame_(uplo, "L")) {
186 } else if (! lsame_(trans, "N") && ! lsame_(trans,
187 "T") && ! lsame_(trans, "C")) {
193 } else if (*lda < max(1,nrowa)) {
195 } else if (*ldb < max(1,nrowa)) {
197 } else if (*ldc < max(1,*n)) {
201 xerbla_("DSYR2K", &info);
205 /* Quick return if possible. */
207 if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
211 /* And when alpha.eq.zero. */
217 for (j = 1; j <= i__1; ++j) {
219 for (i__ = 1; i__ <= i__2; ++i__) {
220 c__[i__ + j * c_dim1] = 0.;
227 for (j = 1; j <= i__1; ++j) {
229 for (i__ = 1; i__ <= i__2; ++i__) {
230 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
239 for (j = 1; j <= i__1; ++j) {
241 for (i__ = j; i__ <= i__2; ++i__) {
242 c__[i__ + j * c_dim1] = 0.;
249 for (j = 1; j <= i__1; ++j) {
251 for (i__ = j; i__ <= i__2; ++i__) {
252 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
262 /* Start the operations. */
264 if (lsame_(trans, "N")) {
266 /* Form C := alpha*A*B' + alpha*B*A' + C. */
270 for (j = 1; j <= i__1; ++j) {
273 for (i__ = 1; i__ <= i__2; ++i__) {
274 c__[i__ + j * c_dim1] = 0.;
277 } else if (*beta != 1.) {
279 for (i__ = 1; i__ <= i__2; ++i__) {
280 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
285 for (l = 1; l <= i__2; ++l) {
286 if (a[j + l * a_dim1] != 0. || b[j + l * b_dim1] != 0.) {
287 temp1 = *alpha * b[j + l * b_dim1];
288 temp2 = *alpha * a[j + l * a_dim1];
290 for (i__ = 1; i__ <= i__3; ++i__) {
291 c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
292 i__ + l * a_dim1] * temp1 + b[i__ + l *
303 for (j = 1; j <= i__1; ++j) {
306 for (i__ = j; i__ <= i__2; ++i__) {
307 c__[i__ + j * c_dim1] = 0.;
310 } else if (*beta != 1.) {
312 for (i__ = j; i__ <= i__2; ++i__) {
313 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
318 for (l = 1; l <= i__2; ++l) {
319 if (a[j + l * a_dim1] != 0. || b[j + l * b_dim1] != 0.) {
320 temp1 = *alpha * b[j + l * b_dim1];
321 temp2 = *alpha * a[j + l * a_dim1];
323 for (i__ = j; i__ <= i__3; ++i__) {
324 c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
325 i__ + l * a_dim1] * temp1 + b[i__ + l *
337 /* Form C := alpha*A'*B + alpha*B'*A + C. */
341 for (j = 1; j <= i__1; ++j) {
343 for (i__ = 1; i__ <= i__2; ++i__) {
347 for (l = 1; l <= i__3; ++l) {
348 temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
349 temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
353 c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
356 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
357 + *alpha * temp1 + *alpha * temp2;
365 for (j = 1; j <= i__1; ++j) {
367 for (i__ = j; i__ <= i__2; ++i__) {
371 for (l = 1; l <= i__3; ++l) {
372 temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
373 temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
377 c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
380 c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
381 + *alpha * temp1 + *alpha * temp2;