00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int csyr2k_(char *uplo, char *trans, integer *n, integer *k,
00017 complex *alpha, complex *a, integer *lda, complex *b, integer *ldb,
00018 complex *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 complex q__1, q__2, q__3, q__4, q__5;
00024
00025
00026 integer i__, j, l, info;
00027 complex temp1, temp2;
00028 extern logical lsame_(char *, char *);
00029 integer nrowa;
00030 logical upper;
00031 extern int xerbla_(char *, integer *);
00032
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 a_dim1 = *lda;
00176 a_offset = 1 + a_dim1;
00177 a -= a_offset;
00178 b_dim1 = *ldb;
00179 b_offset = 1 + b_dim1;
00180 b -= b_offset;
00181 c_dim1 = *ldc;
00182 c_offset = 1 + c_dim1;
00183 c__ -= c_offset;
00184
00185
00186 if (lsame_(trans, "N")) {
00187 nrowa = *n;
00188 } else {
00189 nrowa = *k;
00190 }
00191 upper = lsame_(uplo, "U");
00192
00193 info = 0;
00194 if (! upper && ! lsame_(uplo, "L")) {
00195 info = 1;
00196 } else if (! lsame_(trans, "N") && ! lsame_(trans,
00197 "T")) {
00198 info = 2;
00199 } else if (*n < 0) {
00200 info = 3;
00201 } else if (*k < 0) {
00202 info = 4;
00203 } else if (*lda < max(1,nrowa)) {
00204 info = 7;
00205 } else if (*ldb < max(1,nrowa)) {
00206 info = 9;
00207 } else if (*ldc < max(1,*n)) {
00208 info = 12;
00209 }
00210 if (info != 0) {
00211 xerbla_("CSYR2K", &info);
00212 return 0;
00213 }
00214
00215
00216
00217 if (*n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0) && (
00218 beta->r == 1.f && beta->i == 0.f)) {
00219 return 0;
00220 }
00221
00222
00223
00224 if (alpha->r == 0.f && alpha->i == 0.f) {
00225 if (upper) {
00226 if (beta->r == 0.f && beta->i == 0.f) {
00227 i__1 = *n;
00228 for (j = 1; j <= i__1; ++j) {
00229 i__2 = j;
00230 for (i__ = 1; i__ <= i__2; ++i__) {
00231 i__3 = i__ + j * c_dim1;
00232 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00233
00234 }
00235
00236 }
00237 } else {
00238 i__1 = *n;
00239 for (j = 1; j <= i__1; ++j) {
00240 i__2 = j;
00241 for (i__ = 1; i__ <= i__2; ++i__) {
00242 i__3 = i__ + j * c_dim1;
00243 i__4 = i__ + j * c_dim1;
00244 q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00245 .i, q__1.i = beta->r * c__[i__4].i + beta->i *
00246 c__[i__4].r;
00247 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00248
00249 }
00250
00251 }
00252 }
00253 } else {
00254 if (beta->r == 0.f && beta->i == 0.f) {
00255 i__1 = *n;
00256 for (j = 1; j <= i__1; ++j) {
00257 i__2 = *n;
00258 for (i__ = j; i__ <= i__2; ++i__) {
00259 i__3 = i__ + j * c_dim1;
00260 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00261
00262 }
00263
00264 }
00265 } else {
00266 i__1 = *n;
00267 for (j = 1; j <= i__1; ++j) {
00268 i__2 = *n;
00269 for (i__ = j; i__ <= i__2; ++i__) {
00270 i__3 = i__ + j * c_dim1;
00271 i__4 = i__ + j * c_dim1;
00272 q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00273 .i, q__1.i = beta->r * c__[i__4].i + beta->i *
00274 c__[i__4].r;
00275 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00276
00277 }
00278
00279 }
00280 }
00281 }
00282 return 0;
00283 }
00284
00285
00286
00287 if (lsame_(trans, "N")) {
00288
00289
00290
00291 if (upper) {
00292 i__1 = *n;
00293 for (j = 1; j <= i__1; ++j) {
00294 if (beta->r == 0.f && beta->i == 0.f) {
00295 i__2 = j;
00296 for (i__ = 1; i__ <= i__2; ++i__) {
00297 i__3 = i__ + j * c_dim1;
00298 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00299
00300 }
00301 } else if (beta->r != 1.f || beta->i != 0.f) {
00302 i__2 = j;
00303 for (i__ = 1; i__ <= i__2; ++i__) {
00304 i__3 = i__ + j * c_dim1;
00305 i__4 = i__ + j * c_dim1;
00306 q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00307 .i, q__1.i = beta->r * c__[i__4].i + beta->i *
00308 c__[i__4].r;
00309 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00310
00311 }
00312 }
00313 i__2 = *k;
00314 for (l = 1; l <= i__2; ++l) {
00315 i__3 = j + l * a_dim1;
00316 i__4 = j + l * b_dim1;
00317 if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
00318 0.f || b[i__4].i != 0.f)) {
00319 i__3 = j + l * b_dim1;
00320 q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
00321 q__1.i = alpha->r * b[i__3].i + alpha->i * b[
00322 i__3].r;
00323 temp1.r = q__1.r, temp1.i = q__1.i;
00324 i__3 = j + l * a_dim1;
00325 q__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00326 q__1.i = alpha->r * a[i__3].i + alpha->i * a[
00327 i__3].r;
00328 temp2.r = q__1.r, temp2.i = q__1.i;
00329 i__3 = j;
00330 for (i__ = 1; i__ <= i__3; ++i__) {
00331 i__4 = i__ + j * c_dim1;
00332 i__5 = i__ + j * c_dim1;
00333 i__6 = i__ + l * a_dim1;
00334 q__3.r = a[i__6].r * temp1.r - a[i__6].i *
00335 temp1.i, q__3.i = a[i__6].r * temp1.i + a[
00336 i__6].i * temp1.r;
00337 q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
00338 .i + q__3.i;
00339 i__7 = i__ + l * b_dim1;
00340 q__4.r = b[i__7].r * temp2.r - b[i__7].i *
00341 temp2.i, q__4.i = b[i__7].r * temp2.i + b[
00342 i__7].i * temp2.r;
00343 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
00344 q__4.i;
00345 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00346
00347 }
00348 }
00349
00350 }
00351
00352 }
00353 } else {
00354 i__1 = *n;
00355 for (j = 1; j <= i__1; ++j) {
00356 if (beta->r == 0.f && beta->i == 0.f) {
00357 i__2 = *n;
00358 for (i__ = j; i__ <= i__2; ++i__) {
00359 i__3 = i__ + j * c_dim1;
00360 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00361
00362 }
00363 } else if (beta->r != 1.f || beta->i != 0.f) {
00364 i__2 = *n;
00365 for (i__ = j; i__ <= i__2; ++i__) {
00366 i__3 = i__ + j * c_dim1;
00367 i__4 = i__ + j * c_dim1;
00368 q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00369 .i, q__1.i = beta->r * c__[i__4].i + beta->i *
00370 c__[i__4].r;
00371 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00372
00373 }
00374 }
00375 i__2 = *k;
00376 for (l = 1; l <= i__2; ++l) {
00377 i__3 = j + l * a_dim1;
00378 i__4 = j + l * b_dim1;
00379 if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
00380 0.f || b[i__4].i != 0.f)) {
00381 i__3 = j + l * b_dim1;
00382 q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
00383 q__1.i = alpha->r * b[i__3].i + alpha->i * b[
00384 i__3].r;
00385 temp1.r = q__1.r, temp1.i = q__1.i;
00386 i__3 = j + l * a_dim1;
00387 q__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00388 q__1.i = alpha->r * a[i__3].i + alpha->i * a[
00389 i__3].r;
00390 temp2.r = q__1.r, temp2.i = q__1.i;
00391 i__3 = *n;
00392 for (i__ = j; i__ <= i__3; ++i__) {
00393 i__4 = i__ + j * c_dim1;
00394 i__5 = i__ + j * c_dim1;
00395 i__6 = i__ + l * a_dim1;
00396 q__3.r = a[i__6].r * temp1.r - a[i__6].i *
00397 temp1.i, q__3.i = a[i__6].r * temp1.i + a[
00398 i__6].i * temp1.r;
00399 q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
00400 .i + q__3.i;
00401 i__7 = i__ + l * b_dim1;
00402 q__4.r = b[i__7].r * temp2.r - b[i__7].i *
00403 temp2.i, q__4.i = b[i__7].r * temp2.i + b[
00404 i__7].i * temp2.r;
00405 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
00406 q__4.i;
00407 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00408
00409 }
00410 }
00411
00412 }
00413
00414 }
00415 }
00416 } else {
00417
00418
00419
00420 if (upper) {
00421 i__1 = *n;
00422 for (j = 1; j <= i__1; ++j) {
00423 i__2 = j;
00424 for (i__ = 1; i__ <= i__2; ++i__) {
00425 temp1.r = 0.f, temp1.i = 0.f;
00426 temp2.r = 0.f, temp2.i = 0.f;
00427 i__3 = *k;
00428 for (l = 1; l <= i__3; ++l) {
00429 i__4 = l + i__ * a_dim1;
00430 i__5 = l + j * b_dim1;
00431 q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
00432 .i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
00433 .i * b[i__5].r;
00434 q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
00435 temp1.r = q__1.r, temp1.i = q__1.i;
00436 i__4 = l + i__ * b_dim1;
00437 i__5 = l + j * a_dim1;
00438 q__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
00439 .i, q__2.i = b[i__4].r * a[i__5].i + b[i__4]
00440 .i * a[i__5].r;
00441 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00442 temp2.r = q__1.r, temp2.i = q__1.i;
00443
00444 }
00445 if (beta->r == 0.f && beta->i == 0.f) {
00446 i__3 = i__ + j * c_dim1;
00447 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00448 q__2.i = alpha->r * temp1.i + alpha->i *
00449 temp1.r;
00450 q__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00451 q__3.i = alpha->r * temp2.i + alpha->i *
00452 temp2.r;
00453 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00454 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00455 } else {
00456 i__3 = i__ + j * c_dim1;
00457 i__4 = i__ + j * c_dim1;
00458 q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00459 .i, q__3.i = beta->r * c__[i__4].i + beta->i *
00460 c__[i__4].r;
00461 q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00462 q__4.i = alpha->r * temp1.i + alpha->i *
00463 temp1.r;
00464 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i + q__4.i;
00465 q__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00466 q__5.i = alpha->r * temp2.i + alpha->i *
00467 temp2.r;
00468 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00469 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00470 }
00471
00472 }
00473
00474 }
00475 } else {
00476 i__1 = *n;
00477 for (j = 1; j <= i__1; ++j) {
00478 i__2 = *n;
00479 for (i__ = j; i__ <= i__2; ++i__) {
00480 temp1.r = 0.f, temp1.i = 0.f;
00481 temp2.r = 0.f, temp2.i = 0.f;
00482 i__3 = *k;
00483 for (l = 1; l <= i__3; ++l) {
00484 i__4 = l + i__ * a_dim1;
00485 i__5 = l + j * b_dim1;
00486 q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
00487 .i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
00488 .i * b[i__5].r;
00489 q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
00490 temp1.r = q__1.r, temp1.i = q__1.i;
00491 i__4 = l + i__ * b_dim1;
00492 i__5 = l + j * a_dim1;
00493 q__2.r = b[i__4].r * a[i__5].r - b[i__4].i * a[i__5]
00494 .i, q__2.i = b[i__4].r * a[i__5].i + b[i__4]
00495 .i * a[i__5].r;
00496 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00497 temp2.r = q__1.r, temp2.i = q__1.i;
00498
00499 }
00500 if (beta->r == 0.f && beta->i == 0.f) {
00501 i__3 = i__ + j * c_dim1;
00502 q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
00503 q__2.i = alpha->r * temp1.i + alpha->i *
00504 temp1.r;
00505 q__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00506 q__3.i = alpha->r * temp2.i + alpha->i *
00507 temp2.r;
00508 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00509 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00510 } else {
00511 i__3 = i__ + j * c_dim1;
00512 i__4 = i__ + j * c_dim1;
00513 q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00514 .i, q__3.i = beta->r * c__[i__4].i + beta->i *
00515 c__[i__4].r;
00516 q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
00517 q__4.i = alpha->r * temp1.i + alpha->i *
00518 temp1.r;
00519 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i + q__4.i;
00520 q__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00521 q__5.i = alpha->r * temp2.i + alpha->i *
00522 temp2.r;
00523 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00524 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00525 }
00526
00527 }
00528
00529 }
00530 }
00531 }
00532
00533 return 0;
00534
00535
00536
00537 }