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