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