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