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 logical c_false = FALSE_;
00019 static integer c__1 = 1;
00020 static doublereal c_b22 = 1.;
00021 static doublereal c_b25 = 0.;
00022 static integer c__2 = 2;
00023 static logical c_true = TRUE_;
00024
00025 int dtrevc_(char *side, char *howmny, logical *select,
00026 integer *n, doublereal *t, integer *ldt, doublereal *vl, integer *
00027 ldvl, doublereal *vr, integer *ldvr, integer *mm, integer *m,
00028 doublereal *work, integer *info)
00029 {
00030
00031 integer t_dim1, t_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1,
00032 i__2, i__3;
00033 doublereal d__1, d__2, d__3, d__4;
00034
00035
00036 double sqrt(doublereal);
00037
00038
00039 integer i__, j, k;
00040 doublereal x[4] ;
00041 integer j1, j2, n2, ii, ki, ip, is;
00042 doublereal wi, wr, rec, ulp, beta, emax;
00043 logical pair;
00044 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00045 integer *);
00046 logical allv;
00047 integer ierr;
00048 doublereal unfl, ovfl, smin;
00049 logical over;
00050 doublereal vmax;
00051 integer jnxt;
00052 extern int dscal_(integer *, doublereal *, doublereal *,
00053 integer *);
00054 doublereal scale;
00055 extern logical lsame_(char *, char *);
00056 extern int dgemv_(char *, integer *, integer *,
00057 doublereal *, doublereal *, integer *, doublereal *, integer *,
00058 doublereal *, doublereal *, integer *);
00059 doublereal remax;
00060 extern int dcopy_(integer *, doublereal *, integer *,
00061 doublereal *, integer *);
00062 logical leftv, bothv;
00063 extern int daxpy_(integer *, doublereal *, doublereal *,
00064 integer *, doublereal *, integer *);
00065 doublereal vcrit;
00066 logical somev;
00067 doublereal xnorm;
00068 extern int dlaln2_(logical *, integer *, integer *,
00069 doublereal *, doublereal *, doublereal *, integer *, doublereal *,
00070 doublereal *, doublereal *, integer *, doublereal *, doublereal *
00071 , doublereal *, integer *, doublereal *, doublereal *, integer *),
00072 dlabad_(doublereal *, doublereal *);
00073 extern doublereal dlamch_(char *);
00074 extern integer idamax_(integer *, doublereal *, integer *);
00075 extern int xerbla_(char *, integer *);
00076 doublereal bignum;
00077 logical rightv;
00078 doublereal smlnum;
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
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 --select;
00236 t_dim1 = *ldt;
00237 t_offset = 1 + t_dim1;
00238 t -= t_offset;
00239 vl_dim1 = *ldvl;
00240 vl_offset = 1 + vl_dim1;
00241 vl -= vl_offset;
00242 vr_dim1 = *ldvr;
00243 vr_offset = 1 + vr_dim1;
00244 vr -= vr_offset;
00245 --work;
00246
00247
00248 bothv = lsame_(side, "B");
00249 rightv = lsame_(side, "R") || bothv;
00250 leftv = lsame_(side, "L") || bothv;
00251
00252 allv = lsame_(howmny, "A");
00253 over = lsame_(howmny, "B");
00254 somev = lsame_(howmny, "S");
00255
00256 *info = 0;
00257 if (! rightv && ! leftv) {
00258 *info = -1;
00259 } else if (! allv && ! over && ! somev) {
00260 *info = -2;
00261 } else if (*n < 0) {
00262 *info = -4;
00263 } else if (*ldt < max(1,*n)) {
00264 *info = -6;
00265 } else if (*ldvl < 1 || leftv && *ldvl < *n) {
00266 *info = -8;
00267 } else if (*ldvr < 1 || rightv && *ldvr < *n) {
00268 *info = -10;
00269 } else {
00270
00271
00272
00273
00274
00275 if (somev) {
00276 *m = 0;
00277 pair = FALSE_;
00278 i__1 = *n;
00279 for (j = 1; j <= i__1; ++j) {
00280 if (pair) {
00281 pair = FALSE_;
00282 select[j] = FALSE_;
00283 } else {
00284 if (j < *n) {
00285 if (t[j + 1 + j * t_dim1] == 0.) {
00286 if (select[j]) {
00287 ++(*m);
00288 }
00289 } else {
00290 pair = TRUE_;
00291 if (select[j] || select[j + 1]) {
00292 select[j] = TRUE_;
00293 *m += 2;
00294 }
00295 }
00296 } else {
00297 if (select[*n]) {
00298 ++(*m);
00299 }
00300 }
00301 }
00302
00303 }
00304 } else {
00305 *m = *n;
00306 }
00307
00308 if (*mm < *m) {
00309 *info = -11;
00310 }
00311 }
00312 if (*info != 0) {
00313 i__1 = -(*info);
00314 xerbla_("DTREVC", &i__1);
00315 return 0;
00316 }
00317
00318
00319
00320 if (*n == 0) {
00321 return 0;
00322 }
00323
00324
00325
00326 unfl = dlamch_("Safe minimum");
00327 ovfl = 1. / unfl;
00328 dlabad_(&unfl, &ovfl);
00329 ulp = dlamch_("Precision");
00330 smlnum = unfl * (*n / ulp);
00331 bignum = (1. - ulp) / smlnum;
00332
00333
00334
00335
00336 work[1] = 0.;
00337 i__1 = *n;
00338 for (j = 2; j <= i__1; ++j) {
00339 work[j] = 0.;
00340 i__2 = j - 1;
00341 for (i__ = 1; i__ <= i__2; ++i__) {
00342 work[j] += (d__1 = t[i__ + j * t_dim1], abs(d__1));
00343
00344 }
00345
00346 }
00347
00348
00349
00350
00351
00352
00353 n2 = *n << 1;
00354
00355 if (rightv) {
00356
00357
00358
00359 ip = 0;
00360 is = *m;
00361 for (ki = *n; ki >= 1; --ki) {
00362
00363 if (ip == 1) {
00364 goto L130;
00365 }
00366 if (ki == 1) {
00367 goto L40;
00368 }
00369 if (t[ki + (ki - 1) * t_dim1] == 0.) {
00370 goto L40;
00371 }
00372 ip = -1;
00373
00374 L40:
00375 if (somev) {
00376 if (ip == 0) {
00377 if (! select[ki]) {
00378 goto L130;
00379 }
00380 } else {
00381 if (! select[ki - 1]) {
00382 goto L130;
00383 }
00384 }
00385 }
00386
00387
00388
00389 wr = t[ki + ki * t_dim1];
00390 wi = 0.;
00391 if (ip != 0) {
00392 wi = sqrt((d__1 = t[ki + (ki - 1) * t_dim1], abs(d__1))) *
00393 sqrt((d__2 = t[ki - 1 + ki * t_dim1], abs(d__2)));
00394 }
00395
00396 d__1 = ulp * (abs(wr) + abs(wi));
00397 smin = max(d__1,smlnum);
00398
00399 if (ip == 0) {
00400
00401
00402
00403 work[ki + *n] = 1.;
00404
00405
00406
00407 i__1 = ki - 1;
00408 for (k = 1; k <= i__1; ++k) {
00409 work[k + *n] = -t[k + ki * t_dim1];
00410
00411 }
00412
00413
00414
00415
00416 jnxt = ki - 1;
00417 for (j = ki - 1; j >= 1; --j) {
00418 if (j > jnxt) {
00419 goto L60;
00420 }
00421 j1 = j;
00422 j2 = j;
00423 jnxt = j - 1;
00424 if (j > 1) {
00425 if (t[j + (j - 1) * t_dim1] != 0.) {
00426 j1 = j - 1;
00427 jnxt = j - 2;
00428 }
00429 }
00430
00431 if (j1 == j2) {
00432
00433
00434
00435 dlaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j +
00436 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
00437 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm,
00438 &ierr);
00439
00440
00441
00442
00443 if (xnorm > 1.) {
00444 if (work[j] > bignum / xnorm) {
00445 x[0] /= xnorm;
00446 scale /= xnorm;
00447 }
00448 }
00449
00450
00451
00452 if (scale != 1.) {
00453 dscal_(&ki, &scale, &work[*n + 1], &c__1);
00454 }
00455 work[j + *n] = x[0];
00456
00457
00458
00459 i__1 = j - 1;
00460 d__1 = -x[0];
00461 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00462 *n + 1], &c__1);
00463
00464 } else {
00465
00466
00467
00468 dlaln2_(&c_false, &c__2, &c__1, &smin, &c_b22, &t[j -
00469 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, &
00470 work[j - 1 + *n], n, &wr, &c_b25, x, &c__2, &
00471 scale, &xnorm, &ierr);
00472
00473
00474
00475
00476 if (xnorm > 1.) {
00477
00478 d__1 = work[j - 1], d__2 = work[j];
00479 beta = max(d__1,d__2);
00480 if (beta > bignum / xnorm) {
00481 x[0] /= xnorm;
00482 x[1] /= xnorm;
00483 scale /= xnorm;
00484 }
00485 }
00486
00487
00488
00489 if (scale != 1.) {
00490 dscal_(&ki, &scale, &work[*n + 1], &c__1);
00491 }
00492 work[j - 1 + *n] = x[0];
00493 work[j + *n] = x[1];
00494
00495
00496
00497 i__1 = j - 2;
00498 d__1 = -x[0];
00499 daxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1,
00500 &work[*n + 1], &c__1);
00501 i__1 = j - 2;
00502 d__1 = -x[1];
00503 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00504 *n + 1], &c__1);
00505 }
00506 L60:
00507 ;
00508 }
00509
00510
00511
00512 if (! over) {
00513 dcopy_(&ki, &work[*n + 1], &c__1, &vr[is * vr_dim1 + 1], &
00514 c__1);
00515
00516 ii = idamax_(&ki, &vr[is * vr_dim1 + 1], &c__1);
00517 remax = 1. / (d__1 = vr[ii + is * vr_dim1], abs(d__1));
00518 dscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1);
00519
00520 i__1 = *n;
00521 for (k = ki + 1; k <= i__1; ++k) {
00522 vr[k + is * vr_dim1] = 0.;
00523
00524 }
00525 } else {
00526 if (ki > 1) {
00527 i__1 = ki - 1;
00528 dgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
00529 work[*n + 1], &c__1, &work[ki + *n], &vr[ki *
00530 vr_dim1 + 1], &c__1);
00531 }
00532
00533 ii = idamax_(n, &vr[ki * vr_dim1 + 1], &c__1);
00534 remax = 1. / (d__1 = vr[ii + ki * vr_dim1], abs(d__1));
00535 dscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1);
00536 }
00537
00538 } else {
00539
00540
00541
00542
00543
00544
00545
00546 if ((d__1 = t[ki - 1 + ki * t_dim1], abs(d__1)) >= (d__2 = t[
00547 ki + (ki - 1) * t_dim1], abs(d__2))) {
00548 work[ki - 1 + *n] = 1.;
00549 work[ki + n2] = wi / t[ki - 1 + ki * t_dim1];
00550 } else {
00551 work[ki - 1 + *n] = -wi / t[ki + (ki - 1) * t_dim1];
00552 work[ki + n2] = 1.;
00553 }
00554 work[ki + *n] = 0.;
00555 work[ki - 1 + n2] = 0.;
00556
00557
00558
00559 i__1 = ki - 2;
00560 for (k = 1; k <= i__1; ++k) {
00561 work[k + *n] = -work[ki - 1 + *n] * t[k + (ki - 1) *
00562 t_dim1];
00563 work[k + n2] = -work[ki + n2] * t[k + ki * t_dim1];
00564
00565 }
00566
00567
00568
00569
00570 jnxt = ki - 2;
00571 for (j = ki - 2; j >= 1; --j) {
00572 if (j > jnxt) {
00573 goto L90;
00574 }
00575 j1 = j;
00576 j2 = j;
00577 jnxt = j - 1;
00578 if (j > 1) {
00579 if (t[j + (j - 1) * t_dim1] != 0.) {
00580 j1 = j - 1;
00581 jnxt = j - 2;
00582 }
00583 }
00584
00585 if (j1 == j2) {
00586
00587
00588
00589 dlaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j +
00590 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
00591 n], n, &wr, &wi, x, &c__2, &scale, &xnorm, &
00592 ierr);
00593
00594
00595
00596
00597 if (xnorm > 1.) {
00598 if (work[j] > bignum / xnorm) {
00599 x[0] /= xnorm;
00600 x[2] /= xnorm;
00601 scale /= xnorm;
00602 }
00603 }
00604
00605
00606
00607 if (scale != 1.) {
00608 dscal_(&ki, &scale, &work[*n + 1], &c__1);
00609 dscal_(&ki, &scale, &work[n2 + 1], &c__1);
00610 }
00611 work[j + *n] = x[0];
00612 work[j + n2] = x[2];
00613
00614
00615
00616 i__1 = j - 1;
00617 d__1 = -x[0];
00618 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00619 *n + 1], &c__1);
00620 i__1 = j - 1;
00621 d__1 = -x[2];
00622 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00623 n2 + 1], &c__1);
00624
00625 } else {
00626
00627
00628
00629 dlaln2_(&c_false, &c__2, &c__2, &smin, &c_b22, &t[j -
00630 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, &
00631 work[j - 1 + *n], n, &wr, &wi, x, &c__2, &
00632 scale, &xnorm, &ierr);
00633
00634
00635
00636
00637 if (xnorm > 1.) {
00638
00639 d__1 = work[j - 1], d__2 = work[j];
00640 beta = max(d__1,d__2);
00641 if (beta > bignum / xnorm) {
00642 rec = 1. / xnorm;
00643 x[0] *= rec;
00644 x[2] *= rec;
00645 x[1] *= rec;
00646 x[3] *= rec;
00647 scale *= rec;
00648 }
00649 }
00650
00651
00652
00653 if (scale != 1.) {
00654 dscal_(&ki, &scale, &work[*n + 1], &c__1);
00655 dscal_(&ki, &scale, &work[n2 + 1], &c__1);
00656 }
00657 work[j - 1 + *n] = x[0];
00658 work[j + *n] = x[1];
00659 work[j - 1 + n2] = x[2];
00660 work[j + n2] = x[3];
00661
00662
00663
00664 i__1 = j - 2;
00665 d__1 = -x[0];
00666 daxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1,
00667 &work[*n + 1], &c__1);
00668 i__1 = j - 2;
00669 d__1 = -x[1];
00670 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00671 *n + 1], &c__1);
00672 i__1 = j - 2;
00673 d__1 = -x[2];
00674 daxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1,
00675 &work[n2 + 1], &c__1);
00676 i__1 = j - 2;
00677 d__1 = -x[3];
00678 daxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[
00679 n2 + 1], &c__1);
00680 }
00681 L90:
00682 ;
00683 }
00684
00685
00686
00687 if (! over) {
00688 dcopy_(&ki, &work[*n + 1], &c__1, &vr[(is - 1) * vr_dim1
00689 + 1], &c__1);
00690 dcopy_(&ki, &work[n2 + 1], &c__1, &vr[is * vr_dim1 + 1], &
00691 c__1);
00692
00693 emax = 0.;
00694 i__1 = ki;
00695 for (k = 1; k <= i__1; ++k) {
00696
00697 d__3 = emax, d__4 = (d__1 = vr[k + (is - 1) * vr_dim1]
00698 , abs(d__1)) + (d__2 = vr[k + is * vr_dim1],
00699 abs(d__2));
00700 emax = max(d__3,d__4);
00701
00702 }
00703
00704 remax = 1. / emax;
00705 dscal_(&ki, &remax, &vr[(is - 1) * vr_dim1 + 1], &c__1);
00706 dscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1);
00707
00708 i__1 = *n;
00709 for (k = ki + 1; k <= i__1; ++k) {
00710 vr[k + (is - 1) * vr_dim1] = 0.;
00711 vr[k + is * vr_dim1] = 0.;
00712
00713 }
00714
00715 } else {
00716
00717 if (ki > 2) {
00718 i__1 = ki - 2;
00719 dgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
00720 work[*n + 1], &c__1, &work[ki - 1 + *n], &vr[(
00721 ki - 1) * vr_dim1 + 1], &c__1);
00722 i__1 = ki - 2;
00723 dgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
00724 work[n2 + 1], &c__1, &work[ki + n2], &vr[ki *
00725 vr_dim1 + 1], &c__1);
00726 } else {
00727 dscal_(n, &work[ki - 1 + *n], &vr[(ki - 1) * vr_dim1
00728 + 1], &c__1);
00729 dscal_(n, &work[ki + n2], &vr[ki * vr_dim1 + 1], &
00730 c__1);
00731 }
00732
00733 emax = 0.;
00734 i__1 = *n;
00735 for (k = 1; k <= i__1; ++k) {
00736
00737 d__3 = emax, d__4 = (d__1 = vr[k + (ki - 1) * vr_dim1]
00738 , abs(d__1)) + (d__2 = vr[k + ki * vr_dim1],
00739 abs(d__2));
00740 emax = max(d__3,d__4);
00741
00742 }
00743 remax = 1. / emax;
00744 dscal_(n, &remax, &vr[(ki - 1) * vr_dim1 + 1], &c__1);
00745 dscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1);
00746 }
00747 }
00748
00749 --is;
00750 if (ip != 0) {
00751 --is;
00752 }
00753 L130:
00754 if (ip == 1) {
00755 ip = 0;
00756 }
00757 if (ip == -1) {
00758 ip = 1;
00759 }
00760
00761 }
00762 }
00763
00764 if (leftv) {
00765
00766
00767
00768 ip = 0;
00769 is = 1;
00770 i__1 = *n;
00771 for (ki = 1; ki <= i__1; ++ki) {
00772
00773 if (ip == -1) {
00774 goto L250;
00775 }
00776 if (ki == *n) {
00777 goto L150;
00778 }
00779 if (t[ki + 1 + ki * t_dim1] == 0.) {
00780 goto L150;
00781 }
00782 ip = 1;
00783
00784 L150:
00785 if (somev) {
00786 if (! select[ki]) {
00787 goto L250;
00788 }
00789 }
00790
00791
00792
00793 wr = t[ki + ki * t_dim1];
00794 wi = 0.;
00795 if (ip != 0) {
00796 wi = sqrt((d__1 = t[ki + (ki + 1) * t_dim1], abs(d__1))) *
00797 sqrt((d__2 = t[ki + 1 + ki * t_dim1], abs(d__2)));
00798 }
00799
00800 d__1 = ulp * (abs(wr) + abs(wi));
00801 smin = max(d__1,smlnum);
00802
00803 if (ip == 0) {
00804
00805
00806
00807 work[ki + *n] = 1.;
00808
00809
00810
00811 i__2 = *n;
00812 for (k = ki + 1; k <= i__2; ++k) {
00813 work[k + *n] = -t[ki + k * t_dim1];
00814
00815 }
00816
00817
00818
00819
00820 vmax = 1.;
00821 vcrit = bignum;
00822
00823 jnxt = ki + 1;
00824 i__2 = *n;
00825 for (j = ki + 1; j <= i__2; ++j) {
00826 if (j < jnxt) {
00827 goto L170;
00828 }
00829 j1 = j;
00830 j2 = j;
00831 jnxt = j + 1;
00832 if (j < *n) {
00833 if (t[j + 1 + j * t_dim1] != 0.) {
00834 j2 = j + 1;
00835 jnxt = j + 2;
00836 }
00837 }
00838
00839 if (j1 == j2) {
00840
00841
00842
00843
00844
00845
00846 if (work[j] > vcrit) {
00847 rec = 1. / vmax;
00848 i__3 = *n - ki + 1;
00849 dscal_(&i__3, &rec, &work[ki + *n], &c__1);
00850 vmax = 1.;
00851 vcrit = bignum;
00852 }
00853
00854 i__3 = j - ki - 1;
00855 work[j + *n] -= ddot_(&i__3, &t[ki + 1 + j * t_dim1],
00856 &c__1, &work[ki + 1 + *n], &c__1);
00857
00858
00859
00860 dlaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j +
00861 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
00862 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm,
00863 &ierr);
00864
00865
00866
00867 if (scale != 1.) {
00868 i__3 = *n - ki + 1;
00869 dscal_(&i__3, &scale, &work[ki + *n], &c__1);
00870 }
00871 work[j + *n] = x[0];
00872
00873 d__2 = (d__1 = work[j + *n], abs(d__1));
00874 vmax = max(d__2,vmax);
00875 vcrit = bignum / vmax;
00876
00877 } else {
00878
00879
00880
00881
00882
00883
00884
00885 d__1 = work[j], d__2 = work[j + 1];
00886 beta = max(d__1,d__2);
00887 if (beta > vcrit) {
00888 rec = 1. / vmax;
00889 i__3 = *n - ki + 1;
00890 dscal_(&i__3, &rec, &work[ki + *n], &c__1);
00891 vmax = 1.;
00892 vcrit = bignum;
00893 }
00894
00895 i__3 = j - ki - 1;
00896 work[j + *n] -= ddot_(&i__3, &t[ki + 1 + j * t_dim1],
00897 &c__1, &work[ki + 1 + *n], &c__1);
00898
00899 i__3 = j - ki - 1;
00900 work[j + 1 + *n] -= ddot_(&i__3, &t[ki + 1 + (j + 1) *
00901 t_dim1], &c__1, &work[ki + 1 + *n], &c__1);
00902
00903
00904
00905
00906
00907 dlaln2_(&c_true, &c__2, &c__1, &smin, &c_b22, &t[j +
00908 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
00909 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm,
00910 &ierr);
00911
00912
00913
00914 if (scale != 1.) {
00915 i__3 = *n - ki + 1;
00916 dscal_(&i__3, &scale, &work[ki + *n], &c__1);
00917 }
00918 work[j + *n] = x[0];
00919 work[j + 1 + *n] = x[1];
00920
00921
00922 d__3 = (d__1 = work[j + *n], abs(d__1)), d__4 = (d__2
00923 = work[j + 1 + *n], abs(d__2)), d__3 = max(
00924 d__3,d__4);
00925 vmax = max(d__3,vmax);
00926 vcrit = bignum / vmax;
00927
00928 }
00929 L170:
00930 ;
00931 }
00932
00933
00934
00935 if (! over) {
00936 i__2 = *n - ki + 1;
00937 dcopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is *
00938 vl_dim1], &c__1);
00939
00940 i__2 = *n - ki + 1;
00941 ii = idamax_(&i__2, &vl[ki + is * vl_dim1], &c__1) + ki -
00942 1;
00943 remax = 1. / (d__1 = vl[ii + is * vl_dim1], abs(d__1));
00944 i__2 = *n - ki + 1;
00945 dscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1);
00946
00947 i__2 = ki - 1;
00948 for (k = 1; k <= i__2; ++k) {
00949 vl[k + is * vl_dim1] = 0.;
00950
00951 }
00952
00953 } else {
00954
00955 if (ki < *n) {
00956 i__2 = *n - ki;
00957 dgemv_("N", n, &i__2, &c_b22, &vl[(ki + 1) * vl_dim1
00958 + 1], ldvl, &work[ki + 1 + *n], &c__1, &work[
00959 ki + *n], &vl[ki * vl_dim1 + 1], &c__1);
00960 }
00961
00962 ii = idamax_(n, &vl[ki * vl_dim1 + 1], &c__1);
00963 remax = 1. / (d__1 = vl[ii + ki * vl_dim1], abs(d__1));
00964 dscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1);
00965
00966 }
00967
00968 } else {
00969
00970
00971
00972
00973
00974
00975
00976 if ((d__1 = t[ki + (ki + 1) * t_dim1], abs(d__1)) >= (d__2 =
00977 t[ki + 1 + ki * t_dim1], abs(d__2))) {
00978 work[ki + *n] = wi / t[ki + (ki + 1) * t_dim1];
00979 work[ki + 1 + n2] = 1.;
00980 } else {
00981 work[ki + *n] = 1.;
00982 work[ki + 1 + n2] = -wi / t[ki + 1 + ki * t_dim1];
00983 }
00984 work[ki + 1 + *n] = 0.;
00985 work[ki + n2] = 0.;
00986
00987
00988
00989 i__2 = *n;
00990 for (k = ki + 2; k <= i__2; ++k) {
00991 work[k + *n] = -work[ki + *n] * t[ki + k * t_dim1];
00992 work[k + n2] = -work[ki + 1 + n2] * t[ki + 1 + k * t_dim1]
00993 ;
00994
00995 }
00996
00997
00998
00999
01000 vmax = 1.;
01001 vcrit = bignum;
01002
01003 jnxt = ki + 2;
01004 i__2 = *n;
01005 for (j = ki + 2; j <= i__2; ++j) {
01006 if (j < jnxt) {
01007 goto L200;
01008 }
01009 j1 = j;
01010 j2 = j;
01011 jnxt = j + 1;
01012 if (j < *n) {
01013 if (t[j + 1 + j * t_dim1] != 0.) {
01014 j2 = j + 1;
01015 jnxt = j + 2;
01016 }
01017 }
01018
01019 if (j1 == j2) {
01020
01021
01022
01023
01024
01025
01026 if (work[j] > vcrit) {
01027 rec = 1. / vmax;
01028 i__3 = *n - ki + 1;
01029 dscal_(&i__3, &rec, &work[ki + *n], &c__1);
01030 i__3 = *n - ki + 1;
01031 dscal_(&i__3, &rec, &work[ki + n2], &c__1);
01032 vmax = 1.;
01033 vcrit = bignum;
01034 }
01035
01036 i__3 = j - ki - 2;
01037 work[j + *n] -= ddot_(&i__3, &t[ki + 2 + j * t_dim1],
01038 &c__1, &work[ki + 2 + *n], &c__1);
01039 i__3 = j - ki - 2;
01040 work[j + n2] -= ddot_(&i__3, &t[ki + 2 + j * t_dim1],
01041 &c__1, &work[ki + 2 + n2], &c__1);
01042
01043
01044
01045 d__1 = -wi;
01046 dlaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j +
01047 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
01048 n], n, &wr, &d__1, x, &c__2, &scale, &xnorm, &
01049 ierr);
01050
01051
01052
01053 if (scale != 1.) {
01054 i__3 = *n - ki + 1;
01055 dscal_(&i__3, &scale, &work[ki + *n], &c__1);
01056 i__3 = *n - ki + 1;
01057 dscal_(&i__3, &scale, &work[ki + n2], &c__1);
01058 }
01059 work[j + *n] = x[0];
01060 work[j + n2] = x[2];
01061
01062 d__3 = (d__1 = work[j + *n], abs(d__1)), d__4 = (d__2
01063 = work[j + n2], abs(d__2)), d__3 = max(d__3,
01064 d__4);
01065 vmax = max(d__3,vmax);
01066 vcrit = bignum / vmax;
01067
01068 } else {
01069
01070
01071
01072
01073
01074
01075
01076 d__1 = work[j], d__2 = work[j + 1];
01077 beta = max(d__1,d__2);
01078 if (beta > vcrit) {
01079 rec = 1. / vmax;
01080 i__3 = *n - ki + 1;
01081 dscal_(&i__3, &rec, &work[ki + *n], &c__1);
01082 i__3 = *n - ki + 1;
01083 dscal_(&i__3, &rec, &work[ki + n2], &c__1);
01084 vmax = 1.;
01085 vcrit = bignum;
01086 }
01087
01088 i__3 = j - ki - 2;
01089 work[j + *n] -= ddot_(&i__3, &t[ki + 2 + j * t_dim1],
01090 &c__1, &work[ki + 2 + *n], &c__1);
01091
01092 i__3 = j - ki - 2;
01093 work[j + n2] -= ddot_(&i__3, &t[ki + 2 + j * t_dim1],
01094 &c__1, &work[ki + 2 + n2], &c__1);
01095
01096 i__3 = j - ki - 2;
01097 work[j + 1 + *n] -= ddot_(&i__3, &t[ki + 2 + (j + 1) *
01098 t_dim1], &c__1, &work[ki + 2 + *n], &c__1);
01099
01100 i__3 = j - ki - 2;
01101 work[j + 1 + n2] -= ddot_(&i__3, &t[ki + 2 + (j + 1) *
01102 t_dim1], &c__1, &work[ki + 2 + n2], &c__1);
01103
01104
01105
01106
01107
01108 d__1 = -wi;
01109 dlaln2_(&c_true, &c__2, &c__2, &smin, &c_b22, &t[j +
01110 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
01111 n], n, &wr, &d__1, x, &c__2, &scale, &xnorm, &
01112 ierr);
01113
01114
01115
01116 if (scale != 1.) {
01117 i__3 = *n - ki + 1;
01118 dscal_(&i__3, &scale, &work[ki + *n], &c__1);
01119 i__3 = *n - ki + 1;
01120 dscal_(&i__3, &scale, &work[ki + n2], &c__1);
01121 }
01122 work[j + *n] = x[0];
01123 work[j + n2] = x[2];
01124 work[j + 1 + *n] = x[1];
01125 work[j + 1 + n2] = x[3];
01126
01127 d__1 = abs(x[0]), d__2 = abs(x[2]), d__1 = max(d__1,
01128 d__2), d__2 = abs(x[1]), d__1 = max(d__1,d__2)
01129 , d__2 = abs(x[3]), d__1 = max(d__1,d__2);
01130 vmax = max(d__1,vmax);
01131 vcrit = bignum / vmax;
01132
01133 }
01134 L200:
01135 ;
01136 }
01137
01138
01139
01140 if (! over) {
01141 i__2 = *n - ki + 1;
01142 dcopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is *
01143 vl_dim1], &c__1);
01144 i__2 = *n - ki + 1;
01145 dcopy_(&i__2, &work[ki + n2], &c__1, &vl[ki + (is + 1) *
01146 vl_dim1], &c__1);
01147
01148 emax = 0.;
01149 i__2 = *n;
01150 for (k = ki; k <= i__2; ++k) {
01151
01152 d__3 = emax, d__4 = (d__1 = vl[k + is * vl_dim1], abs(
01153 d__1)) + (d__2 = vl[k + (is + 1) * vl_dim1],
01154 abs(d__2));
01155 emax = max(d__3,d__4);
01156
01157 }
01158 remax = 1. / emax;
01159 i__2 = *n - ki + 1;
01160 dscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1);
01161 i__2 = *n - ki + 1;
01162 dscal_(&i__2, &remax, &vl[ki + (is + 1) * vl_dim1], &c__1)
01163 ;
01164
01165 i__2 = ki - 1;
01166 for (k = 1; k <= i__2; ++k) {
01167 vl[k + is * vl_dim1] = 0.;
01168 vl[k + (is + 1) * vl_dim1] = 0.;
01169
01170 }
01171 } else {
01172 if (ki < *n - 1) {
01173 i__2 = *n - ki - 1;
01174 dgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1
01175 + 1], ldvl, &work[ki + 2 + *n], &c__1, &work[
01176 ki + *n], &vl[ki * vl_dim1 + 1], &c__1);
01177 i__2 = *n - ki - 1;
01178 dgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1
01179 + 1], ldvl, &work[ki + 2 + n2], &c__1, &work[
01180 ki + 1 + n2], &vl[(ki + 1) * vl_dim1 + 1], &
01181 c__1);
01182 } else {
01183 dscal_(n, &work[ki + *n], &vl[ki * vl_dim1 + 1], &
01184 c__1);
01185 dscal_(n, &work[ki + 1 + n2], &vl[(ki + 1) * vl_dim1
01186 + 1], &c__1);
01187 }
01188
01189 emax = 0.;
01190 i__2 = *n;
01191 for (k = 1; k <= i__2; ++k) {
01192
01193 d__3 = emax, d__4 = (d__1 = vl[k + ki * vl_dim1], abs(
01194 d__1)) + (d__2 = vl[k + (ki + 1) * vl_dim1],
01195 abs(d__2));
01196 emax = max(d__3,d__4);
01197
01198 }
01199 remax = 1. / emax;
01200 dscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1);
01201 dscal_(n, &remax, &vl[(ki + 1) * vl_dim1 + 1], &c__1);
01202
01203 }
01204
01205 }
01206
01207 ++is;
01208 if (ip != 0) {
01209 ++is;
01210 }
01211 L250:
01212 if (ip == -1) {
01213 ip = 0;
01214 }
01215 if (ip == 1) {
01216 ip = -1;
01217 }
01218
01219
01220 }
01221
01222 }
01223
01224 return 0;
01225
01226
01227
01228 }