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 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021
00022 int ztgevc_(char *side, char *howmny, logical *select,
00023 integer *n, doublecomplex *s, integer *lds, doublecomplex *p, integer
00024 *ldp, doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *
00025 ldvr, integer *mm, integer *m, doublecomplex *work, doublereal *rwork,
00026 integer *info)
00027 {
00028
00029 integer p_dim1, p_offset, s_dim1, s_offset, vl_dim1, vl_offset, vr_dim1,
00030 vr_offset, i__1, i__2, i__3, i__4, i__5;
00031 doublereal d__1, d__2, d__3, d__4, d__5, d__6;
00032 doublecomplex z__1, z__2, z__3, z__4;
00033
00034
00035 double d_imag(doublecomplex *);
00036 void d_cnjg(doublecomplex *, doublecomplex *);
00037
00038
00039 doublecomplex d__;
00040 integer i__, j;
00041 doublecomplex ca, cb;
00042 integer je, im, jr;
00043 doublereal big;
00044 logical lsa, lsb;
00045 doublereal ulp;
00046 doublecomplex sum;
00047 integer ibeg, ieig, iend;
00048 doublereal dmin__;
00049 integer isrc;
00050 doublereal temp;
00051 doublecomplex suma, sumb;
00052 doublereal xmax, scale;
00053 logical ilall;
00054 integer iside;
00055 doublereal sbeta;
00056 extern logical lsame_(char *, char *);
00057 doublereal small;
00058 logical compl;
00059 doublereal anorm, bnorm;
00060 logical compr;
00061 extern int zgemv_(char *, integer *, integer *,
00062 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00063 integer *, doublecomplex *, doublecomplex *, integer *),
00064 dlabad_(doublereal *, doublereal *);
00065 logical ilbbad;
00066 doublereal acoefa, bcoefa, acoeff;
00067 doublecomplex bcoeff;
00068 logical ilback;
00069 doublereal ascale, bscale;
00070 extern doublereal dlamch_(char *);
00071 doublecomplex salpha;
00072 doublereal safmin;
00073 extern int xerbla_(char *, integer *);
00074 doublereal bignum;
00075 logical ilcomp;
00076 extern VOID zladiv_(doublecomplex *, doublecomplex *,
00077 doublecomplex *);
00078 integer ihwmny;
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 --select;
00228 s_dim1 = *lds;
00229 s_offset = 1 + s_dim1;
00230 s -= s_offset;
00231 p_dim1 = *ldp;
00232 p_offset = 1 + p_dim1;
00233 p -= p_offset;
00234 vl_dim1 = *ldvl;
00235 vl_offset = 1 + vl_dim1;
00236 vl -= vl_offset;
00237 vr_dim1 = *ldvr;
00238 vr_offset = 1 + vr_dim1;
00239 vr -= vr_offset;
00240 --work;
00241 --rwork;
00242
00243
00244 if (lsame_(howmny, "A")) {
00245 ihwmny = 1;
00246 ilall = TRUE_;
00247 ilback = FALSE_;
00248 } else if (lsame_(howmny, "S")) {
00249 ihwmny = 2;
00250 ilall = FALSE_;
00251 ilback = FALSE_;
00252 } else if (lsame_(howmny, "B")) {
00253 ihwmny = 3;
00254 ilall = TRUE_;
00255 ilback = TRUE_;
00256 } else {
00257 ihwmny = -1;
00258 }
00259
00260 if (lsame_(side, "R")) {
00261 iside = 1;
00262 compl = FALSE_;
00263 compr = TRUE_;
00264 } else if (lsame_(side, "L")) {
00265 iside = 2;
00266 compl = TRUE_;
00267 compr = FALSE_;
00268 } else if (lsame_(side, "B")) {
00269 iside = 3;
00270 compl = TRUE_;
00271 compr = TRUE_;
00272 } else {
00273 iside = -1;
00274 }
00275
00276 *info = 0;
00277 if (iside < 0) {
00278 *info = -1;
00279 } else if (ihwmny < 0) {
00280 *info = -2;
00281 } else if (*n < 0) {
00282 *info = -4;
00283 } else if (*lds < max(1,*n)) {
00284 *info = -6;
00285 } else if (*ldp < max(1,*n)) {
00286 *info = -8;
00287 }
00288 if (*info != 0) {
00289 i__1 = -(*info);
00290 xerbla_("ZTGEVC", &i__1);
00291 return 0;
00292 }
00293
00294
00295
00296 if (! ilall) {
00297 im = 0;
00298 i__1 = *n;
00299 for (j = 1; j <= i__1; ++j) {
00300 if (select[j]) {
00301 ++im;
00302 }
00303
00304 }
00305 } else {
00306 im = *n;
00307 }
00308
00309
00310
00311 ilbbad = FALSE_;
00312 i__1 = *n;
00313 for (j = 1; j <= i__1; ++j) {
00314 if (d_imag(&p[j + j * p_dim1]) != 0.) {
00315 ilbbad = TRUE_;
00316 }
00317
00318 }
00319
00320 if (ilbbad) {
00321 *info = -7;
00322 } else if (compl && *ldvl < *n || *ldvl < 1) {
00323 *info = -10;
00324 } else if (compr && *ldvr < *n || *ldvr < 1) {
00325 *info = -12;
00326 } else if (*mm < im) {
00327 *info = -13;
00328 }
00329 if (*info != 0) {
00330 i__1 = -(*info);
00331 xerbla_("ZTGEVC", &i__1);
00332 return 0;
00333 }
00334
00335
00336
00337 *m = im;
00338 if (*n == 0) {
00339 return 0;
00340 }
00341
00342
00343
00344 safmin = dlamch_("Safe minimum");
00345 big = 1. / safmin;
00346 dlabad_(&safmin, &big);
00347 ulp = dlamch_("Epsilon") * dlamch_("Base");
00348 small = safmin * *n / ulp;
00349 big = 1. / small;
00350 bignum = 1. / (safmin * *n);
00351
00352
00353
00354
00355
00356 i__1 = s_dim1 + 1;
00357 anorm = (d__1 = s[i__1].r, abs(d__1)) + (d__2 = d_imag(&s[s_dim1 + 1]),
00358 abs(d__2));
00359 i__1 = p_dim1 + 1;
00360 bnorm = (d__1 = p[i__1].r, abs(d__1)) + (d__2 = d_imag(&p[p_dim1 + 1]),
00361 abs(d__2));
00362 rwork[1] = 0.;
00363 rwork[*n + 1] = 0.;
00364 i__1 = *n;
00365 for (j = 2; j <= i__1; ++j) {
00366 rwork[j] = 0.;
00367 rwork[*n + j] = 0.;
00368 i__2 = j - 1;
00369 for (i__ = 1; i__ <= i__2; ++i__) {
00370 i__3 = i__ + j * s_dim1;
00371 rwork[j] += (d__1 = s[i__3].r, abs(d__1)) + (d__2 = d_imag(&s[i__
00372 + j * s_dim1]), abs(d__2));
00373 i__3 = i__ + j * p_dim1;
00374 rwork[*n + j] += (d__1 = p[i__3].r, abs(d__1)) + (d__2 = d_imag(&
00375 p[i__ + j * p_dim1]), abs(d__2));
00376
00377 }
00378
00379 i__2 = j + j * s_dim1;
00380 d__3 = anorm, d__4 = rwork[j] + ((d__1 = s[i__2].r, abs(d__1)) + (
00381 d__2 = d_imag(&s[j + j * s_dim1]), abs(d__2)));
00382 anorm = max(d__3,d__4);
00383
00384 i__2 = j + j * p_dim1;
00385 d__3 = bnorm, d__4 = rwork[*n + j] + ((d__1 = p[i__2].r, abs(d__1)) +
00386 (d__2 = d_imag(&p[j + j * p_dim1]), abs(d__2)));
00387 bnorm = max(d__3,d__4);
00388
00389 }
00390
00391 ascale = 1. / max(anorm,safmin);
00392 bscale = 1. / max(bnorm,safmin);
00393
00394
00395
00396 if (compl) {
00397 ieig = 0;
00398
00399
00400
00401 i__1 = *n;
00402 for (je = 1; je <= i__1; ++je) {
00403 if (ilall) {
00404 ilcomp = TRUE_;
00405 } else {
00406 ilcomp = select[je];
00407 }
00408 if (ilcomp) {
00409 ++ieig;
00410
00411 i__2 = je + je * s_dim1;
00412 i__3 = je + je * p_dim1;
00413 if ((d__2 = s[i__2].r, abs(d__2)) + (d__3 = d_imag(&s[je + je
00414 * s_dim1]), abs(d__3)) <= safmin && (d__1 = p[i__3].r,
00415 abs(d__1)) <= safmin) {
00416
00417
00418
00419 i__2 = *n;
00420 for (jr = 1; jr <= i__2; ++jr) {
00421 i__3 = jr + ieig * vl_dim1;
00422 vl[i__3].r = 0., vl[i__3].i = 0.;
00423
00424 }
00425 i__2 = ieig + ieig * vl_dim1;
00426 vl[i__2].r = 1., vl[i__2].i = 0.;
00427 goto L140;
00428 }
00429
00430
00431
00432
00433
00434
00435
00436 i__2 = je + je * s_dim1;
00437 i__3 = je + je * p_dim1;
00438 d__4 = ((d__2 = s[i__2].r, abs(d__2)) + (d__3 = d_imag(&s[je
00439 + je * s_dim1]), abs(d__3))) * ascale, d__5 = (d__1 =
00440 p[i__3].r, abs(d__1)) * bscale, d__4 = max(d__4,d__5);
00441 temp = 1. / max(d__4,safmin);
00442 i__2 = je + je * s_dim1;
00443 z__2.r = temp * s[i__2].r, z__2.i = temp * s[i__2].i;
00444 z__1.r = ascale * z__2.r, z__1.i = ascale * z__2.i;
00445 salpha.r = z__1.r, salpha.i = z__1.i;
00446 i__2 = je + je * p_dim1;
00447 sbeta = temp * p[i__2].r * bscale;
00448 acoeff = sbeta * ascale;
00449 z__1.r = bscale * salpha.r, z__1.i = bscale * salpha.i;
00450 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00451
00452
00453
00454 lsa = abs(sbeta) >= safmin && abs(acoeff) < small;
00455 lsb = (d__1 = salpha.r, abs(d__1)) + (d__2 = d_imag(&salpha),
00456 abs(d__2)) >= safmin && (d__3 = bcoeff.r, abs(d__3))
00457 + (d__4 = d_imag(&bcoeff), abs(d__4)) < small;
00458
00459 scale = 1.;
00460 if (lsa) {
00461 scale = small / abs(sbeta) * min(anorm,big);
00462 }
00463 if (lsb) {
00464
00465 d__3 = scale, d__4 = small / ((d__1 = salpha.r, abs(d__1))
00466 + (d__2 = d_imag(&salpha), abs(d__2))) * min(
00467 bnorm,big);
00468 scale = max(d__3,d__4);
00469 }
00470 if (lsa || lsb) {
00471
00472
00473 d__5 = 1., d__6 = abs(acoeff), d__5 = max(d__5,d__6),
00474 d__6 = (d__1 = bcoeff.r, abs(d__1)) + (d__2 =
00475 d_imag(&bcoeff), abs(d__2));
00476 d__3 = scale, d__4 = 1. / (safmin * max(d__5,d__6));
00477 scale = min(d__3,d__4);
00478 if (lsa) {
00479 acoeff = ascale * (scale * sbeta);
00480 } else {
00481 acoeff = scale * acoeff;
00482 }
00483 if (lsb) {
00484 z__2.r = scale * salpha.r, z__2.i = scale * salpha.i;
00485 z__1.r = bscale * z__2.r, z__1.i = bscale * z__2.i;
00486 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00487 } else {
00488 z__1.r = scale * bcoeff.r, z__1.i = scale * bcoeff.i;
00489 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00490 }
00491 }
00492
00493 acoefa = abs(acoeff);
00494 bcoefa = (d__1 = bcoeff.r, abs(d__1)) + (d__2 = d_imag(&
00495 bcoeff), abs(d__2));
00496 xmax = 1.;
00497 i__2 = *n;
00498 for (jr = 1; jr <= i__2; ++jr) {
00499 i__3 = jr;
00500 work[i__3].r = 0., work[i__3].i = 0.;
00501
00502 }
00503 i__2 = je;
00504 work[i__2].r = 1., work[i__2].i = 0.;
00505
00506 d__1 = ulp * acoefa * anorm, d__2 = ulp * bcoefa * bnorm,
00507 d__1 = max(d__1,d__2);
00508 dmin__ = max(d__1,safmin);
00509
00510
00511
00512
00513
00514
00515
00516 i__2 = *n;
00517 for (j = je + 1; j <= i__2; ++j) {
00518
00519
00520
00521
00522
00523
00524
00525 temp = 1. / xmax;
00526 if (acoefa * rwork[j] + bcoefa * rwork[*n + j] > bignum *
00527 temp) {
00528 i__3 = j - 1;
00529 for (jr = je; jr <= i__3; ++jr) {
00530 i__4 = jr;
00531 i__5 = jr;
00532 z__1.r = temp * work[i__5].r, z__1.i = temp *
00533 work[i__5].i;
00534 work[i__4].r = z__1.r, work[i__4].i = z__1.i;
00535
00536 }
00537 xmax = 1.;
00538 }
00539 suma.r = 0., suma.i = 0.;
00540 sumb.r = 0., sumb.i = 0.;
00541
00542 i__3 = j - 1;
00543 for (jr = je; jr <= i__3; ++jr) {
00544 d_cnjg(&z__3, &s[jr + j * s_dim1]);
00545 i__4 = jr;
00546 z__2.r = z__3.r * work[i__4].r - z__3.i * work[i__4]
00547 .i, z__2.i = z__3.r * work[i__4].i + z__3.i *
00548 work[i__4].r;
00549 z__1.r = suma.r + z__2.r, z__1.i = suma.i + z__2.i;
00550 suma.r = z__1.r, suma.i = z__1.i;
00551 d_cnjg(&z__3, &p[jr + j * p_dim1]);
00552 i__4 = jr;
00553 z__2.r = z__3.r * work[i__4].r - z__3.i * work[i__4]
00554 .i, z__2.i = z__3.r * work[i__4].i + z__3.i *
00555 work[i__4].r;
00556 z__1.r = sumb.r + z__2.r, z__1.i = sumb.i + z__2.i;
00557 sumb.r = z__1.r, sumb.i = z__1.i;
00558
00559 }
00560 z__2.r = acoeff * suma.r, z__2.i = acoeff * suma.i;
00561 d_cnjg(&z__4, &bcoeff);
00562 z__3.r = z__4.r * sumb.r - z__4.i * sumb.i, z__3.i =
00563 z__4.r * sumb.i + z__4.i * sumb.r;
00564 z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
00565 sum.r = z__1.r, sum.i = z__1.i;
00566
00567
00568
00569
00570
00571 i__3 = j + j * s_dim1;
00572 z__3.r = acoeff * s[i__3].r, z__3.i = acoeff * s[i__3].i;
00573 i__4 = j + j * p_dim1;
00574 z__4.r = bcoeff.r * p[i__4].r - bcoeff.i * p[i__4].i,
00575 z__4.i = bcoeff.r * p[i__4].i + bcoeff.i * p[i__4]
00576 .r;
00577 z__2.r = z__3.r - z__4.r, z__2.i = z__3.i - z__4.i;
00578 d_cnjg(&z__1, &z__2);
00579 d__.r = z__1.r, d__.i = z__1.i;
00580 if ((d__1 = d__.r, abs(d__1)) + (d__2 = d_imag(&d__), abs(
00581 d__2)) <= dmin__) {
00582 z__1.r = dmin__, z__1.i = 0.;
00583 d__.r = z__1.r, d__.i = z__1.i;
00584 }
00585
00586 if ((d__1 = d__.r, abs(d__1)) + (d__2 = d_imag(&d__), abs(
00587 d__2)) < 1.) {
00588 if ((d__1 = sum.r, abs(d__1)) + (d__2 = d_imag(&sum),
00589 abs(d__2)) >= bignum * ((d__3 = d__.r, abs(
00590 d__3)) + (d__4 = d_imag(&d__), abs(d__4)))) {
00591 temp = 1. / ((d__1 = sum.r, abs(d__1)) + (d__2 =
00592 d_imag(&sum), abs(d__2)));
00593 i__3 = j - 1;
00594 for (jr = je; jr <= i__3; ++jr) {
00595 i__4 = jr;
00596 i__5 = jr;
00597 z__1.r = temp * work[i__5].r, z__1.i = temp *
00598 work[i__5].i;
00599 work[i__4].r = z__1.r, work[i__4].i = z__1.i;
00600
00601 }
00602 xmax = temp * xmax;
00603 z__1.r = temp * sum.r, z__1.i = temp * sum.i;
00604 sum.r = z__1.r, sum.i = z__1.i;
00605 }
00606 }
00607 i__3 = j;
00608 z__2.r = -sum.r, z__2.i = -sum.i;
00609 zladiv_(&z__1, &z__2, &d__);
00610 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00611
00612 i__3 = j;
00613 d__3 = xmax, d__4 = (d__1 = work[i__3].r, abs(d__1)) + (
00614 d__2 = d_imag(&work[j]), abs(d__2));
00615 xmax = max(d__3,d__4);
00616
00617 }
00618
00619
00620
00621 if (ilback) {
00622 i__2 = *n + 1 - je;
00623 zgemv_("N", n, &i__2, &c_b2, &vl[je * vl_dim1 + 1], ldvl,
00624 &work[je], &c__1, &c_b1, &work[*n + 1], &c__1);
00625 isrc = 2;
00626 ibeg = 1;
00627 } else {
00628 isrc = 1;
00629 ibeg = je;
00630 }
00631
00632
00633
00634 xmax = 0.;
00635 i__2 = *n;
00636 for (jr = ibeg; jr <= i__2; ++jr) {
00637
00638 i__3 = (isrc - 1) * *n + jr;
00639 d__3 = xmax, d__4 = (d__1 = work[i__3].r, abs(d__1)) + (
00640 d__2 = d_imag(&work[(isrc - 1) * *n + jr]), abs(
00641 d__2));
00642 xmax = max(d__3,d__4);
00643
00644 }
00645
00646 if (xmax > safmin) {
00647 temp = 1. / xmax;
00648 i__2 = *n;
00649 for (jr = ibeg; jr <= i__2; ++jr) {
00650 i__3 = jr + ieig * vl_dim1;
00651 i__4 = (isrc - 1) * *n + jr;
00652 z__1.r = temp * work[i__4].r, z__1.i = temp * work[
00653 i__4].i;
00654 vl[i__3].r = z__1.r, vl[i__3].i = z__1.i;
00655
00656 }
00657 } else {
00658 ibeg = *n + 1;
00659 }
00660
00661 i__2 = ibeg - 1;
00662 for (jr = 1; jr <= i__2; ++jr) {
00663 i__3 = jr + ieig * vl_dim1;
00664 vl[i__3].r = 0., vl[i__3].i = 0.;
00665
00666 }
00667
00668 }
00669 L140:
00670 ;
00671 }
00672 }
00673
00674
00675
00676 if (compr) {
00677 ieig = im + 1;
00678
00679
00680
00681 for (je = *n; je >= 1; --je) {
00682 if (ilall) {
00683 ilcomp = TRUE_;
00684 } else {
00685 ilcomp = select[je];
00686 }
00687 if (ilcomp) {
00688 --ieig;
00689
00690 i__1 = je + je * s_dim1;
00691 i__2 = je + je * p_dim1;
00692 if ((d__2 = s[i__1].r, abs(d__2)) + (d__3 = d_imag(&s[je + je
00693 * s_dim1]), abs(d__3)) <= safmin && (d__1 = p[i__2].r,
00694 abs(d__1)) <= safmin) {
00695
00696
00697
00698 i__1 = *n;
00699 for (jr = 1; jr <= i__1; ++jr) {
00700 i__2 = jr + ieig * vr_dim1;
00701 vr[i__2].r = 0., vr[i__2].i = 0.;
00702
00703 }
00704 i__1 = ieig + ieig * vr_dim1;
00705 vr[i__1].r = 1., vr[i__1].i = 0.;
00706 goto L250;
00707 }
00708
00709
00710
00711
00712
00713
00714
00715 i__1 = je + je * s_dim1;
00716 i__2 = je + je * p_dim1;
00717 d__4 = ((d__2 = s[i__1].r, abs(d__2)) + (d__3 = d_imag(&s[je
00718 + je * s_dim1]), abs(d__3))) * ascale, d__5 = (d__1 =
00719 p[i__2].r, abs(d__1)) * bscale, d__4 = max(d__4,d__5);
00720 temp = 1. / max(d__4,safmin);
00721 i__1 = je + je * s_dim1;
00722 z__2.r = temp * s[i__1].r, z__2.i = temp * s[i__1].i;
00723 z__1.r = ascale * z__2.r, z__1.i = ascale * z__2.i;
00724 salpha.r = z__1.r, salpha.i = z__1.i;
00725 i__1 = je + je * p_dim1;
00726 sbeta = temp * p[i__1].r * bscale;
00727 acoeff = sbeta * ascale;
00728 z__1.r = bscale * salpha.r, z__1.i = bscale * salpha.i;
00729 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00730
00731
00732
00733 lsa = abs(sbeta) >= safmin && abs(acoeff) < small;
00734 lsb = (d__1 = salpha.r, abs(d__1)) + (d__2 = d_imag(&salpha),
00735 abs(d__2)) >= safmin && (d__3 = bcoeff.r, abs(d__3))
00736 + (d__4 = d_imag(&bcoeff), abs(d__4)) < small;
00737
00738 scale = 1.;
00739 if (lsa) {
00740 scale = small / abs(sbeta) * min(anorm,big);
00741 }
00742 if (lsb) {
00743
00744 d__3 = scale, d__4 = small / ((d__1 = salpha.r, abs(d__1))
00745 + (d__2 = d_imag(&salpha), abs(d__2))) * min(
00746 bnorm,big);
00747 scale = max(d__3,d__4);
00748 }
00749 if (lsa || lsb) {
00750
00751
00752 d__5 = 1., d__6 = abs(acoeff), d__5 = max(d__5,d__6),
00753 d__6 = (d__1 = bcoeff.r, abs(d__1)) + (d__2 =
00754 d_imag(&bcoeff), abs(d__2));
00755 d__3 = scale, d__4 = 1. / (safmin * max(d__5,d__6));
00756 scale = min(d__3,d__4);
00757 if (lsa) {
00758 acoeff = ascale * (scale * sbeta);
00759 } else {
00760 acoeff = scale * acoeff;
00761 }
00762 if (lsb) {
00763 z__2.r = scale * salpha.r, z__2.i = scale * salpha.i;
00764 z__1.r = bscale * z__2.r, z__1.i = bscale * z__2.i;
00765 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00766 } else {
00767 z__1.r = scale * bcoeff.r, z__1.i = scale * bcoeff.i;
00768 bcoeff.r = z__1.r, bcoeff.i = z__1.i;
00769 }
00770 }
00771
00772 acoefa = abs(acoeff);
00773 bcoefa = (d__1 = bcoeff.r, abs(d__1)) + (d__2 = d_imag(&
00774 bcoeff), abs(d__2));
00775 xmax = 1.;
00776 i__1 = *n;
00777 for (jr = 1; jr <= i__1; ++jr) {
00778 i__2 = jr;
00779 work[i__2].r = 0., work[i__2].i = 0.;
00780
00781 }
00782 i__1 = je;
00783 work[i__1].r = 1., work[i__1].i = 0.;
00784
00785 d__1 = ulp * acoefa * anorm, d__2 = ulp * bcoefa * bnorm,
00786 d__1 = max(d__1,d__2);
00787 dmin__ = max(d__1,safmin);
00788
00789
00790
00791
00792
00793
00794 i__1 = je - 1;
00795 for (jr = 1; jr <= i__1; ++jr) {
00796 i__2 = jr;
00797 i__3 = jr + je * s_dim1;
00798 z__2.r = acoeff * s[i__3].r, z__2.i = acoeff * s[i__3].i;
00799 i__4 = jr + je * p_dim1;
00800 z__3.r = bcoeff.r * p[i__4].r - bcoeff.i * p[i__4].i,
00801 z__3.i = bcoeff.r * p[i__4].i + bcoeff.i * p[i__4]
00802 .r;
00803 z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
00804 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00805
00806 }
00807 i__1 = je;
00808 work[i__1].r = 1., work[i__1].i = 0.;
00809
00810 for (j = je - 1; j >= 1; --j) {
00811
00812
00813
00814
00815 i__1 = j + j * s_dim1;
00816 z__2.r = acoeff * s[i__1].r, z__2.i = acoeff * s[i__1].i;
00817 i__2 = j + j * p_dim1;
00818 z__3.r = bcoeff.r * p[i__2].r - bcoeff.i * p[i__2].i,
00819 z__3.i = bcoeff.r * p[i__2].i + bcoeff.i * p[i__2]
00820 .r;
00821 z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
00822 d__.r = z__1.r, d__.i = z__1.i;
00823 if ((d__1 = d__.r, abs(d__1)) + (d__2 = d_imag(&d__), abs(
00824 d__2)) <= dmin__) {
00825 z__1.r = dmin__, z__1.i = 0.;
00826 d__.r = z__1.r, d__.i = z__1.i;
00827 }
00828
00829 if ((d__1 = d__.r, abs(d__1)) + (d__2 = d_imag(&d__), abs(
00830 d__2)) < 1.) {
00831 i__1 = j;
00832 if ((d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(
00833 &work[j]), abs(d__2)) >= bignum * ((d__3 =
00834 d__.r, abs(d__3)) + (d__4 = d_imag(&d__), abs(
00835 d__4)))) {
00836 i__1 = j;
00837 temp = 1. / ((d__1 = work[i__1].r, abs(d__1)) + (
00838 d__2 = d_imag(&work[j]), abs(d__2)));
00839 i__1 = je;
00840 for (jr = 1; jr <= i__1; ++jr) {
00841 i__2 = jr;
00842 i__3 = jr;
00843 z__1.r = temp * work[i__3].r, z__1.i = temp *
00844 work[i__3].i;
00845 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00846
00847 }
00848 }
00849 }
00850
00851 i__1 = j;
00852 i__2 = j;
00853 z__2.r = -work[i__2].r, z__2.i = -work[i__2].i;
00854 zladiv_(&z__1, &z__2, &d__);
00855 work[i__1].r = z__1.r, work[i__1].i = z__1.i;
00856
00857 if (j > 1) {
00858
00859
00860
00861 i__1 = j;
00862 if ((d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(
00863 &work[j]), abs(d__2)) > 1.) {
00864 i__1 = j;
00865 temp = 1. / ((d__1 = work[i__1].r, abs(d__1)) + (
00866 d__2 = d_imag(&work[j]), abs(d__2)));
00867 if (acoefa * rwork[j] + bcoefa * rwork[*n + j] >=
00868 bignum * temp) {
00869 i__1 = je;
00870 for (jr = 1; jr <= i__1; ++jr) {
00871 i__2 = jr;
00872 i__3 = jr;
00873 z__1.r = temp * work[i__3].r, z__1.i =
00874 temp * work[i__3].i;
00875 work[i__2].r = z__1.r, work[i__2].i =
00876 z__1.i;
00877
00878 }
00879 }
00880 }
00881
00882 i__1 = j;
00883 z__1.r = acoeff * work[i__1].r, z__1.i = acoeff *
00884 work[i__1].i;
00885 ca.r = z__1.r, ca.i = z__1.i;
00886 i__1 = j;
00887 z__1.r = bcoeff.r * work[i__1].r - bcoeff.i * work[
00888 i__1].i, z__1.i = bcoeff.r * work[i__1].i +
00889 bcoeff.i * work[i__1].r;
00890 cb.r = z__1.r, cb.i = z__1.i;
00891 i__1 = j - 1;
00892 for (jr = 1; jr <= i__1; ++jr) {
00893 i__2 = jr;
00894 i__3 = jr;
00895 i__4 = jr + j * s_dim1;
00896 z__3.r = ca.r * s[i__4].r - ca.i * s[i__4].i,
00897 z__3.i = ca.r * s[i__4].i + ca.i * s[i__4]
00898 .r;
00899 z__2.r = work[i__3].r + z__3.r, z__2.i = work[
00900 i__3].i + z__3.i;
00901 i__5 = jr + j * p_dim1;
00902 z__4.r = cb.r * p[i__5].r - cb.i * p[i__5].i,
00903 z__4.i = cb.r * p[i__5].i + cb.i * p[i__5]
00904 .r;
00905 z__1.r = z__2.r - z__4.r, z__1.i = z__2.i -
00906 z__4.i;
00907 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00908
00909 }
00910 }
00911
00912 }
00913
00914
00915
00916 if (ilback) {
00917 zgemv_("N", n, &je, &c_b2, &vr[vr_offset], ldvr, &work[1],
00918 &c__1, &c_b1, &work[*n + 1], &c__1);
00919 isrc = 2;
00920 iend = *n;
00921 } else {
00922 isrc = 1;
00923 iend = je;
00924 }
00925
00926
00927
00928 xmax = 0.;
00929 i__1 = iend;
00930 for (jr = 1; jr <= i__1; ++jr) {
00931
00932 i__2 = (isrc - 1) * *n + jr;
00933 d__3 = xmax, d__4 = (d__1 = work[i__2].r, abs(d__1)) + (
00934 d__2 = d_imag(&work[(isrc - 1) * *n + jr]), abs(
00935 d__2));
00936 xmax = max(d__3,d__4);
00937
00938 }
00939
00940 if (xmax > safmin) {
00941 temp = 1. / xmax;
00942 i__1 = iend;
00943 for (jr = 1; jr <= i__1; ++jr) {
00944 i__2 = jr + ieig * vr_dim1;
00945 i__3 = (isrc - 1) * *n + jr;
00946 z__1.r = temp * work[i__3].r, z__1.i = temp * work[
00947 i__3].i;
00948 vr[i__2].r = z__1.r, vr[i__2].i = z__1.i;
00949
00950 }
00951 } else {
00952 iend = 0;
00953 }
00954
00955 i__1 = *n;
00956 for (jr = iend + 1; jr <= i__1; ++jr) {
00957 i__2 = jr + ieig * vr_dim1;
00958 vr[i__2].r = 0., vr[i__2].i = 0.;
00959
00960 }
00961
00962 }
00963 L250:
00964 ;
00965 }
00966 }
00967
00968 return 0;
00969
00970
00971
00972 }