00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int cher2k_(char *uplo, char *trans, integer *n, integer *k,
00017 complex *alpha, complex *a, integer *lda, complex *b, integer *ldb,
00018 real *beta, complex *c__, integer *ldc)
00019 {
00020
00021 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
00022 i__3, i__4, i__5, i__6, i__7;
00023 real r__1;
00024 complex q__1, q__2, q__3, q__4, q__5, q__6;
00025
00026
00027 void r_cnjg(complex *, complex *);
00028
00029
00030 integer i__, j, l, info;
00031 complex temp1, temp2;
00032 extern logical lsame_(char *, char *);
00033 integer nrowa;
00034 logical upper;
00035 extern int xerbla_(char *, integer *);
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
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 a_dim1 = *lda;
00188 a_offset = 1 + a_dim1;
00189 a -= a_offset;
00190 b_dim1 = *ldb;
00191 b_offset = 1 + b_dim1;
00192 b -= b_offset;
00193 c_dim1 = *ldc;
00194 c_offset = 1 + c_dim1;
00195 c__ -= c_offset;
00196
00197
00198 if (lsame_(trans, "N")) {
00199 nrowa = *n;
00200 } else {
00201 nrowa = *k;
00202 }
00203 upper = lsame_(uplo, "U");
00204
00205 info = 0;
00206 if (! upper && ! lsame_(uplo, "L")) {
00207 info = 1;
00208 } else if (! lsame_(trans, "N") && ! lsame_(trans,
00209 "C")) {
00210 info = 2;
00211 } else if (*n < 0) {
00212 info = 3;
00213 } else if (*k < 0) {
00214 info = 4;
00215 } else if (*lda < max(1,nrowa)) {
00216 info = 7;
00217 } else if (*ldb < max(1,nrowa)) {
00218 info = 9;
00219 } else if (*ldc < max(1,*n)) {
00220 info = 12;
00221 }
00222 if (info != 0) {
00223 xerbla_("CHER2K", &info);
00224 return 0;
00225 }
00226
00227
00228
00229 if (*n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0) && *beta ==
00230 1.f) {
00231 return 0;
00232 }
00233
00234
00235
00236 if (alpha->r == 0.f && alpha->i == 0.f) {
00237 if (upper) {
00238 if (*beta == 0.f) {
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 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00245
00246 }
00247
00248 }
00249 } else {
00250 i__1 = *n;
00251 for (j = 1; j <= i__1; ++j) {
00252 i__2 = j - 1;
00253 for (i__ = 1; i__ <= i__2; ++i__) {
00254 i__3 = i__ + j * c_dim1;
00255 i__4 = i__ + j * c_dim1;
00256 q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
00257 i__4].i;
00258 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00259
00260 }
00261 i__2 = j + j * c_dim1;
00262 i__3 = j + j * c_dim1;
00263 r__1 = *beta * c__[i__3].r;
00264 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00265
00266 }
00267 }
00268 } else {
00269 if (*beta == 0.f) {
00270 i__1 = *n;
00271 for (j = 1; j <= i__1; ++j) {
00272 i__2 = *n;
00273 for (i__ = j; i__ <= i__2; ++i__) {
00274 i__3 = i__ + j * c_dim1;
00275 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00276
00277 }
00278
00279 }
00280 } else {
00281 i__1 = *n;
00282 for (j = 1; j <= i__1; ++j) {
00283 i__2 = j + j * c_dim1;
00284 i__3 = j + j * c_dim1;
00285 r__1 = *beta * c__[i__3].r;
00286 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00287 i__2 = *n;
00288 for (i__ = j + 1; i__ <= i__2; ++i__) {
00289 i__3 = i__ + j * c_dim1;
00290 i__4 = i__ + j * c_dim1;
00291 q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
00292 i__4].i;
00293 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00294
00295 }
00296
00297 }
00298 }
00299 }
00300 return 0;
00301 }
00302
00303
00304
00305 if (lsame_(trans, "N")) {
00306
00307
00308
00309
00310 if (upper) {
00311 i__1 = *n;
00312 for (j = 1; j <= i__1; ++j) {
00313 if (*beta == 0.f) {
00314 i__2 = j;
00315 for (i__ = 1; i__ <= i__2; ++i__) {
00316 i__3 = i__ + j * c_dim1;
00317 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00318
00319 }
00320 } else if (*beta != 1.f) {
00321 i__2 = j - 1;
00322 for (i__ = 1; i__ <= i__2; ++i__) {
00323 i__3 = i__ + j * c_dim1;
00324 i__4 = i__ + j * c_dim1;
00325 q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
00326 i__4].i;
00327 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00328
00329 }
00330 i__2 = j + j * c_dim1;
00331 i__3 = j + j * c_dim1;
00332 r__1 = *beta * c__[i__3].r;
00333 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00334 } else {
00335 i__2 = j + j * c_dim1;
00336 i__3 = j + j * c_dim1;
00337 r__1 = c__[i__3].r;
00338 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00339 }
00340 i__2 = *k;
00341 for (l = 1; l <= i__2; ++l) {
00342 i__3 = j + l * a_dim1;
00343 i__4 = j + l * b_dim1;
00344 if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
00345 0.f || b[i__4].i != 0.f)) {
00346 r_cnjg(&q__2, &b[j + l * b_dim1]);
00347 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
00348 q__1.i = alpha->r * q__2.i + alpha->i *
00349 q__2.r;
00350 temp1.r = q__1.r, temp1.i = q__1.i;
00351 i__3 = j + l * a_dim1;
00352 q__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00353 q__2.i = alpha->r * a[i__3].i + alpha->i * a[
00354 i__3].r;
00355 r_cnjg(&q__1, &q__2);
00356 temp2.r = q__1.r, temp2.i = q__1.i;
00357 i__3 = j - 1;
00358 for (i__ = 1; i__ <= i__3; ++i__) {
00359 i__4 = i__ + j * c_dim1;
00360 i__5 = i__ + j * c_dim1;
00361 i__6 = i__ + l * a_dim1;
00362 q__3.r = a[i__6].r * temp1.r - a[i__6].i *
00363 temp1.i, q__3.i = a[i__6].r * temp1.i + a[
00364 i__6].i * temp1.r;
00365 q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
00366 .i + q__3.i;
00367 i__7 = i__ + l * b_dim1;
00368 q__4.r = b[i__7].r * temp2.r - b[i__7].i *
00369 temp2.i, q__4.i = b[i__7].r * temp2.i + b[
00370 i__7].i * temp2.r;
00371 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
00372 q__4.i;
00373 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00374
00375 }
00376 i__3 = j + j * c_dim1;
00377 i__4 = j + j * c_dim1;
00378 i__5 = j + l * a_dim1;
00379 q__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
00380 q__2.i = a[i__5].r * temp1.i + a[i__5].i *
00381 temp1.r;
00382 i__6 = j + l * b_dim1;
00383 q__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
00384 q__3.i = b[i__6].r * temp2.i + b[i__6].i *
00385 temp2.r;
00386 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00387 r__1 = c__[i__4].r + q__1.r;
00388 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00389 }
00390
00391 }
00392
00393 }
00394 } else {
00395 i__1 = *n;
00396 for (j = 1; j <= i__1; ++j) {
00397 if (*beta == 0.f) {
00398 i__2 = *n;
00399 for (i__ = j; i__ <= i__2; ++i__) {
00400 i__3 = i__ + j * c_dim1;
00401 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00402
00403 }
00404 } else if (*beta != 1.f) {
00405 i__2 = *n;
00406 for (i__ = j + 1; i__ <= i__2; ++i__) {
00407 i__3 = i__ + j * c_dim1;
00408 i__4 = i__ + j * c_dim1;
00409 q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
00410 i__4].i;
00411 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00412
00413 }
00414 i__2 = j + j * c_dim1;
00415 i__3 = j + j * c_dim1;
00416 r__1 = *beta * c__[i__3].r;
00417 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00418 } else {
00419 i__2 = j + j * c_dim1;
00420 i__3 = j + j * c_dim1;
00421 r__1 = c__[i__3].r;
00422 c__[i__2].r = r__1, c__[i__2].i = 0.f;
00423 }
00424 i__2 = *k;
00425 for (l = 1; l <= i__2; ++l) {
00426 i__3 = j + l * a_dim1;
00427 i__4 = j + l * b_dim1;
00428 if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
00429 0.f || b[i__4].i != 0.f)) {
00430 r_cnjg(&q__2, &b[j + l * b_dim1]);
00431 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
00432 q__1.i = alpha->r * q__2.i + alpha->i *
00433 q__2.r;
00434 temp1.r = q__1.r, temp1.i = q__1.i;
00435 i__3 = j + l * a_dim1;
00436 q__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00437 q__2.i = alpha->r * a[i__3].i + alpha->i * a[
00438 i__3].r;
00439 r_cnjg(&q__1, &q__2);
00440 temp2.r = q__1.r, temp2.i = q__1.i;
00441 i__3 = *n;
00442 for (i__ = j + 1; i__ <= i__3; ++i__) {
00443 i__4 = i__ + j * c_dim1;
00444 i__5 = i__ + j * c_dim1;
00445 i__6 = i__ + l * a_dim1;
00446 q__3.r = a[i__6].r * temp1.r - a[i__6].i *
00447 temp1.i, q__3.i = a[i__6].r * temp1.i + a[
00448 i__6].i * temp1.r;
00449 q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
00450 .i + q__3.i;
00451 i__7 = i__ + l * b_dim1;
00452 q__4.r = b[i__7].r * temp2.r - b[i__7].i *
00453 temp2.i, q__4.i = b[i__7].r * temp2.i + b[
00454 i__7].i * temp2.r;
00455 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
00456 q__4.i;
00457 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00458
00459 }
00460 i__3 = j + j * c_dim1;
00461 i__4 = j + j * c_dim1;
00462 i__5 = j + l * a_dim1;
00463 q__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
00464 q__2.i = a[i__5].r * temp1.i + a[i__5].i *
00465 temp1.r;
00466 i__6 = j + l * b_dim1;
00467 q__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
00468 q__3.i = b[i__6].r * temp2.i + b[i__6].i *
00469 temp2.r;
00470 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00471 r__1 = c__[i__4].r + q__1.r;
00472 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00473 }
00474
00475 }
00476
00477 }
00478 }
00479 } else {
00480
00481
00482
00483
00484 if (upper) {
00485 i__1 = *n;
00486 for (j = 1; j <= i__1; ++j) {
00487 i__2 = j;
00488 for (i__ = 1; i__ <= i__2; ++i__) {
00489 temp1.r = 0.f, temp1.i = 0.f;
00490 temp2.r = 0.f, temp2.i = 0.f;
00491 i__3 = *k;
00492 for (l = 1; l <= i__3; ++l) {
00493 r_cnjg(&q__3, &a[l + i__ * a_dim1]);
00494 i__4 = l + j * b_dim1;
00495 q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
00496 q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
00497 .r;
00498 q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
00499 temp1.r = q__1.r, temp1.i = q__1.i;
00500 r_cnjg(&q__3, &b[l + i__ * b_dim1]);
00501 i__4 = l + j * a_dim1;
00502 q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
00503 q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
00504 .r;
00505 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00506 temp2.r = q__1.r, temp2.i = q__1.i;
00507
00508 }
00509 if (i__ == j) {
00510 if (*beta == 0.f) {
00511 i__3 = j + j * c_dim1;
00512 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00513 q__2.i = alpha->r * temp1.i + alpha->i *
00514 temp1.r;
00515 r_cnjg(&q__4, alpha);
00516 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00517 q__3.i = q__4.r * temp2.i + q__4.i *
00518 temp2.r;
00519 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00520 q__3.i;
00521 r__1 = q__1.r;
00522 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00523 } else {
00524 i__3 = j + j * c_dim1;
00525 i__4 = j + j * c_dim1;
00526 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00527 q__2.i = alpha->r * temp1.i + alpha->i *
00528 temp1.r;
00529 r_cnjg(&q__4, alpha);
00530 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00531 q__3.i = q__4.r * temp2.i + q__4.i *
00532 temp2.r;
00533 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00534 q__3.i;
00535 r__1 = *beta * c__[i__4].r + q__1.r;
00536 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00537 }
00538 } else {
00539 if (*beta == 0.f) {
00540 i__3 = i__ + j * c_dim1;
00541 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00542 q__2.i = alpha->r * temp1.i + alpha->i *
00543 temp1.r;
00544 r_cnjg(&q__4, alpha);
00545 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00546 q__3.i = q__4.r * temp2.i + q__4.i *
00547 temp2.r;
00548 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00549 q__3.i;
00550 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00551 } else {
00552 i__3 = i__ + j * c_dim1;
00553 i__4 = i__ + j * c_dim1;
00554 q__3.r = *beta * c__[i__4].r, q__3.i = *beta *
00555 c__[i__4].i;
00556 q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00557 q__4.i = alpha->r * temp1.i + alpha->i *
00558 temp1.r;
00559 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i +
00560 q__4.i;
00561 r_cnjg(&q__6, alpha);
00562 q__5.r = q__6.r * temp2.r - q__6.i * temp2.i,
00563 q__5.i = q__6.r * temp2.i + q__6.i *
00564 temp2.r;
00565 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i +
00566 q__5.i;
00567 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00568 }
00569 }
00570
00571 }
00572
00573 }
00574 } else {
00575 i__1 = *n;
00576 for (j = 1; j <= i__1; ++j) {
00577 i__2 = *n;
00578 for (i__ = j; i__ <= i__2; ++i__) {
00579 temp1.r = 0.f, temp1.i = 0.f;
00580 temp2.r = 0.f, temp2.i = 0.f;
00581 i__3 = *k;
00582 for (l = 1; l <= i__3; ++l) {
00583 r_cnjg(&q__3, &a[l + i__ * a_dim1]);
00584 i__4 = l + j * b_dim1;
00585 q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
00586 q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
00587 .r;
00588 q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
00589 temp1.r = q__1.r, temp1.i = q__1.i;
00590 r_cnjg(&q__3, &b[l + i__ * b_dim1]);
00591 i__4 = l + j * a_dim1;
00592 q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
00593 q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
00594 .r;
00595 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00596 temp2.r = q__1.r, temp2.i = q__1.i;
00597
00598 }
00599 if (i__ == j) {
00600 if (*beta == 0.f) {
00601 i__3 = j + j * c_dim1;
00602 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00603 q__2.i = alpha->r * temp1.i + alpha->i *
00604 temp1.r;
00605 r_cnjg(&q__4, alpha);
00606 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00607 q__3.i = q__4.r * temp2.i + q__4.i *
00608 temp2.r;
00609 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00610 q__3.i;
00611 r__1 = q__1.r;
00612 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00613 } else {
00614 i__3 = j + j * c_dim1;
00615 i__4 = j + j * c_dim1;
00616 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00617 q__2.i = alpha->r * temp1.i + alpha->i *
00618 temp1.r;
00619 r_cnjg(&q__4, alpha);
00620 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00621 q__3.i = q__4.r * temp2.i + q__4.i *
00622 temp2.r;
00623 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00624 q__3.i;
00625 r__1 = *beta * c__[i__4].r + q__1.r;
00626 c__[i__3].r = r__1, c__[i__3].i = 0.f;
00627 }
00628 } else {
00629 if (*beta == 0.f) {
00630 i__3 = i__ + j * c_dim1;
00631 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00632 q__2.i = alpha->r * temp1.i + alpha->i *
00633 temp1.r;
00634 r_cnjg(&q__4, alpha);
00635 q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
00636 q__3.i = q__4.r * temp2.i + q__4.i *
00637 temp2.r;
00638 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
00639 q__3.i;
00640 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00641 } else {
00642 i__3 = i__ + j * c_dim1;
00643 i__4 = i__ + j * c_dim1;
00644 q__3.r = *beta * c__[i__4].r, q__3.i = *beta *
00645 c__[i__4].i;
00646 q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00647 q__4.i = alpha->r * temp1.i + alpha->i *
00648 temp1.r;
00649 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i +
00650 q__4.i;
00651 r_cnjg(&q__6, alpha);
00652 q__5.r = q__6.r * temp2.r - q__6.i * temp2.i,
00653 q__5.i = q__6.r * temp2.i + q__6.i *
00654 temp2.r;
00655 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i +
00656 q__5.i;
00657 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00658 }
00659 }
00660
00661 }
00662
00663 }
00664 }
00665 }
00666
00667 return 0;
00668
00669
00670
00671 }