dlaein.c
Go to the documentation of this file.
00001 /* dlaein.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ 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     /* System generated locals */
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     /* Builtin functions */
00031     double sqrt(doublereal);
00032 
00033     /* Local variables */
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 /* Subroutine */ 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 /* Subroutine */ 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 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00059 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00060 /*     November 2006 */
00061 
00062 /*     .. Scalar Arguments .. */
00063 /*     .. */
00064 /*     .. Array Arguments .. */
00065 /*     .. */
00066 
00067 /*  Purpose */
00068 /*  ======= */
00069 
00070 /*  DLAEIN uses inverse iteration to find a right or left eigenvector */
00071 /*  corresponding to the eigenvalue (WR,WI) of a real upper Hessenberg */
00072 /*  matrix H. */
00073 
00074 /*  Arguments */
00075 /*  ========= */
00076 
00077 /*  RIGHTV   (input) LOGICAL */
00078 /*          = .TRUE. : compute right eigenvector; */
00079 /*          = .FALSE.: compute left eigenvector. */
00080 
00081 /*  NOINIT   (input) LOGICAL */
00082 /*          = .TRUE. : no initial vector supplied in (VR,VI). */
00083 /*          = .FALSE.: initial vector supplied in (VR,VI). */
00084 
00085 /*  N       (input) INTEGER */
00086 /*          The order of the matrix H.  N >= 0. */
00087 
00088 /*  H       (input) DOUBLE PRECISION array, dimension (LDH,N) */
00089 /*          The upper Hessenberg matrix H. */
00090 
00091 /*  LDH     (input) INTEGER */
00092 /*          The leading dimension of the array H.  LDH >= max(1,N). */
00093 
00094 /*  WR      (input) DOUBLE PRECISION */
00095 /*  WI      (input) DOUBLE PRECISION */
00096 /*          The real and imaginary parts of the eigenvalue of H whose */
00097 /*          corresponding right or left eigenvector is to be computed. */
00098 
00099 /*  VR      (input/output) DOUBLE PRECISION array, dimension (N) */
00100 /*  VI      (input/output) DOUBLE PRECISION array, dimension (N) */
00101 /*          On entry, if NOINIT = .FALSE. and WI = 0.0, VR must contain */
00102 /*          a real starting vector for inverse iteration using the real */
00103 /*          eigenvalue WR; if NOINIT = .FALSE. and WI.ne.0.0, VR and VI */
00104 /*          must contain the real and imaginary parts of a complex */
00105 /*          starting vector for inverse iteration using the complex */
00106 /*          eigenvalue (WR,WI); otherwise VR and VI need not be set. */
00107 /*          On exit, if WI = 0.0 (real eigenvalue), VR contains the */
00108 /*          computed real eigenvector; if WI.ne.0.0 (complex eigenvalue), */
00109 /*          VR and VI contain the real and imaginary parts of the */
00110 /*          computed complex eigenvector. The eigenvector is normalized */
00111 /*          so that the component of largest magnitude has magnitude 1; */
00112 /*          here the magnitude of a complex number (x,y) is taken to be */
00113 /*          |x| + |y|. */
00114 /*          VI is not referenced if WI = 0.0. */
00115 
00116 /*  B       (workspace) DOUBLE PRECISION array, dimension (LDB,N) */
00117 
00118 /*  LDB     (input) INTEGER */
00119 /*          The leading dimension of the array B.  LDB >= N+1. */
00120 
00121 /*  WORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00122 
00123 /*  EPS3    (input) DOUBLE PRECISION */
00124 /*          A small machine-dependent value which is used to perturb */
00125 /*          close eigenvalues, and to replace zero pivots. */
00126 
00127 /*  SMLNUM  (input) DOUBLE PRECISION */
00128 /*          A machine-dependent value close to the underflow threshold. */
00129 
00130 /*  BIGNUM  (input) DOUBLE PRECISION */
00131 /*          A machine-dependent value close to the overflow threshold. */
00132 
00133 /*  INFO    (output) INTEGER */
00134 /*          = 0:  successful exit */
00135 /*          = 1:  inverse iteration did not converge; VR is set to the */
00136 /*                last iterate, and so is VI if WI.ne.0.0. */
00137 
00138 /*  ===================================================================== */
00139 
00140 /*     .. Parameters .. */
00141 /*     .. */
00142 /*     .. Local Scalars .. */
00143 /*     .. */
00144 /*     .. External Functions .. */
00145 /*     .. */
00146 /*     .. External Subroutines .. */
00147 /*     .. */
00148 /*     .. Intrinsic Functions .. */
00149 /*     .. */
00150 /*     .. Executable Statements .. */
00151 
00152     /* Parameter adjustments */
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     /* Function Body */
00164     *info = 0;
00165 
00166 /*     GROWTO is the threshold used in the acceptance test for an */
00167 /*     eigenvector. */
00168 
00169     rootn = sqrt((doublereal) (*n));
00170     growto = .1 / rootn;
00171 /* Computing MAX */
00172     d__1 = 1., d__2 = *eps3 * rootn;
00173     nrmsml = max(d__1,d__2) * *smlnum;
00174 
00175 /*     Form B = H - (WR,WI)*I (except that the subdiagonal elements and */
00176 /*     the imaginary parts of the diagonal elements are not stored). */
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 /* L10: */
00184         }
00185         b[j + j * b_dim1] = h__[j + j * h_dim1] - *wr;
00186 /* L20: */
00187     }
00188 
00189     if (*wi == 0.) {
00190 
00191 /*        Real eigenvalue. */
00192 
00193         if (*noinit) {
00194 
00195 /*           Set initial vector. */
00196 
00197             i__1 = *n;
00198             for (i__ = 1; i__ <= i__1; ++i__) {
00199                 vr[i__] = *eps3;
00200 /* L30: */
00201             }
00202         } else {
00203 
00204 /*           Scale supplied initial vector. */
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 /*           LU decomposition with partial pivoting of B, replacing zero */
00214 /*           pivots by EPS3. */
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 /*                 Interchange rows and eliminate. */
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 /* L40: */
00232                     }
00233                 } else {
00234 
00235 /*                 Eliminate without interchange. */
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 /* L50: */
00247                         }
00248                     }
00249                 }
00250 /* L60: */
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 /*           UL decomposition with partial pivoting of B, replacing zero */
00261 /*           pivots by EPS3. */
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 /*                 Interchange columns and eliminate. */
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 /* L70: */
00278                     }
00279                 } else {
00280 
00281 /*                 Eliminate without interchange. */
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 /* L80: */
00293                         }
00294                     }
00295                 }
00296 /* L90: */
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 /*           Solve U*x = scale*v for a right eigenvector */
00311 /*             or U'*x = scale*v for a left eigenvector, */
00312 /*           overwriting x on v. */
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 /*           Test for sufficient growth in the norm of v. */
00319 
00320             vnorm = dasum_(n, &vr[1], &c__1);
00321             if (vnorm >= growto * scale) {
00322                 goto L120;
00323             }
00324 
00325 /*           Choose new orthogonal starting vector and try again. */
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 /* L100: */
00333             }
00334             vr[*n - its + 1] -= *eps3 * rootn;
00335 /* L110: */
00336         }
00337 
00338 /*        Failure to find eigenvector in N iterations. */
00339 
00340         *info = 1;
00341 
00342 L120:
00343 
00344 /*        Normalize eigenvector. */
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 /*        Complex eigenvalue. */
00352 
00353         if (*noinit) {
00354 
00355 /*           Set initial vector. */
00356 
00357             i__1 = *n;
00358             for (i__ = 1; i__ <= i__1; ++i__) {
00359                 vr[i__] = *eps3;
00360                 vi[i__] = 0.;
00361 /* L130: */
00362             }
00363         } else {
00364 
00365 /*           Scale supplied initial vector. */
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 /*           LU decomposition with partial pivoting of B, replacing zero */
00378 /*           pivots by EPS3. */
00379 
00380 /*           The imaginary part of the (i,j)-th element of U is stored in */
00381 /*           B(j+1,i). */
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 /* L140: */
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 /*                 Interchange rows and eliminate. */
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 /* L150: */
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 /*                 Eliminate without interchanging rows. */
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 /* L160: */
00437                     }
00438                     b[i__ + 2 + (i__ + 1) * b_dim1] -= *wi;
00439                 }
00440 
00441 /*              Compute 1-norm of offdiagonal elements of i-th row. */
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 /* L170: */
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 /*           UL decomposition with partial pivoting of conjg(B), */
00460 /*           replacing zero pivots by EPS3. */
00461 
00462 /*           The imaginary part of the (i,j)-th element of U is stored in */
00463 /*           B(j+1,i). */
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 /* L180: */
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 /*                 Interchange columns and eliminate */
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 /* L190: */
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 /*                 Eliminate without interchange. */
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 /* L200: */
00517                     }
00518                     b[j + (j - 1) * b_dim1] += *wi;
00519                 }
00520 
00521 /*              Compute 1-norm of offdiagonal elements of j-th column. */
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 /* L210: */
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 /*           Solve U*(xr,xi) = scale*(vr,vi) for a right eigenvector, */
00546 /*             or U'*(xr,xi) = scale*(vr,vi) for a left eigenvector, */
00547 /*           overwriting (xr,xi) on (vr,vi). */
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 /* L220: */
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 /* L230: */
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 /*                 Divide by diagonal element of B. */
00602 
00603                     dladiv_(&xr, &xi, &b[i__ + i__ * b_dim1], &b[i__ + 1 + 
00604                             i__ * b_dim1], &vr[i__], &vi[i__]);
00605 /* Computing MAX */
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 /* L240: */
00616                     }
00617                     vr[i__] = 1.;
00618                     vi[i__] = 1.;
00619                     scale = 0.;
00620                     vmax = 1.;
00621                     vcrit = *bignum;
00622                 }
00623 /* L250: */
00624             }
00625 
00626 /*           Test for sufficient growth in the norm of (VR,VI). */
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 /*           Choose a new orthogonal starting vector and try again. */
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 /* L260: */
00644             }
00645             vr[*n - its + 1] -= *eps3 * rootn;
00646 /* L270: */
00647         }
00648 
00649 /*        Failure to find eigenvector in N iterations */
00650 
00651         *info = 1;
00652 
00653 L280:
00654 
00655 /*        Normalize eigenvector. */
00656 
00657         vnorm = 0.;
00658         i__1 = *n;
00659         for (i__ = 1; i__ <= i__1; ++i__) {
00660 /* Computing MAX */
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 /* L290: */
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 /*     End of DLAEIN */
00676 
00677 } /* dlaein_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:46