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