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 integer c__1 = 1;
00019
00020 int dlaein_(logical *rightv, logical *noinit, integer *n,
00021 doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi,
00022 doublereal *vr, doublereal *vi, doublereal *b, integer *ldb,
00023 doublereal *work, doublereal *eps3, doublereal *smlnum, doublereal *
00024 bignum, integer *info)
00025 {
00026
00027 integer b_dim1, b_offset, h_dim1, h_offset, i__1, i__2, i__3, i__4;
00028 doublereal d__1, d__2, d__3, d__4;
00029
00030
00031 double sqrt(doublereal);
00032
00033
00034 integer i__, j;
00035 doublereal w, x, y;
00036 integer i1, i2, i3;
00037 doublereal w1, ei, ej, xi, xr, rec;
00038 integer its, ierr;
00039 doublereal temp, norm, vmax;
00040 extern doublereal dnrm2_(integer *, doublereal *, integer *);
00041 extern int dscal_(integer *, doublereal *, doublereal *,
00042 integer *);
00043 doublereal scale;
00044 extern doublereal dasum_(integer *, doublereal *, integer *);
00045 char trans[1];
00046 doublereal vcrit, rootn, vnorm;
00047 extern doublereal dlapy2_(doublereal *, doublereal *);
00048 doublereal absbii, absbjj;
00049 extern integer idamax_(integer *, doublereal *, integer *);
00050 extern int dladiv_(doublereal *, doublereal *,
00051 doublereal *, doublereal *, doublereal *, doublereal *), dlatrs_(
00052 char *, char *, char *, char *, integer *, doublereal *, integer *
00053 , doublereal *, doublereal *, doublereal *, integer *);
00054 char normin[1];
00055 doublereal nrmsml, growto;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 h_dim1 = *ldh;
00154 h_offset = 1 + h_dim1;
00155 h__ -= h_offset;
00156 --vr;
00157 --vi;
00158 b_dim1 = *ldb;
00159 b_offset = 1 + b_dim1;
00160 b -= b_offset;
00161 --work;
00162
00163
00164 *info = 0;
00165
00166
00167
00168
00169 rootn = sqrt((doublereal) (*n));
00170 growto = .1 / rootn;
00171
00172 d__1 = 1., d__2 = *eps3 * rootn;
00173 nrmsml = max(d__1,d__2) * *smlnum;
00174
00175
00176
00177
00178 i__1 = *n;
00179 for (j = 1; j <= i__1; ++j) {
00180 i__2 = j - 1;
00181 for (i__ = 1; i__ <= i__2; ++i__) {
00182 b[i__ + j * b_dim1] = h__[i__ + j * h_dim1];
00183
00184 }
00185 b[j + j * b_dim1] = h__[j + j * h_dim1] - *wr;
00186
00187 }
00188
00189 if (*wi == 0.) {
00190
00191
00192
00193 if (*noinit) {
00194
00195
00196
00197 i__1 = *n;
00198 for (i__ = 1; i__ <= i__1; ++i__) {
00199 vr[i__] = *eps3;
00200
00201 }
00202 } else {
00203
00204
00205
00206 vnorm = dnrm2_(n, &vr[1], &c__1);
00207 d__1 = *eps3 * rootn / max(vnorm,nrmsml);
00208 dscal_(n, &d__1, &vr[1], &c__1);
00209 }
00210
00211 if (*rightv) {
00212
00213
00214
00215
00216 i__1 = *n - 1;
00217 for (i__ = 1; i__ <= i__1; ++i__) {
00218 ei = h__[i__ + 1 + i__ * h_dim1];
00219 if ((d__1 = b[i__ + i__ * b_dim1], abs(d__1)) < abs(ei)) {
00220
00221
00222
00223 x = b[i__ + i__ * b_dim1] / ei;
00224 b[i__ + i__ * b_dim1] = ei;
00225 i__2 = *n;
00226 for (j = i__ + 1; j <= i__2; ++j) {
00227 temp = b[i__ + 1 + j * b_dim1];
00228 b[i__ + 1 + j * b_dim1] = b[i__ + j * b_dim1] - x *
00229 temp;
00230 b[i__ + j * b_dim1] = temp;
00231
00232 }
00233 } else {
00234
00235
00236
00237 if (b[i__ + i__ * b_dim1] == 0.) {
00238 b[i__ + i__ * b_dim1] = *eps3;
00239 }
00240 x = ei / b[i__ + i__ * b_dim1];
00241 if (x != 0.) {
00242 i__2 = *n;
00243 for (j = i__ + 1; j <= i__2; ++j) {
00244 b[i__ + 1 + j * b_dim1] -= x * b[i__ + j * b_dim1]
00245 ;
00246
00247 }
00248 }
00249 }
00250
00251 }
00252 if (b[*n + *n * b_dim1] == 0.) {
00253 b[*n + *n * b_dim1] = *eps3;
00254 }
00255
00256 *(unsigned char *)trans = 'N';
00257
00258 } else {
00259
00260
00261
00262
00263 for (j = *n; j >= 2; --j) {
00264 ej = h__[j + (j - 1) * h_dim1];
00265 if ((d__1 = b[j + j * b_dim1], abs(d__1)) < abs(ej)) {
00266
00267
00268
00269 x = b[j + j * b_dim1] / ej;
00270 b[j + j * b_dim1] = ej;
00271 i__1 = j - 1;
00272 for (i__ = 1; i__ <= i__1; ++i__) {
00273 temp = b[i__ + (j - 1) * b_dim1];
00274 b[i__ + (j - 1) * b_dim1] = b[i__ + j * b_dim1] - x *
00275 temp;
00276 b[i__ + j * b_dim1] = temp;
00277
00278 }
00279 } else {
00280
00281
00282
00283 if (b[j + j * b_dim1] == 0.) {
00284 b[j + j * b_dim1] = *eps3;
00285 }
00286 x = ej / b[j + j * b_dim1];
00287 if (x != 0.) {
00288 i__1 = j - 1;
00289 for (i__ = 1; i__ <= i__1; ++i__) {
00290 b[i__ + (j - 1) * b_dim1] -= x * b[i__ + j *
00291 b_dim1];
00292
00293 }
00294 }
00295 }
00296
00297 }
00298 if (b[b_dim1 + 1] == 0.) {
00299 b[b_dim1 + 1] = *eps3;
00300 }
00301
00302 *(unsigned char *)trans = 'T';
00303
00304 }
00305
00306 *(unsigned char *)normin = 'N';
00307 i__1 = *n;
00308 for (its = 1; its <= i__1; ++its) {
00309
00310
00311
00312
00313
00314 dlatrs_("Upper", trans, "Nonunit", normin, n, &b[b_offset], ldb, &
00315 vr[1], &scale, &work[1], &ierr);
00316 *(unsigned char *)normin = 'Y';
00317
00318
00319
00320 vnorm = dasum_(n, &vr[1], &c__1);
00321 if (vnorm >= growto * scale) {
00322 goto L120;
00323 }
00324
00325
00326
00327 temp = *eps3 / (rootn + 1.);
00328 vr[1] = *eps3;
00329 i__2 = *n;
00330 for (i__ = 2; i__ <= i__2; ++i__) {
00331 vr[i__] = temp;
00332
00333 }
00334 vr[*n - its + 1] -= *eps3 * rootn;
00335
00336 }
00337
00338
00339
00340 *info = 1;
00341
00342 L120:
00343
00344
00345
00346 i__ = idamax_(n, &vr[1], &c__1);
00347 d__2 = 1. / (d__1 = vr[i__], abs(d__1));
00348 dscal_(n, &d__2, &vr[1], &c__1);
00349 } else {
00350
00351
00352
00353 if (*noinit) {
00354
00355
00356
00357 i__1 = *n;
00358 for (i__ = 1; i__ <= i__1; ++i__) {
00359 vr[i__] = *eps3;
00360 vi[i__] = 0.;
00361
00362 }
00363 } else {
00364
00365
00366
00367 d__1 = dnrm2_(n, &vr[1], &c__1);
00368 d__2 = dnrm2_(n, &vi[1], &c__1);
00369 norm = dlapy2_(&d__1, &d__2);
00370 rec = *eps3 * rootn / max(norm,nrmsml);
00371 dscal_(n, &rec, &vr[1], &c__1);
00372 dscal_(n, &rec, &vi[1], &c__1);
00373 }
00374
00375 if (*rightv) {
00376
00377
00378
00379
00380
00381
00382
00383 b[b_dim1 + 2] = -(*wi);
00384 i__1 = *n;
00385 for (i__ = 2; i__ <= i__1; ++i__) {
00386 b[i__ + 1 + b_dim1] = 0.;
00387
00388 }
00389
00390 i__1 = *n - 1;
00391 for (i__ = 1; i__ <= i__1; ++i__) {
00392 absbii = dlapy2_(&b[i__ + i__ * b_dim1], &b[i__ + 1 + i__ *
00393 b_dim1]);
00394 ei = h__[i__ + 1 + i__ * h_dim1];
00395 if (absbii < abs(ei)) {
00396
00397
00398
00399 xr = b[i__ + i__ * b_dim1] / ei;
00400 xi = b[i__ + 1 + i__ * b_dim1] / ei;
00401 b[i__ + i__ * b_dim1] = ei;
00402 b[i__ + 1 + i__ * b_dim1] = 0.;
00403 i__2 = *n;
00404 for (j = i__ + 1; j <= i__2; ++j) {
00405 temp = b[i__ + 1 + j * b_dim1];
00406 b[i__ + 1 + j * b_dim1] = b[i__ + j * b_dim1] - xr *
00407 temp;
00408 b[j + 1 + (i__ + 1) * b_dim1] = b[j + 1 + i__ *
00409 b_dim1] - xi * temp;
00410 b[i__ + j * b_dim1] = temp;
00411 b[j + 1 + i__ * b_dim1] = 0.;
00412
00413 }
00414 b[i__ + 2 + i__ * b_dim1] = -(*wi);
00415 b[i__ + 1 + (i__ + 1) * b_dim1] -= xi * *wi;
00416 b[i__ + 2 + (i__ + 1) * b_dim1] += xr * *wi;
00417 } else {
00418
00419
00420
00421 if (absbii == 0.) {
00422 b[i__ + i__ * b_dim1] = *eps3;
00423 b[i__ + 1 + i__ * b_dim1] = 0.;
00424 absbii = *eps3;
00425 }
00426 ei = ei / absbii / absbii;
00427 xr = b[i__ + i__ * b_dim1] * ei;
00428 xi = -b[i__ + 1 + i__ * b_dim1] * ei;
00429 i__2 = *n;
00430 for (j = i__ + 1; j <= i__2; ++j) {
00431 b[i__ + 1 + j * b_dim1] = b[i__ + 1 + j * b_dim1] -
00432 xr * b[i__ + j * b_dim1] + xi * b[j + 1 + i__
00433 * b_dim1];
00434 b[j + 1 + (i__ + 1) * b_dim1] = -xr * b[j + 1 + i__ *
00435 b_dim1] - xi * b[i__ + j * b_dim1];
00436
00437 }
00438 b[i__ + 2 + (i__ + 1) * b_dim1] -= *wi;
00439 }
00440
00441
00442
00443 i__2 = *n - i__;
00444 i__3 = *n - i__;
00445 work[i__] = dasum_(&i__2, &b[i__ + (i__ + 1) * b_dim1], ldb)
00446 + dasum_(&i__3, &b[i__ + 2 + i__ * b_dim1], &c__1);
00447
00448 }
00449 if (b[*n + *n * b_dim1] == 0. && b[*n + 1 + *n * b_dim1] == 0.) {
00450 b[*n + *n * b_dim1] = *eps3;
00451 }
00452 work[*n] = 0.;
00453
00454 i1 = *n;
00455 i2 = 1;
00456 i3 = -1;
00457 } else {
00458
00459
00460
00461
00462
00463
00464
00465 b[*n + 1 + *n * b_dim1] = *wi;
00466 i__1 = *n - 1;
00467 for (j = 1; j <= i__1; ++j) {
00468 b[*n + 1 + j * b_dim1] = 0.;
00469
00470 }
00471
00472 for (j = *n; j >= 2; --j) {
00473 ej = h__[j + (j - 1) * h_dim1];
00474 absbjj = dlapy2_(&b[j + j * b_dim1], &b[j + 1 + j * b_dim1]);
00475 if (absbjj < abs(ej)) {
00476
00477
00478
00479 xr = b[j + j * b_dim1] / ej;
00480 xi = b[j + 1 + j * b_dim1] / ej;
00481 b[j + j * b_dim1] = ej;
00482 b[j + 1 + j * b_dim1] = 0.;
00483 i__1 = j - 1;
00484 for (i__ = 1; i__ <= i__1; ++i__) {
00485 temp = b[i__ + (j - 1) * b_dim1];
00486 b[i__ + (j - 1) * b_dim1] = b[i__ + j * b_dim1] - xr *
00487 temp;
00488 b[j + i__ * b_dim1] = b[j + 1 + i__ * b_dim1] - xi *
00489 temp;
00490 b[i__ + j * b_dim1] = temp;
00491 b[j + 1 + i__ * b_dim1] = 0.;
00492
00493 }
00494 b[j + 1 + (j - 1) * b_dim1] = *wi;
00495 b[j - 1 + (j - 1) * b_dim1] += xi * *wi;
00496 b[j + (j - 1) * b_dim1] -= xr * *wi;
00497 } else {
00498
00499
00500
00501 if (absbjj == 0.) {
00502 b[j + j * b_dim1] = *eps3;
00503 b[j + 1 + j * b_dim1] = 0.;
00504 absbjj = *eps3;
00505 }
00506 ej = ej / absbjj / absbjj;
00507 xr = b[j + j * b_dim1] * ej;
00508 xi = -b[j + 1 + j * b_dim1] * ej;
00509 i__1 = j - 1;
00510 for (i__ = 1; i__ <= i__1; ++i__) {
00511 b[i__ + (j - 1) * b_dim1] = b[i__ + (j - 1) * b_dim1]
00512 - xr * b[i__ + j * b_dim1] + xi * b[j + 1 +
00513 i__ * b_dim1];
00514 b[j + i__ * b_dim1] = -xr * b[j + 1 + i__ * b_dim1] -
00515 xi * b[i__ + j * b_dim1];
00516
00517 }
00518 b[j + (j - 1) * b_dim1] += *wi;
00519 }
00520
00521
00522
00523 i__1 = j - 1;
00524 i__2 = j - 1;
00525 work[j] = dasum_(&i__1, &b[j * b_dim1 + 1], &c__1) + dasum_(&
00526 i__2, &b[j + 1 + b_dim1], ldb);
00527
00528 }
00529 if (b[b_dim1 + 1] == 0. && b[b_dim1 + 2] == 0.) {
00530 b[b_dim1 + 1] = *eps3;
00531 }
00532 work[1] = 0.;
00533
00534 i1 = 1;
00535 i2 = *n;
00536 i3 = 1;
00537 }
00538
00539 i__1 = *n;
00540 for (its = 1; its <= i__1; ++its) {
00541 scale = 1.;
00542 vmax = 1.;
00543 vcrit = *bignum;
00544
00545
00546
00547
00548
00549 i__2 = i2;
00550 i__3 = i3;
00551 for (i__ = i1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__3)
00552 {
00553
00554 if (work[i__] > vcrit) {
00555 rec = 1. / vmax;
00556 dscal_(n, &rec, &vr[1], &c__1);
00557 dscal_(n, &rec, &vi[1], &c__1);
00558 scale *= rec;
00559 vmax = 1.;
00560 vcrit = *bignum;
00561 }
00562
00563 xr = vr[i__];
00564 xi = vi[i__];
00565 if (*rightv) {
00566 i__4 = *n;
00567 for (j = i__ + 1; j <= i__4; ++j) {
00568 xr = xr - b[i__ + j * b_dim1] * vr[j] + b[j + 1 + i__
00569 * b_dim1] * vi[j];
00570 xi = xi - b[i__ + j * b_dim1] * vi[j] - b[j + 1 + i__
00571 * b_dim1] * vr[j];
00572
00573 }
00574 } else {
00575 i__4 = i__ - 1;
00576 for (j = 1; j <= i__4; ++j) {
00577 xr = xr - b[j + i__ * b_dim1] * vr[j] + b[i__ + 1 + j
00578 * b_dim1] * vi[j];
00579 xi = xi - b[j + i__ * b_dim1] * vi[j] - b[i__ + 1 + j
00580 * b_dim1] * vr[j];
00581
00582 }
00583 }
00584
00585 w = (d__1 = b[i__ + i__ * b_dim1], abs(d__1)) + (d__2 = b[i__
00586 + 1 + i__ * b_dim1], abs(d__2));
00587 if (w > *smlnum) {
00588 if (w < 1.) {
00589 w1 = abs(xr) + abs(xi);
00590 if (w1 > w * *bignum) {
00591 rec = 1. / w1;
00592 dscal_(n, &rec, &vr[1], &c__1);
00593 dscal_(n, &rec, &vi[1], &c__1);
00594 xr = vr[i__];
00595 xi = vi[i__];
00596 scale *= rec;
00597 vmax *= rec;
00598 }
00599 }
00600
00601
00602
00603 dladiv_(&xr, &xi, &b[i__ + i__ * b_dim1], &b[i__ + 1 +
00604 i__ * b_dim1], &vr[i__], &vi[i__]);
00605
00606 d__3 = (d__1 = vr[i__], abs(d__1)) + (d__2 = vi[i__], abs(
00607 d__2));
00608 vmax = max(d__3,vmax);
00609 vcrit = *bignum / vmax;
00610 } else {
00611 i__4 = *n;
00612 for (j = 1; j <= i__4; ++j) {
00613 vr[j] = 0.;
00614 vi[j] = 0.;
00615
00616 }
00617 vr[i__] = 1.;
00618 vi[i__] = 1.;
00619 scale = 0.;
00620 vmax = 1.;
00621 vcrit = *bignum;
00622 }
00623
00624 }
00625
00626
00627
00628 vnorm = dasum_(n, &vr[1], &c__1) + dasum_(n, &vi[1], &c__1);
00629 if (vnorm >= growto * scale) {
00630 goto L280;
00631 }
00632
00633
00634
00635 y = *eps3 / (rootn + 1.);
00636 vr[1] = *eps3;
00637 vi[1] = 0.;
00638
00639 i__3 = *n;
00640 for (i__ = 2; i__ <= i__3; ++i__) {
00641 vr[i__] = y;
00642 vi[i__] = 0.;
00643
00644 }
00645 vr[*n - its + 1] -= *eps3 * rootn;
00646
00647 }
00648
00649
00650
00651 *info = 1;
00652
00653 L280:
00654
00655
00656
00657 vnorm = 0.;
00658 i__1 = *n;
00659 for (i__ = 1; i__ <= i__1; ++i__) {
00660
00661 d__3 = vnorm, d__4 = (d__1 = vr[i__], abs(d__1)) + (d__2 = vi[i__]
00662 , abs(d__2));
00663 vnorm = max(d__3,d__4);
00664
00665 }
00666 d__1 = 1. / vnorm;
00667 dscal_(n, &d__1, &vr[1], &c__1);
00668 d__1 = 1. / vnorm;
00669 dscal_(n, &d__1, &vi[1], &c__1);
00670
00671 }
00672
00673 return 0;
00674
00675
00676
00677 }