slaein.c
Go to the documentation of this file.
00001 /* slaein.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 slaein_(logical *rightv, logical *noinit, integer *n, 
00021         real *h__, integer *ldh, real *wr, real *wi, real *vr, real *vi, real 
00022         *b, integer *ldb, real *work, real *eps3, real *smlnum, real *bignum, 
00023         integer *info)
00024 {
00025     /* System generated locals */
00026     integer b_dim1, b_offset, h_dim1, h_offset, i__1, i__2, i__3, i__4;
00027     real r__1, r__2, r__3, r__4;
00028 
00029     /* Builtin functions */
00030     double sqrt(doublereal);
00031 
00032     /* Local variables */
00033     integer i__, j;
00034     real w, x, y;
00035     integer i1, i2, i3;
00036     real w1, ei, ej, xi, xr, rec;
00037     integer its, ierr;
00038     real temp, norm, vmax;
00039     extern doublereal snrm2_(integer *, real *, integer *);
00040     real scale;
00041     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00042     char trans[1];
00043     real vcrit;
00044     extern doublereal sasum_(integer *, real *, integer *);
00045     real rootn, vnorm;
00046     extern doublereal slapy2_(real *, real *);
00047     real absbii, absbjj;
00048     extern integer isamax_(integer *, real *, integer *);
00049     extern /* Subroutine */ int sladiv_(real *, real *, real *, real *, real *
00050 , real *);
00051     char normin[1];
00052     real nrmsml;
00053     extern /* Subroutine */ int slatrs_(char *, char *, char *, char *, 
00054             integer *, real *, integer *, real *, real *, real *, integer *);
00055     real 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 /*  SLAEIN 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) REAL 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) REAL */
00095 /*  WI      (input) REAL */
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) REAL array, dimension (N) */
00100 /*  VI      (input/output) REAL 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) REAL array, dimension (LDB,N) */
00117 
00118 /*  LDB     (input) INTEGER */
00119 /*          The leading dimension of the array B.  LDB >= N+1. */
00120 
00121 /*  WORK   (workspace) REAL array, dimension (N) */
00122 
00123 /*  EPS3    (input) REAL */
00124 /*          A small machine-dependent value which is used to perturb */
00125 /*          close eigenvalues, and to replace zero pivots. */
00126 
00127 /*  SMLNUM  (input) REAL */
00128 /*          A machine-dependent value close to the underflow threshold. */
00129 
00130 /*  BIGNUM  (input) REAL */
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((real) (*n));
00170     growto = .1f / rootn;
00171 /* Computing MAX */
00172     r__1 = 1.f, r__2 = *eps3 * rootn;
00173     nrmsml = dmax(r__1,r__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.f) {
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 = snrm2_(n, &vr[1], &c__1);
00207             r__1 = *eps3 * rootn / dmax(vnorm,nrmsml);
00208             sscal_(n, &r__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 ((r__1 = b[i__ + i__ * b_dim1], dabs(r__1)) < dabs(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.f) {
00238                         b[i__ + i__ * b_dim1] = *eps3;
00239                     }
00240                     x = ei / b[i__ + i__ * b_dim1];
00241                     if (x != 0.f) {
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.f) {
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 ((r__1 = b[j + j * b_dim1], dabs(r__1)) < dabs(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.f) {
00284                         b[j + j * b_dim1] = *eps3;
00285                     }
00286                     x = ej / b[j + j * b_dim1];
00287                     if (x != 0.f) {
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.f) {
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             slatrs_("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 = sasum_(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.f);
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__ = isamax_(n, &vr[1], &c__1);
00347         r__2 = 1.f / (r__1 = vr[i__], dabs(r__1));
00348         sscal_(n, &r__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.f;
00361 /* L130: */
00362             }
00363         } else {
00364 
00365 /*           Scale supplied initial vector. */
00366 
00367             r__1 = snrm2_(n, &vr[1], &c__1);
00368             r__2 = snrm2_(n, &vi[1], &c__1);
00369             norm = slapy2_(&r__1, &r__2);
00370             rec = *eps3 * rootn / dmax(norm,nrmsml);
00371             sscal_(n, &rec, &vr[1], &c__1);
00372             sscal_(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.f;
00387 /* L140: */
00388             }
00389 
00390             i__1 = *n - 1;
00391             for (i__ = 1; i__ <= i__1; ++i__) {
00392                 absbii = slapy2_(&b[i__ + i__ * b_dim1], &b[i__ + 1 + i__ * 
00393                         b_dim1]);
00394                 ei = h__[i__ + 1 + i__ * h_dim1];
00395                 if (absbii < dabs(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.f;
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.f;
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.f) {
00422                         b[i__ + i__ * b_dim1] = *eps3;
00423                         b[i__ + 1 + i__ * b_dim1] = 0.f;
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__] = sasum_(&i__2, &b[i__ + (i__ + 1) * b_dim1], ldb) 
00446                         + sasum_(&i__3, &b[i__ + 2 + i__ * b_dim1], &c__1);
00447 /* L170: */
00448             }
00449             if (b[*n + *n * b_dim1] == 0.f && b[*n + 1 + *n * b_dim1] == 0.f) 
00450                     {
00451                 b[*n + *n * b_dim1] = *eps3;
00452             }
00453             work[*n] = 0.f;
00454 
00455             i1 = *n;
00456             i2 = 1;
00457             i3 = -1;
00458         } else {
00459 
00460 /*           UL decomposition with partial pivoting of conjg(B), */
00461 /*           replacing zero pivots by EPS3. */
00462 
00463 /*           The imaginary part of the (i,j)-th element of U is stored in */
00464 /*           B(j+1,i). */
00465 
00466             b[*n + 1 + *n * b_dim1] = *wi;
00467             i__1 = *n - 1;
00468             for (j = 1; j <= i__1; ++j) {
00469                 b[*n + 1 + j * b_dim1] = 0.f;
00470 /* L180: */
00471             }
00472 
00473             for (j = *n; j >= 2; --j) {
00474                 ej = h__[j + (j - 1) * h_dim1];
00475                 absbjj = slapy2_(&b[j + j * b_dim1], &b[j + 1 + j * b_dim1]);
00476                 if (absbjj < dabs(ej)) {
00477 
00478 /*                 Interchange columns and eliminate */
00479 
00480                     xr = b[j + j * b_dim1] / ej;
00481                     xi = b[j + 1 + j * b_dim1] / ej;
00482                     b[j + j * b_dim1] = ej;
00483                     b[j + 1 + j * b_dim1] = 0.f;
00484                     i__1 = j - 1;
00485                     for (i__ = 1; i__ <= i__1; ++i__) {
00486                         temp = b[i__ + (j - 1) * b_dim1];
00487                         b[i__ + (j - 1) * b_dim1] = b[i__ + j * b_dim1] - xr *
00488                                  temp;
00489                         b[j + i__ * b_dim1] = b[j + 1 + i__ * b_dim1] - xi * 
00490                                 temp;
00491                         b[i__ + j * b_dim1] = temp;
00492                         b[j + 1 + i__ * b_dim1] = 0.f;
00493 /* L190: */
00494                     }
00495                     b[j + 1 + (j - 1) * b_dim1] = *wi;
00496                     b[j - 1 + (j - 1) * b_dim1] += xi * *wi;
00497                     b[j + (j - 1) * b_dim1] -= xr * *wi;
00498                 } else {
00499 
00500 /*                 Eliminate without interchange. */
00501 
00502                     if (absbjj == 0.f) {
00503                         b[j + j * b_dim1] = *eps3;
00504                         b[j + 1 + j * b_dim1] = 0.f;
00505                         absbjj = *eps3;
00506                     }
00507                     ej = ej / absbjj / absbjj;
00508                     xr = b[j + j * b_dim1] * ej;
00509                     xi = -b[j + 1 + j * b_dim1] * ej;
00510                     i__1 = j - 1;
00511                     for (i__ = 1; i__ <= i__1; ++i__) {
00512                         b[i__ + (j - 1) * b_dim1] = b[i__ + (j - 1) * b_dim1] 
00513                                 - xr * b[i__ + j * b_dim1] + xi * b[j + 1 + 
00514                                 i__ * b_dim1];
00515                         b[j + i__ * b_dim1] = -xr * b[j + 1 + i__ * b_dim1] - 
00516                                 xi * b[i__ + j * b_dim1];
00517 /* L200: */
00518                     }
00519                     b[j + (j - 1) * b_dim1] += *wi;
00520                 }
00521 
00522 /*              Compute 1-norm of offdiagonal elements of j-th column. */
00523 
00524                 i__1 = j - 1;
00525                 i__2 = j - 1;
00526                 work[j] = sasum_(&i__1, &b[j * b_dim1 + 1], &c__1) + sasum_(&
00527                         i__2, &b[j + 1 + b_dim1], ldb);
00528 /* L210: */
00529             }
00530             if (b[b_dim1 + 1] == 0.f && b[b_dim1 + 2] == 0.f) {
00531                 b[b_dim1 + 1] = *eps3;
00532             }
00533             work[1] = 0.f;
00534 
00535             i1 = 1;
00536             i2 = *n;
00537             i3 = 1;
00538         }
00539 
00540         i__1 = *n;
00541         for (its = 1; its <= i__1; ++its) {
00542             scale = 1.f;
00543             vmax = 1.f;
00544             vcrit = *bignum;
00545 
00546 /*           Solve U*(xr,xi) = scale*(vr,vi) for a right eigenvector, */
00547 /*             or U'*(xr,xi) = scale*(vr,vi) for a left eigenvector, */
00548 /*           overwriting (xr,xi) on (vr,vi). */
00549 
00550             i__2 = i2;
00551             i__3 = i3;
00552             for (i__ = i1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__3) 
00553                     {
00554 
00555                 if (work[i__] > vcrit) {
00556                     rec = 1.f / vmax;
00557                     sscal_(n, &rec, &vr[1], &c__1);
00558                     sscal_(n, &rec, &vi[1], &c__1);
00559                     scale *= rec;
00560                     vmax = 1.f;
00561                     vcrit = *bignum;
00562                 }
00563 
00564                 xr = vr[i__];
00565                 xi = vi[i__];
00566                 if (*rightv) {
00567                     i__4 = *n;
00568                     for (j = i__ + 1; j <= i__4; ++j) {
00569                         xr = xr - b[i__ + j * b_dim1] * vr[j] + b[j + 1 + i__ 
00570                                 * b_dim1] * vi[j];
00571                         xi = xi - b[i__ + j * b_dim1] * vi[j] - b[j + 1 + i__ 
00572                                 * b_dim1] * vr[j];
00573 /* L220: */
00574                     }
00575                 } else {
00576                     i__4 = i__ - 1;
00577                     for (j = 1; j <= i__4; ++j) {
00578                         xr = xr - b[j + i__ * b_dim1] * vr[j] + b[i__ + 1 + j 
00579                                 * b_dim1] * vi[j];
00580                         xi = xi - b[j + i__ * b_dim1] * vi[j] - b[i__ + 1 + j 
00581                                 * b_dim1] * vr[j];
00582 /* L230: */
00583                     }
00584                 }
00585 
00586                 w = (r__1 = b[i__ + i__ * b_dim1], dabs(r__1)) + (r__2 = b[
00587                         i__ + 1 + i__ * b_dim1], dabs(r__2));
00588                 if (w > *smlnum) {
00589                     if (w < 1.f) {
00590                         w1 = dabs(xr) + dabs(xi);
00591                         if (w1 > w * *bignum) {
00592                             rec = 1.f / w1;
00593                             sscal_(n, &rec, &vr[1], &c__1);
00594                             sscal_(n, &rec, &vi[1], &c__1);
00595                             xr = vr[i__];
00596                             xi = vi[i__];
00597                             scale *= rec;
00598                             vmax *= rec;
00599                         }
00600                     }
00601 
00602 /*                 Divide by diagonal element of B. */
00603 
00604                     sladiv_(&xr, &xi, &b[i__ + i__ * b_dim1], &b[i__ + 1 + 
00605                             i__ * b_dim1], &vr[i__], &vi[i__]);
00606 /* Computing MAX */
00607                     r__3 = (r__1 = vr[i__], dabs(r__1)) + (r__2 = vi[i__], 
00608                             dabs(r__2));
00609                     vmax = dmax(r__3,vmax);
00610                     vcrit = *bignum / vmax;
00611                 } else {
00612                     i__4 = *n;
00613                     for (j = 1; j <= i__4; ++j) {
00614                         vr[j] = 0.f;
00615                         vi[j] = 0.f;
00616 /* L240: */
00617                     }
00618                     vr[i__] = 1.f;
00619                     vi[i__] = 1.f;
00620                     scale = 0.f;
00621                     vmax = 1.f;
00622                     vcrit = *bignum;
00623                 }
00624 /* L250: */
00625             }
00626 
00627 /*           Test for sufficient growth in the norm of (VR,VI). */
00628 
00629             vnorm = sasum_(n, &vr[1], &c__1) + sasum_(n, &vi[1], &c__1);
00630             if (vnorm >= growto * scale) {
00631                 goto L280;
00632             }
00633 
00634 /*           Choose a new orthogonal starting vector and try again. */
00635 
00636             y = *eps3 / (rootn + 1.f);
00637             vr[1] = *eps3;
00638             vi[1] = 0.f;
00639 
00640             i__3 = *n;
00641             for (i__ = 2; i__ <= i__3; ++i__) {
00642                 vr[i__] = y;
00643                 vi[i__] = 0.f;
00644 /* L260: */
00645             }
00646             vr[*n - its + 1] -= *eps3 * rootn;
00647 /* L270: */
00648         }
00649 
00650 /*        Failure to find eigenvector in N iterations */
00651 
00652         *info = 1;
00653 
00654 L280:
00655 
00656 /*        Normalize eigenvector. */
00657 
00658         vnorm = 0.f;
00659         i__1 = *n;
00660         for (i__ = 1; i__ <= i__1; ++i__) {
00661 /* Computing MAX */
00662             r__3 = vnorm, r__4 = (r__1 = vr[i__], dabs(r__1)) + (r__2 = vi[
00663                     i__], dabs(r__2));
00664             vnorm = dmax(r__3,r__4);
00665 /* L290: */
00666         }
00667         r__1 = 1.f / vnorm;
00668         sscal_(n, &r__1, &vr[1], &c__1);
00669         r__1 = 1.f / vnorm;
00670         sscal_(n, &r__1, &vi[1], &c__1);
00671 
00672     }
00673 
00674     return 0;
00675 
00676 /*     End of SLAEIN */
00677 
00678 } /* slaein_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:10