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_true = TRUE_;
00019 static integer c__2 = 2;
00020 static real c_b34 = 1.f;
00021 static integer c__1 = 1;
00022 static real c_b36 = 0.f;
00023 static logical c_false = FALSE_;
00024
00025 int stgevc_(char *side, char *howmny, logical *select,
00026 integer *n, real *s, integer *lds, real *p, integer *ldp, real *vl,
00027 integer *ldvl, real *vr, integer *ldvr, integer *mm, integer *m, real
00028 *work, integer *info)
00029 {
00030
00031 integer p_dim1, p_offset, s_dim1, s_offset, vl_dim1, vl_offset, vr_dim1,
00032 vr_offset, i__1, i__2, i__3, i__4, i__5;
00033 real r__1, r__2, r__3, r__4, r__5, r__6;
00034
00035
00036 integer i__, j, ja, jc, je, na, im, jr, jw, nw;
00037 real big;
00038 logical lsa, lsb;
00039 real ulp, sum[4] ;
00040 integer ibeg, ieig, iend;
00041 real dmin__, temp, xmax, sump[4] , sums[4]
00042 , cim2a, cim2b, cre2a, cre2b;
00043 extern int slag2_(real *, integer *, real *, integer *,
00044 real *, real *, real *, real *, real *, real *);
00045 real temp2, bdiag[2], acoef, scale;
00046 logical ilall;
00047 integer iside;
00048 real sbeta;
00049 extern logical lsame_(char *, char *);
00050 logical il2by2;
00051 integer iinfo;
00052 real small;
00053 logical compl;
00054 real anorm, bnorm;
00055 logical compr;
00056 extern int sgemv_(char *, integer *, integer *, real *,
00057 real *, integer *, real *, integer *, real *, real *, integer *), slaln2_(logical *, integer *, integer *, real *, real *,
00058 real *, integer *, real *, real *, real *, integer *, real *,
00059 real *, real *, integer *, real *, real *, integer *);
00060 real temp2i, temp2r;
00061 logical ilabad, ilbbad;
00062 real acoefa, bcoefa, cimaga, cimagb;
00063 logical ilback;
00064 extern int slabad_(real *, real *);
00065 real bcoefi, ascale, bscale, creala, crealb, bcoefr;
00066 extern doublereal slamch_(char *);
00067 real salfar, safmin;
00068 extern int xerbla_(char *, integer *);
00069 real xscale, bignum;
00070 logical ilcomp, ilcplx;
00071 extern int slacpy_(char *, integer *, integer *, real *,
00072 integer *, real *, integer *);
00073 integer ihwmny;
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
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
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 --select;
00297 s_dim1 = *lds;
00298 s_offset = 1 + s_dim1;
00299 s -= s_offset;
00300 p_dim1 = *ldp;
00301 p_offset = 1 + p_dim1;
00302 p -= p_offset;
00303 vl_dim1 = *ldvl;
00304 vl_offset = 1 + vl_dim1;
00305 vl -= vl_offset;
00306 vr_dim1 = *ldvr;
00307 vr_offset = 1 + vr_dim1;
00308 vr -= vr_offset;
00309 --work;
00310
00311
00312 if (lsame_(howmny, "A")) {
00313 ihwmny = 1;
00314 ilall = TRUE_;
00315 ilback = FALSE_;
00316 } else if (lsame_(howmny, "S")) {
00317 ihwmny = 2;
00318 ilall = FALSE_;
00319 ilback = FALSE_;
00320 } else if (lsame_(howmny, "B")) {
00321 ihwmny = 3;
00322 ilall = TRUE_;
00323 ilback = TRUE_;
00324 } else {
00325 ihwmny = -1;
00326 ilall = TRUE_;
00327 }
00328
00329 if (lsame_(side, "R")) {
00330 iside = 1;
00331 compl = FALSE_;
00332 compr = TRUE_;
00333 } else if (lsame_(side, "L")) {
00334 iside = 2;
00335 compl = TRUE_;
00336 compr = FALSE_;
00337 } else if (lsame_(side, "B")) {
00338 iside = 3;
00339 compl = TRUE_;
00340 compr = TRUE_;
00341 } else {
00342 iside = -1;
00343 }
00344
00345 *info = 0;
00346 if (iside < 0) {
00347 *info = -1;
00348 } else if (ihwmny < 0) {
00349 *info = -2;
00350 } else if (*n < 0) {
00351 *info = -4;
00352 } else if (*lds < max(1,*n)) {
00353 *info = -6;
00354 } else if (*ldp < max(1,*n)) {
00355 *info = -8;
00356 }
00357 if (*info != 0) {
00358 i__1 = -(*info);
00359 xerbla_("STGEVC", &i__1);
00360 return 0;
00361 }
00362
00363
00364
00365 if (! ilall) {
00366 im = 0;
00367 ilcplx = FALSE_;
00368 i__1 = *n;
00369 for (j = 1; j <= i__1; ++j) {
00370 if (ilcplx) {
00371 ilcplx = FALSE_;
00372 goto L10;
00373 }
00374 if (j < *n) {
00375 if (s[j + 1 + j * s_dim1] != 0.f) {
00376 ilcplx = TRUE_;
00377 }
00378 }
00379 if (ilcplx) {
00380 if (select[j] || select[j + 1]) {
00381 im += 2;
00382 }
00383 } else {
00384 if (select[j]) {
00385 ++im;
00386 }
00387 }
00388 L10:
00389 ;
00390 }
00391 } else {
00392 im = *n;
00393 }
00394
00395
00396
00397 ilabad = FALSE_;
00398 ilbbad = FALSE_;
00399 i__1 = *n - 1;
00400 for (j = 1; j <= i__1; ++j) {
00401 if (s[j + 1 + j * s_dim1] != 0.f) {
00402 if (p[j + j * p_dim1] == 0.f || p[j + 1 + (j + 1) * p_dim1] ==
00403 0.f || p[j + (j + 1) * p_dim1] != 0.f) {
00404 ilbbad = TRUE_;
00405 }
00406 if (j < *n - 1) {
00407 if (s[j + 2 + (j + 1) * s_dim1] != 0.f) {
00408 ilabad = TRUE_;
00409 }
00410 }
00411 }
00412
00413 }
00414
00415 if (ilabad) {
00416 *info = -5;
00417 } else if (ilbbad) {
00418 *info = -7;
00419 } else if (compl && *ldvl < *n || *ldvl < 1) {
00420 *info = -10;
00421 } else if (compr && *ldvr < *n || *ldvr < 1) {
00422 *info = -12;
00423 } else if (*mm < im) {
00424 *info = -13;
00425 }
00426 if (*info != 0) {
00427 i__1 = -(*info);
00428 xerbla_("STGEVC", &i__1);
00429 return 0;
00430 }
00431
00432
00433
00434 *m = im;
00435 if (*n == 0) {
00436 return 0;
00437 }
00438
00439
00440
00441 safmin = slamch_("Safe minimum");
00442 big = 1.f / safmin;
00443 slabad_(&safmin, &big);
00444 ulp = slamch_("Epsilon") * slamch_("Base");
00445 small = safmin * *n / ulp;
00446 big = 1.f / small;
00447 bignum = 1.f / (safmin * *n);
00448
00449
00450
00451
00452
00453
00454 anorm = (r__1 = s[s_dim1 + 1], dabs(r__1));
00455 if (*n > 1) {
00456 anorm += (r__1 = s[s_dim1 + 2], dabs(r__1));
00457 }
00458 bnorm = (r__1 = p[p_dim1 + 1], dabs(r__1));
00459 work[1] = 0.f;
00460 work[*n + 1] = 0.f;
00461
00462 i__1 = *n;
00463 for (j = 2; j <= i__1; ++j) {
00464 temp = 0.f;
00465 temp2 = 0.f;
00466 if (s[j + (j - 1) * s_dim1] == 0.f) {
00467 iend = j - 1;
00468 } else {
00469 iend = j - 2;
00470 }
00471 i__2 = iend;
00472 for (i__ = 1; i__ <= i__2; ++i__) {
00473 temp += (r__1 = s[i__ + j * s_dim1], dabs(r__1));
00474 temp2 += (r__1 = p[i__ + j * p_dim1], dabs(r__1));
00475
00476 }
00477 work[j] = temp;
00478 work[*n + j] = temp2;
00479
00480 i__3 = j + 1;
00481 i__2 = min(i__3,*n);
00482 for (i__ = iend + 1; i__ <= i__2; ++i__) {
00483 temp += (r__1 = s[i__ + j * s_dim1], dabs(r__1));
00484 temp2 += (r__1 = p[i__ + j * p_dim1], dabs(r__1));
00485
00486 }
00487 anorm = dmax(anorm,temp);
00488 bnorm = dmax(bnorm,temp2);
00489
00490 }
00491
00492 ascale = 1.f / dmax(anorm,safmin);
00493 bscale = 1.f / dmax(bnorm,safmin);
00494
00495
00496
00497 if (compl) {
00498 ieig = 0;
00499
00500
00501
00502 ilcplx = FALSE_;
00503 i__1 = *n;
00504 for (je = 1; je <= i__1; ++je) {
00505
00506
00507
00508
00509
00510
00511 if (ilcplx) {
00512 ilcplx = FALSE_;
00513 goto L220;
00514 }
00515 nw = 1;
00516 if (je < *n) {
00517 if (s[je + 1 + je * s_dim1] != 0.f) {
00518 ilcplx = TRUE_;
00519 nw = 2;
00520 }
00521 }
00522 if (ilall) {
00523 ilcomp = TRUE_;
00524 } else if (ilcplx) {
00525 ilcomp = select[je] || select[je + 1];
00526 } else {
00527 ilcomp = select[je];
00528 }
00529 if (! ilcomp) {
00530 goto L220;
00531 }
00532
00533
00534
00535
00536 if (! ilcplx) {
00537 if ((r__1 = s[je + je * s_dim1], dabs(r__1)) <= safmin && (
00538 r__2 = p[je + je * p_dim1], dabs(r__2)) <= safmin) {
00539
00540
00541
00542 ++ieig;
00543 i__2 = *n;
00544 for (jr = 1; jr <= i__2; ++jr) {
00545 vl[jr + ieig * vl_dim1] = 0.f;
00546
00547 }
00548 vl[ieig + ieig * vl_dim1] = 1.f;
00549 goto L220;
00550 }
00551 }
00552
00553
00554
00555 i__2 = nw * *n;
00556 for (jr = 1; jr <= i__2; ++jr) {
00557 work[(*n << 1) + jr] = 0.f;
00558
00559 }
00560
00561
00562
00563
00564
00565 if (! ilcplx) {
00566
00567
00568
00569
00570 r__3 = (r__1 = s[je + je * s_dim1], dabs(r__1)) * ascale,
00571 r__4 = (r__2 = p[je + je * p_dim1], dabs(r__2)) *
00572 bscale, r__3 = max(r__3,r__4);
00573 temp = 1.f / dmax(r__3,safmin);
00574 salfar = temp * s[je + je * s_dim1] * ascale;
00575 sbeta = temp * p[je + je * p_dim1] * bscale;
00576 acoef = sbeta * ascale;
00577 bcoefr = salfar * bscale;
00578 bcoefi = 0.f;
00579
00580
00581
00582 scale = 1.f;
00583 lsa = dabs(sbeta) >= safmin && dabs(acoef) < small;
00584 lsb = dabs(salfar) >= safmin && dabs(bcoefr) < small;
00585 if (lsa) {
00586 scale = small / dabs(sbeta) * dmin(anorm,big);
00587 }
00588 if (lsb) {
00589
00590 r__1 = scale, r__2 = small / dabs(salfar) * dmin(bnorm,
00591 big);
00592 scale = dmax(r__1,r__2);
00593 }
00594 if (lsa || lsb) {
00595
00596
00597 r__3 = 1.f, r__4 = dabs(acoef), r__3 = max(r__3,r__4),
00598 r__4 = dabs(bcoefr);
00599 r__1 = scale, r__2 = 1.f / (safmin * dmax(r__3,r__4));
00600 scale = dmin(r__1,r__2);
00601 if (lsa) {
00602 acoef = ascale * (scale * sbeta);
00603 } else {
00604 acoef = scale * acoef;
00605 }
00606 if (lsb) {
00607 bcoefr = bscale * (scale * salfar);
00608 } else {
00609 bcoefr = scale * bcoefr;
00610 }
00611 }
00612 acoefa = dabs(acoef);
00613 bcoefa = dabs(bcoefr);
00614
00615
00616
00617 work[(*n << 1) + je] = 1.f;
00618 xmax = 1.f;
00619 } else {
00620
00621
00622
00623 r__1 = safmin * 100.f;
00624 slag2_(&s[je + je * s_dim1], lds, &p[je + je * p_dim1], ldp, &
00625 r__1, &acoef, &temp, &bcoefr, &temp2, &bcoefi);
00626 bcoefi = -bcoefi;
00627 if (bcoefi == 0.f) {
00628 *info = je;
00629 return 0;
00630 }
00631
00632
00633
00634 acoefa = dabs(acoef);
00635 bcoefa = dabs(bcoefr) + dabs(bcoefi);
00636 scale = 1.f;
00637 if (acoefa * ulp < safmin && acoefa >= safmin) {
00638 scale = safmin / ulp / acoefa;
00639 }
00640 if (bcoefa * ulp < safmin && bcoefa >= safmin) {
00641
00642 r__1 = scale, r__2 = safmin / ulp / bcoefa;
00643 scale = dmax(r__1,r__2);
00644 }
00645 if (safmin * acoefa > ascale) {
00646 scale = ascale / (safmin * acoefa);
00647 }
00648 if (safmin * bcoefa > bscale) {
00649
00650 r__1 = scale, r__2 = bscale / (safmin * bcoefa);
00651 scale = dmin(r__1,r__2);
00652 }
00653 if (scale != 1.f) {
00654 acoef = scale * acoef;
00655 acoefa = dabs(acoef);
00656 bcoefr = scale * bcoefr;
00657 bcoefi = scale * bcoefi;
00658 bcoefa = dabs(bcoefr) + dabs(bcoefi);
00659 }
00660
00661
00662
00663 temp = acoef * s[je + 1 + je * s_dim1];
00664 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je *
00665 p_dim1];
00666 temp2i = -bcoefi * p[je + je * p_dim1];
00667 if (dabs(temp) > dabs(temp2r) + dabs(temp2i)) {
00668 work[(*n << 1) + je] = 1.f;
00669 work[*n * 3 + je] = 0.f;
00670 work[(*n << 1) + je + 1] = -temp2r / temp;
00671 work[*n * 3 + je + 1] = -temp2i / temp;
00672 } else {
00673 work[(*n << 1) + je + 1] = 1.f;
00674 work[*n * 3 + je + 1] = 0.f;
00675 temp = acoef * s[je + (je + 1) * s_dim1];
00676 work[(*n << 1) + je] = (bcoefr * p[je + 1 + (je + 1) *
00677 p_dim1] - acoef * s[je + 1 + (je + 1) * s_dim1]) /
00678 temp;
00679 work[*n * 3 + je] = bcoefi * p[je + 1 + (je + 1) * p_dim1]
00680 / temp;
00681 }
00682
00683 r__5 = (r__1 = work[(*n << 1) + je], dabs(r__1)) + (r__2 =
00684 work[*n * 3 + je], dabs(r__2)), r__6 = (r__3 = work[(*
00685 n << 1) + je + 1], dabs(r__3)) + (r__4 = work[*n * 3
00686 + je + 1], dabs(r__4));
00687 xmax = dmax(r__5,r__6);
00688 }
00689
00690
00691 r__1 = ulp * acoefa * anorm, r__2 = ulp * bcoefa * bnorm, r__1 =
00692 max(r__1,r__2);
00693 dmin__ = dmax(r__1,safmin);
00694
00695
00696
00697
00698
00699
00700
00701 il2by2 = FALSE_;
00702
00703 i__2 = *n;
00704 for (j = je + nw; j <= i__2; ++j) {
00705 if (il2by2) {
00706 il2by2 = FALSE_;
00707 goto L160;
00708 }
00709
00710 na = 1;
00711 bdiag[0] = p[j + j * p_dim1];
00712 if (j < *n) {
00713 if (s[j + 1 + j * s_dim1] != 0.f) {
00714 il2by2 = TRUE_;
00715 bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
00716 na = 2;
00717 }
00718 }
00719
00720
00721
00722 xscale = 1.f / dmax(1.f,xmax);
00723
00724 r__1 = work[j], r__2 = work[*n + j], r__1 = max(r__1,r__2),
00725 r__2 = acoefa * work[j] + bcoefa * work[*n + j];
00726 temp = dmax(r__1,r__2);
00727 if (il2by2) {
00728
00729 r__1 = temp, r__2 = work[j + 1], r__1 = max(r__1,r__2),
00730 r__2 = work[*n + j + 1], r__1 = max(r__1,r__2),
00731 r__2 = acoefa * work[j + 1] + bcoefa * work[*n +
00732 j + 1];
00733 temp = dmax(r__1,r__2);
00734 }
00735 if (temp > bignum * xscale) {
00736 i__3 = nw - 1;
00737 for (jw = 0; jw <= i__3; ++jw) {
00738 i__4 = j - 1;
00739 for (jr = je; jr <= i__4; ++jr) {
00740 work[(jw + 2) * *n + jr] = xscale * work[(jw + 2)
00741 * *n + jr];
00742
00743 }
00744
00745 }
00746 xmax *= xscale;
00747 }
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780 i__3 = nw;
00781 for (jw = 1; jw <= i__3; ++jw) {
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795 i__4 = na;
00796 for (ja = 1; ja <= i__4; ++ja) {
00797 sums[ja + (jw << 1) - 3] = 0.f;
00798 sump[ja + (jw << 1) - 3] = 0.f;
00799
00800 i__5 = j - 1;
00801 for (jr = je; jr <= i__5; ++jr) {
00802 sums[ja + (jw << 1) - 3] += s[jr + (j + ja - 1) *
00803 s_dim1] * work[(jw + 1) * *n + jr];
00804 sump[ja + (jw << 1) - 3] += p[jr + (j + ja - 1) *
00805 p_dim1] * work[(jw + 1) * *n + jr];
00806
00807 }
00808
00809 }
00810
00811 }
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825 i__3 = na;
00826 for (ja = 1; ja <= i__3; ++ja) {
00827 if (ilcplx) {
00828 sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
00829 ja - 1] - bcoefi * sump[ja + 1];
00830 sum[ja + 1] = -acoef * sums[ja + 1] + bcoefr * sump[
00831 ja + 1] + bcoefi * sump[ja - 1];
00832 } else {
00833 sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
00834 ja - 1];
00835 }
00836
00837 }
00838
00839
00840
00841
00842
00843 slaln2_(&c_true, &na, &nw, &dmin__, &acoef, &s[j + j * s_dim1]
00844 , lds, bdiag, &bdiag[1], sum, &c__2, &bcoefr, &bcoefi,
00845 &work[(*n << 1) + j], n, &scale, &temp, &iinfo);
00846 if (scale < 1.f) {
00847 i__3 = nw - 1;
00848 for (jw = 0; jw <= i__3; ++jw) {
00849 i__4 = j - 1;
00850 for (jr = je; jr <= i__4; ++jr) {
00851 work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
00852 *n + jr];
00853
00854 }
00855
00856 }
00857 xmax = scale * xmax;
00858 }
00859 xmax = dmax(xmax,temp);
00860 L160:
00861 ;
00862 }
00863
00864
00865
00866
00867 ++ieig;
00868 if (ilback) {
00869 i__2 = nw - 1;
00870 for (jw = 0; jw <= i__2; ++jw) {
00871 i__3 = *n + 1 - je;
00872 sgemv_("N", n, &i__3, &c_b34, &vl[je * vl_dim1 + 1], ldvl,
00873 &work[(jw + 2) * *n + je], &c__1, &c_b36, &work[(
00874 jw + 4) * *n + 1], &c__1);
00875
00876 }
00877 slacpy_(" ", n, &nw, &work[(*n << 2) + 1], n, &vl[je *
00878 vl_dim1 + 1], ldvl);
00879 ibeg = 1;
00880 } else {
00881 slacpy_(" ", n, &nw, &work[(*n << 1) + 1], n, &vl[ieig *
00882 vl_dim1 + 1], ldvl);
00883 ibeg = je;
00884 }
00885
00886
00887
00888 xmax = 0.f;
00889 if (ilcplx) {
00890 i__2 = *n;
00891 for (j = ibeg; j <= i__2; ++j) {
00892
00893 r__3 = xmax, r__4 = (r__1 = vl[j + ieig * vl_dim1], dabs(
00894 r__1)) + (r__2 = vl[j + (ieig + 1) * vl_dim1],
00895 dabs(r__2));
00896 xmax = dmax(r__3,r__4);
00897
00898 }
00899 } else {
00900 i__2 = *n;
00901 for (j = ibeg; j <= i__2; ++j) {
00902
00903 r__2 = xmax, r__3 = (r__1 = vl[j + ieig * vl_dim1], dabs(
00904 r__1));
00905 xmax = dmax(r__2,r__3);
00906
00907 }
00908 }
00909
00910 if (xmax > safmin) {
00911 xscale = 1.f / xmax;
00912
00913 i__2 = nw - 1;
00914 for (jw = 0; jw <= i__2; ++jw) {
00915 i__3 = *n;
00916 for (jr = ibeg; jr <= i__3; ++jr) {
00917 vl[jr + (ieig + jw) * vl_dim1] = xscale * vl[jr + (
00918 ieig + jw) * vl_dim1];
00919
00920 }
00921
00922 }
00923 }
00924 ieig = ieig + nw - 1;
00925
00926 L220:
00927 ;
00928 }
00929 }
00930
00931
00932
00933 if (compr) {
00934 ieig = im + 1;
00935
00936
00937
00938 ilcplx = FALSE_;
00939 for (je = *n; je >= 1; --je) {
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949 if (ilcplx) {
00950 ilcplx = FALSE_;
00951 goto L500;
00952 }
00953 nw = 1;
00954 if (je > 1) {
00955 if (s[je + (je - 1) * s_dim1] != 0.f) {
00956 ilcplx = TRUE_;
00957 nw = 2;
00958 }
00959 }
00960 if (ilall) {
00961 ilcomp = TRUE_;
00962 } else if (ilcplx) {
00963 ilcomp = select[je] || select[je - 1];
00964 } else {
00965 ilcomp = select[je];
00966 }
00967 if (! ilcomp) {
00968 goto L500;
00969 }
00970
00971
00972
00973
00974 if (! ilcplx) {
00975 if ((r__1 = s[je + je * s_dim1], dabs(r__1)) <= safmin && (
00976 r__2 = p[je + je * p_dim1], dabs(r__2)) <= safmin) {
00977
00978
00979
00980 --ieig;
00981 i__1 = *n;
00982 for (jr = 1; jr <= i__1; ++jr) {
00983 vr[jr + ieig * vr_dim1] = 0.f;
00984
00985 }
00986 vr[ieig + ieig * vr_dim1] = 1.f;
00987 goto L500;
00988 }
00989 }
00990
00991
00992
00993 i__1 = nw - 1;
00994 for (jw = 0; jw <= i__1; ++jw) {
00995 i__2 = *n;
00996 for (jr = 1; jr <= i__2; ++jr) {
00997 work[(jw + 2) * *n + jr] = 0.f;
00998
00999 }
01000
01001 }
01002
01003
01004
01005
01006
01007 if (! ilcplx) {
01008
01009
01010
01011
01012 r__3 = (r__1 = s[je + je * s_dim1], dabs(r__1)) * ascale,
01013 r__4 = (r__2 = p[je + je * p_dim1], dabs(r__2)) *
01014 bscale, r__3 = max(r__3,r__4);
01015 temp = 1.f / dmax(r__3,safmin);
01016 salfar = temp * s[je + je * s_dim1] * ascale;
01017 sbeta = temp * p[je + je * p_dim1] * bscale;
01018 acoef = sbeta * ascale;
01019 bcoefr = salfar * bscale;
01020 bcoefi = 0.f;
01021
01022
01023
01024 scale = 1.f;
01025 lsa = dabs(sbeta) >= safmin && dabs(acoef) < small;
01026 lsb = dabs(salfar) >= safmin && dabs(bcoefr) < small;
01027 if (lsa) {
01028 scale = small / dabs(sbeta) * dmin(anorm,big);
01029 }
01030 if (lsb) {
01031
01032 r__1 = scale, r__2 = small / dabs(salfar) * dmin(bnorm,
01033 big);
01034 scale = dmax(r__1,r__2);
01035 }
01036 if (lsa || lsb) {
01037
01038
01039 r__3 = 1.f, r__4 = dabs(acoef), r__3 = max(r__3,r__4),
01040 r__4 = dabs(bcoefr);
01041 r__1 = scale, r__2 = 1.f / (safmin * dmax(r__3,r__4));
01042 scale = dmin(r__1,r__2);
01043 if (lsa) {
01044 acoef = ascale * (scale * sbeta);
01045 } else {
01046 acoef = scale * acoef;
01047 }
01048 if (lsb) {
01049 bcoefr = bscale * (scale * salfar);
01050 } else {
01051 bcoefr = scale * bcoefr;
01052 }
01053 }
01054 acoefa = dabs(acoef);
01055 bcoefa = dabs(bcoefr);
01056
01057
01058
01059 work[(*n << 1) + je] = 1.f;
01060 xmax = 1.f;
01061
01062
01063
01064
01065 i__1 = je - 1;
01066 for (jr = 1; jr <= i__1; ++jr) {
01067 work[(*n << 1) + jr] = bcoefr * p[jr + je * p_dim1] -
01068 acoef * s[jr + je * s_dim1];
01069
01070 }
01071 } else {
01072
01073
01074
01075 r__1 = safmin * 100.f;
01076 slag2_(&s[je - 1 + (je - 1) * s_dim1], lds, &p[je - 1 + (je -
01077 1) * p_dim1], ldp, &r__1, &acoef, &temp, &bcoefr, &
01078 temp2, &bcoefi);
01079 if (bcoefi == 0.f) {
01080 *info = je - 1;
01081 return 0;
01082 }
01083
01084
01085
01086 acoefa = dabs(acoef);
01087 bcoefa = dabs(bcoefr) + dabs(bcoefi);
01088 scale = 1.f;
01089 if (acoefa * ulp < safmin && acoefa >= safmin) {
01090 scale = safmin / ulp / acoefa;
01091 }
01092 if (bcoefa * ulp < safmin && bcoefa >= safmin) {
01093
01094 r__1 = scale, r__2 = safmin / ulp / bcoefa;
01095 scale = dmax(r__1,r__2);
01096 }
01097 if (safmin * acoefa > ascale) {
01098 scale = ascale / (safmin * acoefa);
01099 }
01100 if (safmin * bcoefa > bscale) {
01101
01102 r__1 = scale, r__2 = bscale / (safmin * bcoefa);
01103 scale = dmin(r__1,r__2);
01104 }
01105 if (scale != 1.f) {
01106 acoef = scale * acoef;
01107 acoefa = dabs(acoef);
01108 bcoefr = scale * bcoefr;
01109 bcoefi = scale * bcoefi;
01110 bcoefa = dabs(bcoefr) + dabs(bcoefi);
01111 }
01112
01113
01114
01115
01116 temp = acoef * s[je + (je - 1) * s_dim1];
01117 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je *
01118 p_dim1];
01119 temp2i = -bcoefi * p[je + je * p_dim1];
01120 if (dabs(temp) >= dabs(temp2r) + dabs(temp2i)) {
01121 work[(*n << 1) + je] = 1.f;
01122 work[*n * 3 + je] = 0.f;
01123 work[(*n << 1) + je - 1] = -temp2r / temp;
01124 work[*n * 3 + je - 1] = -temp2i / temp;
01125 } else {
01126 work[(*n << 1) + je - 1] = 1.f;
01127 work[*n * 3 + je - 1] = 0.f;
01128 temp = acoef * s[je - 1 + je * s_dim1];
01129 work[(*n << 1) + je] = (bcoefr * p[je - 1 + (je - 1) *
01130 p_dim1] - acoef * s[je - 1 + (je - 1) * s_dim1]) /
01131 temp;
01132 work[*n * 3 + je] = bcoefi * p[je - 1 + (je - 1) * p_dim1]
01133 / temp;
01134 }
01135
01136
01137 r__5 = (r__1 = work[(*n << 1) + je], dabs(r__1)) + (r__2 =
01138 work[*n * 3 + je], dabs(r__2)), r__6 = (r__3 = work[(*
01139 n << 1) + je - 1], dabs(r__3)) + (r__4 = work[*n * 3
01140 + je - 1], dabs(r__4));
01141 xmax = dmax(r__5,r__6);
01142
01143
01144
01145
01146 creala = acoef * work[(*n << 1) + je - 1];
01147 cimaga = acoef * work[*n * 3 + je - 1];
01148 crealb = bcoefr * work[(*n << 1) + je - 1] - bcoefi * work[*n
01149 * 3 + je - 1];
01150 cimagb = bcoefi * work[(*n << 1) + je - 1] + bcoefr * work[*n
01151 * 3 + je - 1];
01152 cre2a = acoef * work[(*n << 1) + je];
01153 cim2a = acoef * work[*n * 3 + je];
01154 cre2b = bcoefr * work[(*n << 1) + je] - bcoefi * work[*n * 3
01155 + je];
01156 cim2b = bcoefi * work[(*n << 1) + je] + bcoefr * work[*n * 3
01157 + je];
01158 i__1 = je - 2;
01159 for (jr = 1; jr <= i__1; ++jr) {
01160 work[(*n << 1) + jr] = -creala * s[jr + (je - 1) * s_dim1]
01161 + crealb * p[jr + (je - 1) * p_dim1] - cre2a * s[
01162 jr + je * s_dim1] + cre2b * p[jr + je * p_dim1];
01163 work[*n * 3 + jr] = -cimaga * s[jr + (je - 1) * s_dim1] +
01164 cimagb * p[jr + (je - 1) * p_dim1] - cim2a * s[jr
01165 + je * s_dim1] + cim2b * p[jr + je * p_dim1];
01166
01167 }
01168 }
01169
01170
01171 r__1 = ulp * acoefa * anorm, r__2 = ulp * bcoefa * bnorm, r__1 =
01172 max(r__1,r__2);
01173 dmin__ = dmax(r__1,safmin);
01174
01175
01176
01177 il2by2 = FALSE_;
01178 for (j = je - nw; j >= 1; --j) {
01179
01180
01181
01182
01183 if (! il2by2 && j > 1) {
01184 if (s[j + (j - 1) * s_dim1] != 0.f) {
01185 il2by2 = TRUE_;
01186 goto L370;
01187 }
01188 }
01189 bdiag[0] = p[j + j * p_dim1];
01190 if (il2by2) {
01191 na = 2;
01192 bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
01193 } else {
01194 na = 1;
01195 }
01196
01197
01198
01199 slaln2_(&c_false, &na, &nw, &dmin__, &acoef, &s[j + j *
01200 s_dim1], lds, bdiag, &bdiag[1], &work[(*n << 1) + j],
01201 n, &bcoefr, &bcoefi, sum, &c__2, &scale, &temp, &
01202 iinfo);
01203 if (scale < 1.f) {
01204
01205 i__1 = nw - 1;
01206 for (jw = 0; jw <= i__1; ++jw) {
01207 i__2 = je;
01208 for (jr = 1; jr <= i__2; ++jr) {
01209 work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
01210 *n + jr];
01211
01212 }
01213
01214 }
01215 }
01216
01217 r__1 = scale * xmax;
01218 xmax = dmax(r__1,temp);
01219
01220 i__1 = nw;
01221 for (jw = 1; jw <= i__1; ++jw) {
01222 i__2 = na;
01223 for (ja = 1; ja <= i__2; ++ja) {
01224 work[(jw + 1) * *n + j + ja - 1] = sum[ja + (jw << 1)
01225 - 3];
01226
01227 }
01228
01229 }
01230
01231
01232
01233 if (j > 1) {
01234
01235
01236
01237 xscale = 1.f / dmax(1.f,xmax);
01238 temp = acoefa * work[j] + bcoefa * work[*n + j];
01239 if (il2by2) {
01240
01241 r__1 = temp, r__2 = acoefa * work[j + 1] + bcoefa *
01242 work[*n + j + 1];
01243 temp = dmax(r__1,r__2);
01244 }
01245
01246 r__1 = max(temp,acoefa);
01247 temp = dmax(r__1,bcoefa);
01248 if (temp > bignum * xscale) {
01249
01250 i__1 = nw - 1;
01251 for (jw = 0; jw <= i__1; ++jw) {
01252 i__2 = je;
01253 for (jr = 1; jr <= i__2; ++jr) {
01254 work[(jw + 2) * *n + jr] = xscale * work[(jw
01255 + 2) * *n + jr];
01256
01257 }
01258
01259 }
01260 xmax *= xscale;
01261 }
01262
01263
01264
01265
01266
01267
01268 i__1 = na;
01269 for (ja = 1; ja <= i__1; ++ja) {
01270 if (ilcplx) {
01271 creala = acoef * work[(*n << 1) + j + ja - 1];
01272 cimaga = acoef * work[*n * 3 + j + ja - 1];
01273 crealb = bcoefr * work[(*n << 1) + j + ja - 1] -
01274 bcoefi * work[*n * 3 + j + ja - 1];
01275 cimagb = bcoefi * work[(*n << 1) + j + ja - 1] +
01276 bcoefr * work[*n * 3 + j + ja - 1];
01277 i__2 = j - 1;
01278 for (jr = 1; jr <= i__2; ++jr) {
01279 work[(*n << 1) + jr] = work[(*n << 1) + jr] -
01280 creala * s[jr + (j + ja - 1) * s_dim1]
01281 + crealb * p[jr + (j + ja - 1) *
01282 p_dim1];
01283 work[*n * 3 + jr] = work[*n * 3 + jr] -
01284 cimaga * s[jr + (j + ja - 1) * s_dim1]
01285 + cimagb * p[jr + (j + ja - 1) *
01286 p_dim1];
01287
01288 }
01289 } else {
01290 creala = acoef * work[(*n << 1) + j + ja - 1];
01291 crealb = bcoefr * work[(*n << 1) + j + ja - 1];
01292 i__2 = j - 1;
01293 for (jr = 1; jr <= i__2; ++jr) {
01294 work[(*n << 1) + jr] = work[(*n << 1) + jr] -
01295 creala * s[jr + (j + ja - 1) * s_dim1]
01296 + crealb * p[jr + (j + ja - 1) *
01297 p_dim1];
01298
01299 }
01300 }
01301
01302 }
01303 }
01304
01305 il2by2 = FALSE_;
01306 L370:
01307 ;
01308 }
01309
01310
01311
01312
01313 ieig -= nw;
01314 if (ilback) {
01315
01316 i__1 = nw - 1;
01317 for (jw = 0; jw <= i__1; ++jw) {
01318 i__2 = *n;
01319 for (jr = 1; jr <= i__2; ++jr) {
01320 work[(jw + 4) * *n + jr] = work[(jw + 2) * *n + 1] *
01321 vr[jr + vr_dim1];
01322
01323 }
01324
01325
01326
01327
01328
01329 i__2 = je;
01330 for (jc = 2; jc <= i__2; ++jc) {
01331 i__3 = *n;
01332 for (jr = 1; jr <= i__3; ++jr) {
01333 work[(jw + 4) * *n + jr] += work[(jw + 2) * *n +
01334 jc] * vr[jr + jc * vr_dim1];
01335
01336 }
01337
01338 }
01339
01340 }
01341
01342 i__1 = nw - 1;
01343 for (jw = 0; jw <= i__1; ++jw) {
01344 i__2 = *n;
01345 for (jr = 1; jr <= i__2; ++jr) {
01346 vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 4) * *n +
01347 jr];
01348
01349 }
01350
01351 }
01352
01353 iend = *n;
01354 } else {
01355 i__1 = nw - 1;
01356 for (jw = 0; jw <= i__1; ++jw) {
01357 i__2 = *n;
01358 for (jr = 1; jr <= i__2; ++jr) {
01359 vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 2) * *n +
01360 jr];
01361
01362 }
01363
01364 }
01365
01366 iend = je;
01367 }
01368
01369
01370
01371 xmax = 0.f;
01372 if (ilcplx) {
01373 i__1 = iend;
01374 for (j = 1; j <= i__1; ++j) {
01375
01376 r__3 = xmax, r__4 = (r__1 = vr[j + ieig * vr_dim1], dabs(
01377 r__1)) + (r__2 = vr[j + (ieig + 1) * vr_dim1],
01378 dabs(r__2));
01379 xmax = dmax(r__3,r__4);
01380
01381 }
01382 } else {
01383 i__1 = iend;
01384 for (j = 1; j <= i__1; ++j) {
01385
01386 r__2 = xmax, r__3 = (r__1 = vr[j + ieig * vr_dim1], dabs(
01387 r__1));
01388 xmax = dmax(r__2,r__3);
01389
01390 }
01391 }
01392
01393 if (xmax > safmin) {
01394 xscale = 1.f / xmax;
01395 i__1 = nw - 1;
01396 for (jw = 0; jw <= i__1; ++jw) {
01397 i__2 = iend;
01398 for (jr = 1; jr <= i__2; ++jr) {
01399 vr[jr + (ieig + jw) * vr_dim1] = xscale * vr[jr + (
01400 ieig + jw) * vr_dim1];
01401
01402 }
01403
01404 }
01405 }
01406 L500:
01407 ;
01408 }
01409 }
01410
01411 return 0;
01412
01413
01414
01415 }