00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int zsyr2k_(char *uplo, char *trans, integer *n, integer *k,
00017 doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
00018 b, integer *ldb, doublecomplex *beta, doublecomplex *c__, integer *
00019 ldc)
00020 {
00021
00022 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
00023 i__3, i__4, i__5, i__6, i__7;
00024 doublecomplex z__1, z__2, z__3, z__4, z__5;
00025
00026
00027 integer i__, j, l, info;
00028 doublecomplex temp1, temp2;
00029 extern logical lsame_(char *, char *);
00030 integer nrowa;
00031 logical upper;
00032 extern int xerbla_(char *, integer *);
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 a_dim1 = *lda;
00177 a_offset = 1 + a_dim1;
00178 a -= a_offset;
00179 b_dim1 = *ldb;
00180 b_offset = 1 + b_dim1;
00181 b -= b_offset;
00182 c_dim1 = *ldc;
00183 c_offset = 1 + c_dim1;
00184 c__ -= c_offset;
00185
00186
00187 if (lsame_(trans, "N")) {
00188 nrowa = *n;
00189 } else {
00190 nrowa = *k;
00191 }
00192 upper = lsame_(uplo, "U");
00193
00194 info = 0;
00195 if (! upper && ! lsame_(uplo, "L")) {
00196 info = 1;
00197 } else if (! lsame_(trans, "N") && ! lsame_(trans,
00198 "T")) {
00199 info = 2;
00200 } else if (*n < 0) {
00201 info = 3;
00202 } else if (*k < 0) {
00203 info = 4;
00204 } else if (*lda < max(1,nrowa)) {
00205 info = 7;
00206 } else if (*ldb < max(1,nrowa)) {
00207 info = 9;
00208 } else if (*ldc < max(1,*n)) {
00209 info = 12;
00210 }
00211 if (info != 0) {
00212 xerbla_("ZSYR2K", &info);
00213 return 0;
00214 }
00215
00216
00217
00218 if (*n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) && (beta->r
00219 == 1. && beta->i == 0.)) {
00220 return 0;
00221 }
00222
00223
00224
00225 if (alpha->r == 0. && alpha->i == 0.) {
00226 if (upper) {
00227 if (beta->r == 0. && beta->i == 0.) {
00228 i__1 = *n;
00229 for (j = 1; j <= i__1; ++j) {
00230 i__2 = j;
00231 for (i__ = 1; i__ <= i__2; ++i__) {
00232 i__3 = i__ + j * c_dim1;
00233 c__[i__3].r = 0., c__[i__3].i = 0.;
00234
00235 }
00236
00237 }
00238 } else {
00239 i__1 = *n;
00240 for (j = 1; j <= i__1; ++j) {
00241 i__2 = j;
00242 for (i__ = 1; i__ <= i__2; ++i__) {
00243 i__3 = i__ + j * c_dim1;
00244 i__4 = i__ + j * c_dim1;
00245 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00246 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
00247 c__[i__4].r;
00248 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00249
00250 }
00251
00252 }
00253 }
00254 } else {
00255 if (beta->r == 0. && beta->i == 0.) {
00256 i__1 = *n;
00257 for (j = 1; j <= i__1; ++j) {
00258 i__2 = *n;
00259 for (i__ = j; i__ <= i__2; ++i__) {
00260 i__3 = i__ + j * c_dim1;
00261 c__[i__3].r = 0., c__[i__3].i = 0.;
00262
00263 }
00264
00265 }
00266 } else {
00267 i__1 = *n;
00268 for (j = 1; j <= i__1; ++j) {
00269 i__2 = *n;
00270 for (i__ = j; i__ <= i__2; ++i__) {
00271 i__3 = i__ + j * c_dim1;
00272 i__4 = i__ + j * c_dim1;
00273 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00274 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
00275 c__[i__4].r;
00276 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00277
00278 }
00279
00280 }
00281 }
00282 }
00283 return 0;
00284 }
00285
00286
00287
00288 if (lsame_(trans, "N")) {
00289
00290
00291
00292 if (upper) {
00293 i__1 = *n;
00294 for (j = 1; j <= i__1; ++j) {
00295 if (beta->r == 0. && beta->i == 0.) {
00296 i__2 = j;
00297 for (i__ = 1; i__ <= i__2; ++i__) {
00298 i__3 = i__ + j * c_dim1;
00299 c__[i__3].r = 0., c__[i__3].i = 0.;
00300
00301 }
00302 } else if (beta->r != 1. || beta->i != 0.) {
00303 i__2 = j;
00304 for (i__ = 1; i__ <= i__2; ++i__) {
00305 i__3 = i__ + j * c_dim1;
00306 i__4 = i__ + j * c_dim1;
00307 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00308 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
00309 c__[i__4].r;
00310 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00311
00312 }
00313 }
00314 i__2 = *k;
00315 for (l = 1; l <= i__2; ++l) {
00316 i__3 = j + l * a_dim1;
00317 i__4 = j + l * b_dim1;
00318 if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
00319 0. || b[i__4].i != 0.)) {
00320 i__3 = j + l * b_dim1;
00321 z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
00322 z__1.i = alpha->r * b[i__3].i + alpha->i * b[
00323 i__3].r;
00324 temp1.r = z__1.r, temp1.i = z__1.i;
00325 i__3 = j + l * a_dim1;
00326 z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00327 z__1.i = alpha->r * a[i__3].i + alpha->i * a[
00328 i__3].r;
00329 temp2.r = z__1.r, temp2.i = z__1.i;
00330 i__3 = j;
00331 for (i__ = 1; i__ <= i__3; ++i__) {
00332 i__4 = i__ + j * c_dim1;
00333 i__5 = i__ + j * c_dim1;
00334 i__6 = i__ + l * a_dim1;
00335 z__3.r = a[i__6].r * temp1.r - a[i__6].i *
00336 temp1.i, z__3.i = a[i__6].r * temp1.i + a[
00337 i__6].i * temp1.r;
00338 z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
00339 .i + z__3.i;
00340 i__7 = i__ + l * b_dim1;
00341 z__4.r = b[i__7].r * temp2.r - b[i__7].i *
00342 temp2.i, z__4.i = b[i__7].r * temp2.i + b[
00343 i__7].i * temp2.r;
00344 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
00345 z__4.i;
00346 c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
00347
00348 }
00349 }
00350
00351 }
00352
00353 }
00354 } else {
00355 i__1 = *n;
00356 for (j = 1; j <= i__1; ++j) {
00357 if (beta->r == 0. && beta->i == 0.) {
00358 i__2 = *n;
00359 for (i__ = j; i__ <= i__2; ++i__) {
00360 i__3 = i__ + j * c_dim1;
00361 c__[i__3].r = 0., c__[i__3].i = 0.;
00362
00363 }
00364 } else if (beta->r != 1. || beta->i != 0.) {
00365 i__2 = *n;
00366 for (i__ = j; i__ <= i__2; ++i__) {
00367 i__3 = i__ + j * c_dim1;
00368 i__4 = i__ + j * c_dim1;
00369 z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00370 .i, z__1.i = beta->r * c__[i__4].i + beta->i *
00371 c__[i__4].r;
00372 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00373
00374 }
00375 }
00376 i__2 = *k;
00377 for (l = 1; l <= i__2; ++l) {
00378 i__3 = j + l * a_dim1;
00379 i__4 = j + l * b_dim1;
00380 if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
00381 0. || b[i__4].i != 0.)) {
00382 i__3 = j + l * b_dim1;
00383 z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
00384 z__1.i = alpha->r * b[i__3].i + alpha->i * b[
00385 i__3].r;
00386 temp1.r = z__1.r, temp1.i = z__1.i;
00387 i__3 = j + l * a_dim1;
00388 z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00389 z__1.i = alpha->r * a[i__3].i + alpha->i * a[
00390 i__3].r;
00391 temp2.r = z__1.r, temp2.i = z__1.i;
00392 i__3 = *n;
00393 for (i__ = j; i__ <= i__3; ++i__) {
00394 i__4 = i__ + j * c_dim1;
00395 i__5 = i__ + j * c_dim1;
00396 i__6 = i__ + l * a_dim1;
00397 z__3.r = a[i__6].r * temp1.r - a[i__6].i *
00398 temp1.i, z__3.i = a[i__6].r * temp1.i + a[
00399 i__6].i * temp1.r;
00400 z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
00401 .i + z__3.i;
00402 i__7 = i__ + l * b_dim1;
00403 z__4.r = b[i__7].r * temp2.r - b[i__7].i *
00404 temp2.i, z__4.i = b[i__7].r * temp2.i + b[
00405 i__7].i * temp2.r;
00406 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
00407 z__4.i;
00408 c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
00409
00410 }
00411 }
00412
00413 }
00414
00415 }
00416 }
00417 } else {
00418
00419
00420
00421 if (upper) {
00422 i__1 = *n;
00423 for (j = 1; j <= i__1; ++j) {
00424 i__2 = j;
00425 for (i__ = 1; i__ <= i__2; ++i__) {
00426 temp1.r = 0., temp1.i = 0.;
00427 temp2.r = 0., temp2.i = 0.;
00428 i__3 = *k;
00429 for (l = 1; l <= i__3; ++l) {
00430 i__4 = l + i__ * a_dim1;
00431 i__5 = l + j * b_dim1;
00432 z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
00433 .i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
00434 .i * b[i__5].r;
00435 z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
00436 temp1.r = z__1.r, temp1.i = z__1.i;
00437 i__4 = l + i__ * b_dim1;
00438 i__5 = l + j * a_dim1;
00439 z__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
00440 .i, z__2.i = b[i__4].r * a[i__5].i + b[i__4]
00441 .i * a[i__5].r;
00442 z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
00443 temp2.r = z__1.r, temp2.i = z__1.i;
00444
00445 }
00446 if (beta->r == 0. && beta->i == 0.) {
00447 i__3 = i__ + j * c_dim1;
00448 z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00449 z__2.i = alpha->r * temp1.i + alpha->i *
00450 temp1.r;
00451 z__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00452 z__3.i = alpha->r * temp2.i + alpha->i *
00453 temp2.r;
00454 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00455 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00456 } else {
00457 i__3 = i__ + j * c_dim1;
00458 i__4 = i__ + j * c_dim1;
00459 z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00460 .i, z__3.i = beta->r * c__[i__4].i + beta->i *
00461 c__[i__4].r;
00462 z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00463 z__4.i = alpha->r * temp1.i + alpha->i *
00464 temp1.r;
00465 z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
00466 z__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00467 z__5.i = alpha->r * temp2.i + alpha->i *
00468 temp2.r;
00469 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00470 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00471 }
00472
00473 }
00474
00475 }
00476 } else {
00477 i__1 = *n;
00478 for (j = 1; j <= i__1; ++j) {
00479 i__2 = *n;
00480 for (i__ = j; i__ <= i__2; ++i__) {
00481 temp1.r = 0., temp1.i = 0.;
00482 temp2.r = 0., temp2.i = 0.;
00483 i__3 = *k;
00484 for (l = 1; l <= i__3; ++l) {
00485 i__4 = l + i__ * a_dim1;
00486 i__5 = l + j * b_dim1;
00487 z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
00488 .i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
00489 .i * b[i__5].r;
00490 z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
00491 temp1.r = z__1.r, temp1.i = z__1.i;
00492 i__4 = l + i__ * b_dim1;
00493 i__5 = l + j * a_dim1;
00494 z__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
00495 .i, z__2.i = b[i__4].r * a[i__5].i + b[i__4]
00496 .i * a[i__5].r;
00497 z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
00498 temp2.r = z__1.r, temp2.i = z__1.i;
00499
00500 }
00501 if (beta->r == 0. && beta->i == 0.) {
00502 i__3 = i__ + j * c_dim1;
00503 z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00504 z__2.i = alpha->r * temp1.i + alpha->i *
00505 temp1.r;
00506 z__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00507 z__3.i = alpha->r * temp2.i + alpha->i *
00508 temp2.r;
00509 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00510 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00511 } else {
00512 i__3 = i__ + j * c_dim1;
00513 i__4 = i__ + j * c_dim1;
00514 z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00515 .i, z__3.i = beta->r * c__[i__4].i + beta->i *
00516 c__[i__4].r;
00517 z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00518 z__4.i = alpha->r * temp1.i + alpha->i *
00519 temp1.r;
00520 z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
00521 z__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00522 z__5.i = alpha->r * temp2.i + alpha->i *
00523 temp2.r;
00524 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00525 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00526 }
00527
00528 }
00529
00530 }
00531 }
00532 }
00533
00534 return 0;
00535
00536
00537
00538 }