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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020
00021 int zlavhe_(char *uplo, char *trans, char *diag, integer *n,
00022 integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv,
00023 doublecomplex *b, integer *ldb, integer *info)
00024 {
00025
00026 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00027 doublecomplex z__1, z__2, z__3;
00028
00029
00030 void d_cnjg(doublecomplex *, doublecomplex *);
00031
00032
00033 integer j, k;
00034 doublecomplex t1, t2, d11, d12, d21, d22;
00035 integer kp;
00036 extern logical lsame_(char *, char *);
00037 extern int zscal_(integer *, doublecomplex *,
00038 doublecomplex *, integer *), zgemv_(char *, integer *, integer *,
00039 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00040 integer *, doublecomplex *, doublecomplex *, integer *),
00041 zgeru_(integer *, integer *, doublecomplex *, doublecomplex *,
00042 integer *, doublecomplex *, integer *, doublecomplex *, integer *)
00043 , zswap_(integer *, doublecomplex *, integer *, doublecomplex *,
00044 integer *), xerbla_(char *, integer *), zlacgv_(integer *,
00045 doublecomplex *, integer *);
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_("ZLAVHE ", &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 zscal_(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 zgeru_(&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 zswap_(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 d_cnjg(&z__1, &d12);
00271 d21.r = z__1.r, d21.i = z__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 z__2.r = d11.r * t1.r - d11.i * t1.i, z__2.i = d11.r *
00280 t1.i + d11.i * t1.r;
00281 z__3.r = d12.r * t2.r - d12.i * t2.i, z__3.i = d12.r *
00282 t2.i + d12.i * t2.r;
00283 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00284 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00285 i__2 = k + 1 + j * b_dim1;
00286 z__2.r = d21.r * t1.r - d21.i * t1.i, z__2.i = d21.r *
00287 t1.i + d21.i * t1.r;
00288 z__3.r = d22.r * t2.r - d22.i * t2.i, z__3.i = d22.r *
00289 t2.i + d22.i * t2.r;
00290 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00291 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00292
00293 }
00294 }
00295
00296
00297
00298 if (k > 1) {
00299
00300
00301
00302 i__1 = k - 1;
00303 zgeru_(&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 zgeru_(&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 zswap_(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 zscal_(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 zgeru_(&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 zswap_(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 d_cnjg(&z__1, &d21);
00385 d12.r = z__1.r, d12.i = z__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 z__2.r = d11.r * t1.r - d11.i * t1.i, z__2.i = d11.r *
00394 t1.i + d11.i * t1.r;
00395 z__3.r = d12.r * t2.r - d12.i * t2.i, z__3.i = d12.r *
00396 t2.i + d12.i * t2.r;
00397 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00398 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00399 i__2 = k + j * b_dim1;
00400 z__2.r = d21.r * t1.r - d21.i * t1.i, z__2.i = d21.r *
00401 t1.i + d21.i * t1.r;
00402 z__3.r = d22.r * t2.r - d22.i * t2.i, z__3.i = d22.r *
00403 t2.i + d22.i * t2.r;
00404 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00405 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00406
00407 }
00408 }
00409
00410
00411
00412 if (k != *n) {
00413
00414
00415
00416 i__1 = *n - k;
00417 zgeru_(&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 zgeru_(&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 zswap_(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 zswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00470 ldb);
00471 }
00472
00473
00474
00475
00476
00477 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00478 i__1 = k - 1;
00479 zgemv_("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 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00483 }
00484 if (nounit) {
00485 zscal_(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 zswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1],
00499 ldb);
00500 }
00501
00502
00503
00504
00505
00506
00507 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00508 i__1 = k - 2;
00509 zgemv_("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 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00513
00514 zlacgv_(nrhs, &b[k - 1 + b_dim1], ldb);
00515 i__1 = k - 2;
00516 zgemv_("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 zlacgv_(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 d_cnjg(&z__1, &d12);
00532 d21.r = z__1.r, d21.i = z__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 z__2.r = d11.r * t1.r - d11.i * t1.i, z__2.i = d11.r *
00541 t1.i + d11.i * t1.r;
00542 z__3.r = d12.r * t2.r - d12.i * t2.i, z__3.i = d12.r *
00543 t2.i + d12.i * t2.r;
00544 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00545 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00546 i__2 = k + j * b_dim1;
00547 z__2.r = d21.r * t1.r - d21.i * t1.i, z__2.i = d21.r *
00548 t1.i + d21.i * t1.r;
00549 z__3.r = d22.r * t2.r - d22.i * t2.i, z__3.i = d22.r *
00550 t2.i + d22.i * t2.r;
00551 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00552 b[i__2].r = z__1.r, b[i__2].i = z__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 zswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00586 ldb);
00587 }
00588
00589
00590
00591 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00592 i__1 = *n - k;
00593 zgemv_("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 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00597 }
00598 if (nounit) {
00599 zscal_(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 zswap_(nrhs, &b[k + 1 + b_dim1], ldb, &b[kp + b_dim1],
00613 ldb);
00614 }
00615
00616
00617
00618 zlacgv_(nrhs, &b[k + 1 + b_dim1], ldb);
00619 i__1 = *n - k - 1;
00620 zgemv_("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 zlacgv_(nrhs, &b[k + 1 + b_dim1], ldb);
00624
00625 zlacgv_(nrhs, &b[k + b_dim1], ldb);
00626 i__1 = *n - k - 1;
00627 zgemv_("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 zlacgv_(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 d_cnjg(&z__1, &d21);
00643 d12.r = z__1.r, d12.i = z__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 z__2.r = d11.r * t1.r - d11.i * t1.i, z__2.i = d11.r *
00652 t1.i + d11.i * t1.r;
00653 z__3.r = d12.r * t2.r - d12.i * t2.i, z__3.i = d12.r *
00654 t2.i + d12.i * t2.r;
00655 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00656 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00657 i__2 = k + 1 + j * b_dim1;
00658 z__2.r = d21.r * t1.r - d21.i * t1.i, z__2.i = d21.r *
00659 t1.i + d21.i * t1.r;
00660 z__3.r = d22.r * t2.r - d22.i * t2.i, z__3.i = d22.r *
00661 t2.i + d22.i * t2.r;
00662 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00663 b[i__2].r = z__1.r, b[i__2].i = z__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 }