stgevc.c
Go to the documentation of this file.
00001 /* stgevc.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 logical c_true = TRUE_;
00019 static integer c__2 = 2;
00020 static real c_b34 = 1.f;
00021 static integer c__1 = 1;
00022 static real c_b36 = 0.f;
00023 static logical c_false = FALSE_;
00024 
00025 /* Subroutine */ int stgevc_(char *side, char *howmny, logical *select, 
00026         integer *n, real *s, integer *lds, real *p, integer *ldp, real *vl, 
00027         integer *ldvl, real *vr, integer *ldvr, integer *mm, integer *m, real 
00028         *work, integer *info)
00029 {
00030     /* System generated locals */
00031     integer p_dim1, p_offset, s_dim1, s_offset, vl_dim1, vl_offset, vr_dim1, 
00032             vr_offset, i__1, i__2, i__3, i__4, i__5;
00033     real r__1, r__2, r__3, r__4, r__5, r__6;
00034 
00035     /* Local variables */
00036     integer i__, j, ja, jc, je, na, im, jr, jw, nw;
00037     real big;
00038     logical lsa, lsb;
00039     real ulp, sum[4]    /* was [2][2] */;
00040     integer ibeg, ieig, iend;
00041     real dmin__, temp, xmax, sump[4]    /* was [2][2] */, sums[4]       /* 
00042             was [2][2] */, cim2a, cim2b, cre2a, cre2b;
00043     extern /* Subroutine */ int slag2_(real *, integer *, real *, integer *, 
00044             real *, real *, real *, real *, real *, real *);
00045     real temp2, bdiag[2], acoef, scale;
00046     logical ilall;
00047     integer iside;
00048     real sbeta;
00049     extern logical lsame_(char *, char *);
00050     logical il2by2;
00051     integer iinfo;
00052     real small;
00053     logical compl;
00054     real anorm, bnorm;
00055     logical compr;
00056     extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, 
00057             real *, integer *, real *, integer *, real *, real *, integer *), slaln2_(logical *, integer *, integer *, real *, real *, 
00058             real *, integer *, real *, real *, real *, integer *, real *, 
00059             real *, real *, integer *, real *, real *, integer *);
00060     real temp2i, temp2r;
00061     logical ilabad, ilbbad;
00062     real acoefa, bcoefa, cimaga, cimagb;
00063     logical ilback;
00064     extern /* Subroutine */ int slabad_(real *, real *);
00065     real bcoefi, ascale, bscale, creala, crealb, bcoefr;
00066     extern doublereal slamch_(char *);
00067     real salfar, safmin;
00068     extern /* Subroutine */ int xerbla_(char *, integer *);
00069     real xscale, bignum;
00070     logical ilcomp, ilcplx;
00071     extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, 
00072             integer *, real *, integer *);
00073     integer ihwmny;
00074 
00075 
00076 /*  -- LAPACK routine (version 3.2) -- */
00077 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00078 /*     November 2006 */
00079 
00080 /*     .. Scalar Arguments .. */
00081 /*     .. */
00082 /*     .. Array Arguments .. */
00083 /*     .. */
00084 
00085 
00086 /*  Purpose */
00087 /*  ======= */
00088 
00089 /*  STGEVC computes some or all of the right and/or left eigenvectors of */
00090 /*  a pair of real matrices (S,P), where S is a quasi-triangular matrix */
00091 /*  and P is upper triangular.  Matrix pairs of this type are produced by */
00092 /*  the generalized Schur factorization of a matrix pair (A,B): */
00093 
00094 /*     A = Q*S*Z**T,  B = Q*P*Z**T */
00095 
00096 /*  as computed by SGGHRD + SHGEQZ. */
00097 
00098 /*  The right eigenvector x and the left eigenvector y of (S,P) */
00099 /*  corresponding to an eigenvalue w are defined by: */
00100 
00101 /*     S*x = w*P*x,  (y**H)*S = w*(y**H)*P, */
00102 
00103 /*  where y**H denotes the conjugate tranpose of y. */
00104 /*  The eigenvalues are not input to this routine, but are computed */
00105 /*  directly from the diagonal blocks of S and P. */
00106 
00107 /*  This routine returns the matrices X and/or Y of right and left */
00108 /*  eigenvectors of (S,P), or the products Z*X and/or Q*Y, */
00109 /*  where Z and Q are input matrices. */
00110 /*  If Q and Z are the orthogonal factors from the generalized Schur */
00111 /*  factorization of a matrix pair (A,B), then Z*X and Q*Y */
00112 /*  are the matrices of right and left eigenvectors of (A,B). */
00113 
00114 /*  Arguments */
00115 /*  ========= */
00116 
00117 /*  SIDE    (input) CHARACTER*1 */
00118 /*          = 'R': compute right eigenvectors only; */
00119 /*          = 'L': compute left eigenvectors only; */
00120 /*          = 'B': compute both right and left eigenvectors. */
00121 
00122 /*  HOWMNY  (input) CHARACTER*1 */
00123 /*          = 'A': compute all right and/or left eigenvectors; */
00124 /*          = 'B': compute all right and/or left eigenvectors, */
00125 /*                 backtransformed by the matrices in VR and/or VL; */
00126 /*          = 'S': compute selected right and/or left eigenvectors, */
00127 /*                 specified by the logical array SELECT. */
00128 
00129 /*  SELECT  (input) LOGICAL array, dimension (N) */
00130 /*          If HOWMNY='S', SELECT specifies the eigenvectors to be */
00131 /*          computed.  If w(j) is a real eigenvalue, the corresponding */
00132 /*          real eigenvector is computed if SELECT(j) is .TRUE.. */
00133 /*          If w(j) and w(j+1) are the real and imaginary parts of a */
00134 /*          complex eigenvalue, the corresponding complex eigenvector */
00135 /*          is computed if either SELECT(j) or SELECT(j+1) is .TRUE., */
00136 /*          and on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is */
00137 /*          set to .FALSE.. */
00138 /*          Not referenced if HOWMNY = 'A' or 'B'. */
00139 
00140 /*  N       (input) INTEGER */
00141 /*          The order of the matrices S and P.  N >= 0. */
00142 
00143 /*  S       (input) REAL array, dimension (LDS,N) */
00144 /*          The upper quasi-triangular matrix S from a generalized Schur */
00145 /*          factorization, as computed by SHGEQZ. */
00146 
00147 /*  LDS     (input) INTEGER */
00148 /*          The leading dimension of array S.  LDS >= max(1,N). */
00149 
00150 /*  P       (input) REAL array, dimension (LDP,N) */
00151 /*          The upper triangular matrix P from a generalized Schur */
00152 /*          factorization, as computed by SHGEQZ. */
00153 /*          2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks */
00154 /*          of S must be in positive diagonal form. */
00155 
00156 /*  LDP     (input) INTEGER */
00157 /*          The leading dimension of array P.  LDP >= max(1,N). */
00158 
00159 /*  VL      (input/output) REAL array, dimension (LDVL,MM) */
00160 /*          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must */
00161 /*          contain an N-by-N matrix Q (usually the orthogonal matrix Q */
00162 /*          of left Schur vectors returned by SHGEQZ). */
00163 /*          On exit, if SIDE = 'L' or 'B', VL contains: */
00164 /*          if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P); */
00165 /*          if HOWMNY = 'B', the matrix Q*Y; */
00166 /*          if HOWMNY = 'S', the left eigenvectors of (S,P) specified by */
00167 /*                      SELECT, stored consecutively in the columns of */
00168 /*                      VL, in the same order as their eigenvalues. */
00169 
00170 /*          A complex eigenvector corresponding to a complex eigenvalue */
00171 /*          is stored in two consecutive columns, the first holding the */
00172 /*          real part, and the second the imaginary part. */
00173 
00174 /*          Not referenced if SIDE = 'R'. */
00175 
00176 /*  LDVL    (input) INTEGER */
00177 /*          The leading dimension of array VL.  LDVL >= 1, and if */
00178 /*          SIDE = 'L' or 'B', LDVL >= N. */
00179 
00180 /*  VR      (input/output) REAL array, dimension (LDVR,MM) */
00181 /*          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must */
00182 /*          contain an N-by-N matrix Z (usually the orthogonal matrix Z */
00183 /*          of right Schur vectors returned by SHGEQZ). */
00184 
00185 /*          On exit, if SIDE = 'R' or 'B', VR contains: */
00186 /*          if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P); */
00187 /*          if HOWMNY = 'B' or 'b', the matrix Z*X; */
00188 /*          if HOWMNY = 'S' or 's', the right eigenvectors of (S,P) */
00189 /*                      specified by SELECT, stored consecutively in the */
00190 /*                      columns of VR, in the same order as their */
00191 /*                      eigenvalues. */
00192 
00193 /*          A complex eigenvector corresponding to a complex eigenvalue */
00194 /*          is stored in two consecutive columns, the first holding the */
00195 /*          real part and the second the imaginary part. */
00196 
00197 /*          Not referenced if SIDE = 'L'. */
00198 
00199 /*  LDVR    (input) INTEGER */
00200 /*          The leading dimension of the array VR.  LDVR >= 1, and if */
00201 /*          SIDE = 'R' or 'B', LDVR >= N. */
00202 
00203 /*  MM      (input) INTEGER */
00204 /*          The number of columns in the arrays VL and/or VR. MM >= M. */
00205 
00206 /*  M       (output) INTEGER */
00207 /*          The number of columns in the arrays VL and/or VR actually */
00208 /*          used to store the eigenvectors.  If HOWMNY = 'A' or 'B', M */
00209 /*          is set to N.  Each selected real eigenvector occupies one */
00210 /*          column and each selected complex eigenvector occupies two */
00211 /*          columns. */
00212 
00213 /*  WORK    (workspace) REAL array, dimension (6*N) */
00214 
00215 /*  INFO    (output) INTEGER */
00216 /*          = 0:  successful exit. */
00217 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00218 /*          > 0:  the 2-by-2 block (INFO:INFO+1) does not have a complex */
00219 /*                eigenvalue. */
00220 
00221 /*  Further Details */
00222 /*  =============== */
00223 
00224 /*  Allocation of workspace: */
00225 /*  ---------- -- --------- */
00226 
00227 /*     WORK( j ) = 1-norm of j-th column of A, above the diagonal */
00228 /*     WORK( N+j ) = 1-norm of j-th column of B, above the diagonal */
00229 /*     WORK( 2*N+1:3*N ) = real part of eigenvector */
00230 /*     WORK( 3*N+1:4*N ) = imaginary part of eigenvector */
00231 /*     WORK( 4*N+1:5*N ) = real part of back-transformed eigenvector */
00232 /*     WORK( 5*N+1:6*N ) = imaginary part of back-transformed eigenvector */
00233 
00234 /*  Rowwise vs. columnwise solution methods: */
00235 /*  ------- --  ---------- -------- ------- */
00236 
00237 /*  Finding a generalized eigenvector consists basically of solving the */
00238 /*  singular triangular system */
00239 
00240 /*   (A - w B) x = 0     (for right) or:   (A - w B)**H y = 0  (for left) */
00241 
00242 /*  Consider finding the i-th right eigenvector (assume all eigenvalues */
00243 /*  are real). The equation to be solved is: */
00244 /*       n                   i */
00245 /*  0 = sum  C(j,k) v(k)  = sum  C(j,k) v(k)     for j = i,. . .,1 */
00246 /*      k=j                 k=j */
00247 
00248 /*  where  C = (A - w B)  (The components v(i+1:n) are 0.) */
00249 
00250 /*  The "rowwise" method is: */
00251 
00252 /*  (1)  v(i) := 1 */
00253 /*  for j = i-1,. . .,1: */
00254 /*                          i */
00255 /*      (2) compute  s = - sum C(j,k) v(k)   and */
00256 /*                        k=j+1 */
00257 
00258 /*      (3) v(j) := s / C(j,j) */
00259 
00260 /*  Step 2 is sometimes called the "dot product" step, since it is an */
00261 /*  inner product between the j-th row and the portion of the eigenvector */
00262 /*  that has been computed so far. */
00263 
00264 /*  The "columnwise" method consists basically in doing the sums */
00265 /*  for all the rows in parallel.  As each v(j) is computed, the */
00266 /*  contribution of v(j) times the j-th column of C is added to the */
00267 /*  partial sums.  Since FORTRAN arrays are stored columnwise, this has */
00268 /*  the advantage that at each step, the elements of C that are accessed */
00269 /*  are adjacent to one another, whereas with the rowwise method, the */
00270 /*  elements accessed at a step are spaced LDS (and LDP) words apart. */
00271 
00272 /*  When finding left eigenvectors, the matrix in question is the */
00273 /*  transpose of the one in storage, so the rowwise method then */
00274 /*  actually accesses columns of A and B at each step, and so is the */
00275 /*  preferred method. */
00276 
00277 /*  ===================================================================== */
00278 
00279 /*     .. Parameters .. */
00280 /*     .. */
00281 /*     .. Local Scalars .. */
00282 /*     .. */
00283 /*     .. Local Arrays .. */
00284 /*     .. */
00285 /*     .. External Functions .. */
00286 /*     .. */
00287 /*     .. External Subroutines .. */
00288 /*     .. */
00289 /*     .. Intrinsic Functions .. */
00290 /*     .. */
00291 /*     .. Executable Statements .. */
00292 
00293 /*     Decode and Test the input parameters */
00294 
00295     /* Parameter adjustments */
00296     --select;
00297     s_dim1 = *lds;
00298     s_offset = 1 + s_dim1;
00299     s -= s_offset;
00300     p_dim1 = *ldp;
00301     p_offset = 1 + p_dim1;
00302     p -= p_offset;
00303     vl_dim1 = *ldvl;
00304     vl_offset = 1 + vl_dim1;
00305     vl -= vl_offset;
00306     vr_dim1 = *ldvr;
00307     vr_offset = 1 + vr_dim1;
00308     vr -= vr_offset;
00309     --work;
00310 
00311     /* Function Body */
00312     if (lsame_(howmny, "A")) {
00313         ihwmny = 1;
00314         ilall = TRUE_;
00315         ilback = FALSE_;
00316     } else if (lsame_(howmny, "S")) {
00317         ihwmny = 2;
00318         ilall = FALSE_;
00319         ilback = FALSE_;
00320     } else if (lsame_(howmny, "B")) {
00321         ihwmny = 3;
00322         ilall = TRUE_;
00323         ilback = TRUE_;
00324     } else {
00325         ihwmny = -1;
00326         ilall = TRUE_;
00327     }
00328 
00329     if (lsame_(side, "R")) {
00330         iside = 1;
00331         compl = FALSE_;
00332         compr = TRUE_;
00333     } else if (lsame_(side, "L")) {
00334         iside = 2;
00335         compl = TRUE_;
00336         compr = FALSE_;
00337     } else if (lsame_(side, "B")) {
00338         iside = 3;
00339         compl = TRUE_;
00340         compr = TRUE_;
00341     } else {
00342         iside = -1;
00343     }
00344 
00345     *info = 0;
00346     if (iside < 0) {
00347         *info = -1;
00348     } else if (ihwmny < 0) {
00349         *info = -2;
00350     } else if (*n < 0) {
00351         *info = -4;
00352     } else if (*lds < max(1,*n)) {
00353         *info = -6;
00354     } else if (*ldp < max(1,*n)) {
00355         *info = -8;
00356     }
00357     if (*info != 0) {
00358         i__1 = -(*info);
00359         xerbla_("STGEVC", &i__1);
00360         return 0;
00361     }
00362 
00363 /*     Count the number of eigenvectors to be computed */
00364 
00365     if (! ilall) {
00366         im = 0;
00367         ilcplx = FALSE_;
00368         i__1 = *n;
00369         for (j = 1; j <= i__1; ++j) {
00370             if (ilcplx) {
00371                 ilcplx = FALSE_;
00372                 goto L10;
00373             }
00374             if (j < *n) {
00375                 if (s[j + 1 + j * s_dim1] != 0.f) {
00376                     ilcplx = TRUE_;
00377                 }
00378             }
00379             if (ilcplx) {
00380                 if (select[j] || select[j + 1]) {
00381                     im += 2;
00382                 }
00383             } else {
00384                 if (select[j]) {
00385                     ++im;
00386                 }
00387             }
00388 L10:
00389             ;
00390         }
00391     } else {
00392         im = *n;
00393     }
00394 
00395 /*     Check 2-by-2 diagonal blocks of A, B */
00396 
00397     ilabad = FALSE_;
00398     ilbbad = FALSE_;
00399     i__1 = *n - 1;
00400     for (j = 1; j <= i__1; ++j) {
00401         if (s[j + 1 + j * s_dim1] != 0.f) {
00402             if (p[j + j * p_dim1] == 0.f || p[j + 1 + (j + 1) * p_dim1] == 
00403                     0.f || p[j + (j + 1) * p_dim1] != 0.f) {
00404                 ilbbad = TRUE_;
00405             }
00406             if (j < *n - 1) {
00407                 if (s[j + 2 + (j + 1) * s_dim1] != 0.f) {
00408                     ilabad = TRUE_;
00409                 }
00410             }
00411         }
00412 /* L20: */
00413     }
00414 
00415     if (ilabad) {
00416         *info = -5;
00417     } else if (ilbbad) {
00418         *info = -7;
00419     } else if (compl && *ldvl < *n || *ldvl < 1) {
00420         *info = -10;
00421     } else if (compr && *ldvr < *n || *ldvr < 1) {
00422         *info = -12;
00423     } else if (*mm < im) {
00424         *info = -13;
00425     }
00426     if (*info != 0) {
00427         i__1 = -(*info);
00428         xerbla_("STGEVC", &i__1);
00429         return 0;
00430     }
00431 
00432 /*     Quick return if possible */
00433 
00434     *m = im;
00435     if (*n == 0) {
00436         return 0;
00437     }
00438 
00439 /*     Machine Constants */
00440 
00441     safmin = slamch_("Safe minimum");
00442     big = 1.f / safmin;
00443     slabad_(&safmin, &big);
00444     ulp = slamch_("Epsilon") * slamch_("Base");
00445     small = safmin * *n / ulp;
00446     big = 1.f / small;
00447     bignum = 1.f / (safmin * *n);
00448 
00449 /*     Compute the 1-norm of each column of the strictly upper triangular */
00450 /*     part (i.e., excluding all elements belonging to the diagonal */
00451 /*     blocks) of A and B to check for possible overflow in the */
00452 /*     triangular solver. */
00453 
00454     anorm = (r__1 = s[s_dim1 + 1], dabs(r__1));
00455     if (*n > 1) {
00456         anorm += (r__1 = s[s_dim1 + 2], dabs(r__1));
00457     }
00458     bnorm = (r__1 = p[p_dim1 + 1], dabs(r__1));
00459     work[1] = 0.f;
00460     work[*n + 1] = 0.f;
00461 
00462     i__1 = *n;
00463     for (j = 2; j <= i__1; ++j) {
00464         temp = 0.f;
00465         temp2 = 0.f;
00466         if (s[j + (j - 1) * s_dim1] == 0.f) {
00467             iend = j - 1;
00468         } else {
00469             iend = j - 2;
00470         }
00471         i__2 = iend;
00472         for (i__ = 1; i__ <= i__2; ++i__) {
00473             temp += (r__1 = s[i__ + j * s_dim1], dabs(r__1));
00474             temp2 += (r__1 = p[i__ + j * p_dim1], dabs(r__1));
00475 /* L30: */
00476         }
00477         work[j] = temp;
00478         work[*n + j] = temp2;
00479 /* Computing MIN */
00480         i__3 = j + 1;
00481         i__2 = min(i__3,*n);
00482         for (i__ = iend + 1; i__ <= i__2; ++i__) {
00483             temp += (r__1 = s[i__ + j * s_dim1], dabs(r__1));
00484             temp2 += (r__1 = p[i__ + j * p_dim1], dabs(r__1));
00485 /* L40: */
00486         }
00487         anorm = dmax(anorm,temp);
00488         bnorm = dmax(bnorm,temp2);
00489 /* L50: */
00490     }
00491 
00492     ascale = 1.f / dmax(anorm,safmin);
00493     bscale = 1.f / dmax(bnorm,safmin);
00494 
00495 /*     Left eigenvectors */
00496 
00497     if (compl) {
00498         ieig = 0;
00499 
00500 /*        Main loop over eigenvalues */
00501 
00502         ilcplx = FALSE_;
00503         i__1 = *n;
00504         for (je = 1; je <= i__1; ++je) {
00505 
00506 /*           Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
00507 /*           (b) this would be the second of a complex pair. */
00508 /*           Check for complex eigenvalue, so as to be sure of which */
00509 /*           entry(-ies) of SELECT to look at. */
00510 
00511             if (ilcplx) {
00512                 ilcplx = FALSE_;
00513                 goto L220;
00514             }
00515             nw = 1;
00516             if (je < *n) {
00517                 if (s[je + 1 + je * s_dim1] != 0.f) {
00518                     ilcplx = TRUE_;
00519                     nw = 2;
00520                 }
00521             }
00522             if (ilall) {
00523                 ilcomp = TRUE_;
00524             } else if (ilcplx) {
00525                 ilcomp = select[je] || select[je + 1];
00526             } else {
00527                 ilcomp = select[je];
00528             }
00529             if (! ilcomp) {
00530                 goto L220;
00531             }
00532 
00533 /*           Decide if (a) singular pencil, (b) real eigenvalue, or */
00534 /*           (c) complex eigenvalue. */
00535 
00536             if (! ilcplx) {
00537                 if ((r__1 = s[je + je * s_dim1], dabs(r__1)) <= safmin && (
00538                         r__2 = p[je + je * p_dim1], dabs(r__2)) <= safmin) {
00539 
00540 /*                 Singular matrix pencil -- return unit eigenvector */
00541 
00542                     ++ieig;
00543                     i__2 = *n;
00544                     for (jr = 1; jr <= i__2; ++jr) {
00545                         vl[jr + ieig * vl_dim1] = 0.f;
00546 /* L60: */
00547                     }
00548                     vl[ieig + ieig * vl_dim1] = 1.f;
00549                     goto L220;
00550                 }
00551             }
00552 
00553 /*           Clear vector */
00554 
00555             i__2 = nw * *n;
00556             for (jr = 1; jr <= i__2; ++jr) {
00557                 work[(*n << 1) + jr] = 0.f;
00558 /* L70: */
00559             }
00560 /*                                                 T */
00561 /*           Compute coefficients in  ( a A - b B )  y = 0 */
00562 /*              a  is  ACOEF */
00563 /*              b  is  BCOEFR + i*BCOEFI */
00564 
00565             if (! ilcplx) {
00566 
00567 /*              Real eigenvalue */
00568 
00569 /* Computing MAX */
00570                 r__3 = (r__1 = s[je + je * s_dim1], dabs(r__1)) * ascale, 
00571                         r__4 = (r__2 = p[je + je * p_dim1], dabs(r__2)) * 
00572                         bscale, r__3 = max(r__3,r__4);
00573                 temp = 1.f / dmax(r__3,safmin);
00574                 salfar = temp * s[je + je * s_dim1] * ascale;
00575                 sbeta = temp * p[je + je * p_dim1] * bscale;
00576                 acoef = sbeta * ascale;
00577                 bcoefr = salfar * bscale;
00578                 bcoefi = 0.f;
00579 
00580 /*              Scale to avoid underflow */
00581 
00582                 scale = 1.f;
00583                 lsa = dabs(sbeta) >= safmin && dabs(acoef) < small;
00584                 lsb = dabs(salfar) >= safmin && dabs(bcoefr) < small;
00585                 if (lsa) {
00586                     scale = small / dabs(sbeta) * dmin(anorm,big);
00587                 }
00588                 if (lsb) {
00589 /* Computing MAX */
00590                     r__1 = scale, r__2 = small / dabs(salfar) * dmin(bnorm,
00591                             big);
00592                     scale = dmax(r__1,r__2);
00593                 }
00594                 if (lsa || lsb) {
00595 /* Computing MIN */
00596 /* Computing MAX */
00597                     r__3 = 1.f, r__4 = dabs(acoef), r__3 = max(r__3,r__4), 
00598                             r__4 = dabs(bcoefr);
00599                     r__1 = scale, r__2 = 1.f / (safmin * dmax(r__3,r__4));
00600                     scale = dmin(r__1,r__2);
00601                     if (lsa) {
00602                         acoef = ascale * (scale * sbeta);
00603                     } else {
00604                         acoef = scale * acoef;
00605                     }
00606                     if (lsb) {
00607                         bcoefr = bscale * (scale * salfar);
00608                     } else {
00609                         bcoefr = scale * bcoefr;
00610                     }
00611                 }
00612                 acoefa = dabs(acoef);
00613                 bcoefa = dabs(bcoefr);
00614 
00615 /*              First component is 1 */
00616 
00617                 work[(*n << 1) + je] = 1.f;
00618                 xmax = 1.f;
00619             } else {
00620 
00621 /*              Complex eigenvalue */
00622 
00623                 r__1 = safmin * 100.f;
00624                 slag2_(&s[je + je * s_dim1], lds, &p[je + je * p_dim1], ldp, &
00625                         r__1, &acoef, &temp, &bcoefr, &temp2, &bcoefi);
00626                 bcoefi = -bcoefi;
00627                 if (bcoefi == 0.f) {
00628                     *info = je;
00629                     return 0;
00630                 }
00631 
00632 /*              Scale to avoid over/underflow */
00633 
00634                 acoefa = dabs(acoef);
00635                 bcoefa = dabs(bcoefr) + dabs(bcoefi);
00636                 scale = 1.f;
00637                 if (acoefa * ulp < safmin && acoefa >= safmin) {
00638                     scale = safmin / ulp / acoefa;
00639                 }
00640                 if (bcoefa * ulp < safmin && bcoefa >= safmin) {
00641 /* Computing MAX */
00642                     r__1 = scale, r__2 = safmin / ulp / bcoefa;
00643                     scale = dmax(r__1,r__2);
00644                 }
00645                 if (safmin * acoefa > ascale) {
00646                     scale = ascale / (safmin * acoefa);
00647                 }
00648                 if (safmin * bcoefa > bscale) {
00649 /* Computing MIN */
00650                     r__1 = scale, r__2 = bscale / (safmin * bcoefa);
00651                     scale = dmin(r__1,r__2);
00652                 }
00653                 if (scale != 1.f) {
00654                     acoef = scale * acoef;
00655                     acoefa = dabs(acoef);
00656                     bcoefr = scale * bcoefr;
00657                     bcoefi = scale * bcoefi;
00658                     bcoefa = dabs(bcoefr) + dabs(bcoefi);
00659                 }
00660 
00661 /*              Compute first two components of eigenvector */
00662 
00663                 temp = acoef * s[je + 1 + je * s_dim1];
00664                 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je * 
00665                         p_dim1];
00666                 temp2i = -bcoefi * p[je + je * p_dim1];
00667                 if (dabs(temp) > dabs(temp2r) + dabs(temp2i)) {
00668                     work[(*n << 1) + je] = 1.f;
00669                     work[*n * 3 + je] = 0.f;
00670                     work[(*n << 1) + je + 1] = -temp2r / temp;
00671                     work[*n * 3 + je + 1] = -temp2i / temp;
00672                 } else {
00673                     work[(*n << 1) + je + 1] = 1.f;
00674                     work[*n * 3 + je + 1] = 0.f;
00675                     temp = acoef * s[je + (je + 1) * s_dim1];
00676                     work[(*n << 1) + je] = (bcoefr * p[je + 1 + (je + 1) * 
00677                             p_dim1] - acoef * s[je + 1 + (je + 1) * s_dim1]) /
00678                              temp;
00679                     work[*n * 3 + je] = bcoefi * p[je + 1 + (je + 1) * p_dim1]
00680                              / temp;
00681                 }
00682 /* Computing MAX */
00683                 r__5 = (r__1 = work[(*n << 1) + je], dabs(r__1)) + (r__2 = 
00684                         work[*n * 3 + je], dabs(r__2)), r__6 = (r__3 = work[(*
00685                         n << 1) + je + 1], dabs(r__3)) + (r__4 = work[*n * 3 
00686                         + je + 1], dabs(r__4));
00687                 xmax = dmax(r__5,r__6);
00688             }
00689 
00690 /* Computing MAX */
00691             r__1 = ulp * acoefa * anorm, r__2 = ulp * bcoefa * bnorm, r__1 = 
00692                     max(r__1,r__2);
00693             dmin__ = dmax(r__1,safmin);
00694 
00695 /*                                           T */
00696 /*           Triangular solve of  (a A - b B)  y = 0 */
00697 
00698 /*                                   T */
00699 /*           (rowwise in  (a A - b B) , or columnwise in (a A - b B) ) */
00700 
00701             il2by2 = FALSE_;
00702 
00703             i__2 = *n;
00704             for (j = je + nw; j <= i__2; ++j) {
00705                 if (il2by2) {
00706                     il2by2 = FALSE_;
00707                     goto L160;
00708                 }
00709 
00710                 na = 1;
00711                 bdiag[0] = p[j + j * p_dim1];
00712                 if (j < *n) {
00713                     if (s[j + 1 + j * s_dim1] != 0.f) {
00714                         il2by2 = TRUE_;
00715                         bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
00716                         na = 2;
00717                     }
00718                 }
00719 
00720 /*              Check whether scaling is necessary for dot products */
00721 
00722                 xscale = 1.f / dmax(1.f,xmax);
00723 /* Computing MAX */
00724                 r__1 = work[j], r__2 = work[*n + j], r__1 = max(r__1,r__2), 
00725                         r__2 = acoefa * work[j] + bcoefa * work[*n + j];
00726                 temp = dmax(r__1,r__2);
00727                 if (il2by2) {
00728 /* Computing MAX */
00729                     r__1 = temp, r__2 = work[j + 1], r__1 = max(r__1,r__2), 
00730                             r__2 = work[*n + j + 1], r__1 = max(r__1,r__2), 
00731                             r__2 = acoefa * work[j + 1] + bcoefa * work[*n + 
00732                             j + 1];
00733                     temp = dmax(r__1,r__2);
00734                 }
00735                 if (temp > bignum * xscale) {
00736                     i__3 = nw - 1;
00737                     for (jw = 0; jw <= i__3; ++jw) {
00738                         i__4 = j - 1;
00739                         for (jr = je; jr <= i__4; ++jr) {
00740                             work[(jw + 2) * *n + jr] = xscale * work[(jw + 2) 
00741                                     * *n + jr];
00742 /* L80: */
00743                         }
00744 /* L90: */
00745                     }
00746                     xmax *= xscale;
00747                 }
00748 
00749 /*              Compute dot products */
00750 
00751 /*                    j-1 */
00752 /*              SUM = sum  conjg( a*S(k,j) - b*P(k,j) )*x(k) */
00753 /*                    k=je */
00754 
00755 /*              To reduce the op count, this is done as */
00756 
00757 /*              _        j-1                  _        j-1 */
00758 /*              a*conjg( sum  S(k,j)*x(k) ) - b*conjg( sum  P(k,j)*x(k) ) */
00759 /*                       k=je                          k=je */
00760 
00761 /*              which may cause underflow problems if A or B are close */
00762 /*              to underflow.  (E.g., less than SMALL.) */
00763 
00764 
00765 /*              A series of compiler directives to defeat vectorization */
00766 /*              for the next loop */
00767 
00768 /* $PL$ CMCHAR=' ' */
00769 /* DIR$          NEXTSCALAR */
00770 /* $DIR          SCALAR */
00771 /* DIR$          NEXT SCALAR */
00772 /* VD$L          NOVECTOR */
00773 /* DEC$          NOVECTOR */
00774 /* VD$           NOVECTOR */
00775 /* VDIR          NOVECTOR */
00776 /* VOCL          LOOP,SCALAR */
00777 /* IBM           PREFER SCALAR */
00778 /* $PL$ CMCHAR='*' */
00779 
00780                 i__3 = nw;
00781                 for (jw = 1; jw <= i__3; ++jw) {
00782 
00783 /* $PL$ CMCHAR=' ' */
00784 /* DIR$             NEXTSCALAR */
00785 /* $DIR             SCALAR */
00786 /* DIR$             NEXT SCALAR */
00787 /* VD$L             NOVECTOR */
00788 /* DEC$             NOVECTOR */
00789 /* VD$              NOVECTOR */
00790 /* VDIR             NOVECTOR */
00791 /* VOCL             LOOP,SCALAR */
00792 /* IBM              PREFER SCALAR */
00793 /* $PL$ CMCHAR='*' */
00794 
00795                     i__4 = na;
00796                     for (ja = 1; ja <= i__4; ++ja) {
00797                         sums[ja + (jw << 1) - 3] = 0.f;
00798                         sump[ja + (jw << 1) - 3] = 0.f;
00799 
00800                         i__5 = j - 1;
00801                         for (jr = je; jr <= i__5; ++jr) {
00802                             sums[ja + (jw << 1) - 3] += s[jr + (j + ja - 1) * 
00803                                     s_dim1] * work[(jw + 1) * *n + jr];
00804                             sump[ja + (jw << 1) - 3] += p[jr + (j + ja - 1) * 
00805                                     p_dim1] * work[(jw + 1) * *n + jr];
00806 /* L100: */
00807                         }
00808 /* L110: */
00809                     }
00810 /* L120: */
00811                 }
00812 
00813 /* $PL$ CMCHAR=' ' */
00814 /* DIR$          NEXTSCALAR */
00815 /* $DIR          SCALAR */
00816 /* DIR$          NEXT SCALAR */
00817 /* VD$L          NOVECTOR */
00818 /* DEC$          NOVECTOR */
00819 /* VD$           NOVECTOR */
00820 /* VDIR          NOVECTOR */
00821 /* VOCL          LOOP,SCALAR */
00822 /* IBM           PREFER SCALAR */
00823 /* $PL$ CMCHAR='*' */
00824 
00825                 i__3 = na;
00826                 for (ja = 1; ja <= i__3; ++ja) {
00827                     if (ilcplx) {
00828                         sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
00829                                 ja - 1] - bcoefi * sump[ja + 1];
00830                         sum[ja + 1] = -acoef * sums[ja + 1] + bcoefr * sump[
00831                                 ja + 1] + bcoefi * sump[ja - 1];
00832                     } else {
00833                         sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
00834                                 ja - 1];
00835                     }
00836 /* L130: */
00837                 }
00838 
00839 /*                                  T */
00840 /*              Solve  ( a A - b B )  y = SUM(,) */
00841 /*              with scaling and perturbation of the denominator */
00842 
00843                 slaln2_(&c_true, &na, &nw, &dmin__, &acoef, &s[j + j * s_dim1]
00844 , lds, bdiag, &bdiag[1], sum, &c__2, &bcoefr, &bcoefi, 
00845                          &work[(*n << 1) + j], n, &scale, &temp, &iinfo);
00846                 if (scale < 1.f) {
00847                     i__3 = nw - 1;
00848                     for (jw = 0; jw <= i__3; ++jw) {
00849                         i__4 = j - 1;
00850                         for (jr = je; jr <= i__4; ++jr) {
00851                             work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
00852                                      *n + jr];
00853 /* L140: */
00854                         }
00855 /* L150: */
00856                     }
00857                     xmax = scale * xmax;
00858                 }
00859                 xmax = dmax(xmax,temp);
00860 L160:
00861                 ;
00862             }
00863 
00864 /*           Copy eigenvector to VL, back transforming if */
00865 /*           HOWMNY='B'. */
00866 
00867             ++ieig;
00868             if (ilback) {
00869                 i__2 = nw - 1;
00870                 for (jw = 0; jw <= i__2; ++jw) {
00871                     i__3 = *n + 1 - je;
00872                     sgemv_("N", n, &i__3, &c_b34, &vl[je * vl_dim1 + 1], ldvl, 
00873                              &work[(jw + 2) * *n + je], &c__1, &c_b36, &work[(
00874                             jw + 4) * *n + 1], &c__1);
00875 /* L170: */
00876                 }
00877                 slacpy_(" ", n, &nw, &work[(*n << 2) + 1], n, &vl[je * 
00878                         vl_dim1 + 1], ldvl);
00879                 ibeg = 1;
00880             } else {
00881                 slacpy_(" ", n, &nw, &work[(*n << 1) + 1], n, &vl[ieig * 
00882                         vl_dim1 + 1], ldvl);
00883                 ibeg = je;
00884             }
00885 
00886 /*           Scale eigenvector */
00887 
00888             xmax = 0.f;
00889             if (ilcplx) {
00890                 i__2 = *n;
00891                 for (j = ibeg; j <= i__2; ++j) {
00892 /* Computing MAX */
00893                     r__3 = xmax, r__4 = (r__1 = vl[j + ieig * vl_dim1], dabs(
00894                             r__1)) + (r__2 = vl[j + (ieig + 1) * vl_dim1], 
00895                             dabs(r__2));
00896                     xmax = dmax(r__3,r__4);
00897 /* L180: */
00898                 }
00899             } else {
00900                 i__2 = *n;
00901                 for (j = ibeg; j <= i__2; ++j) {
00902 /* Computing MAX */
00903                     r__2 = xmax, r__3 = (r__1 = vl[j + ieig * vl_dim1], dabs(
00904                             r__1));
00905                     xmax = dmax(r__2,r__3);
00906 /* L190: */
00907                 }
00908             }
00909 
00910             if (xmax > safmin) {
00911                 xscale = 1.f / xmax;
00912 
00913                 i__2 = nw - 1;
00914                 for (jw = 0; jw <= i__2; ++jw) {
00915                     i__3 = *n;
00916                     for (jr = ibeg; jr <= i__3; ++jr) {
00917                         vl[jr + (ieig + jw) * vl_dim1] = xscale * vl[jr + (
00918                                 ieig + jw) * vl_dim1];
00919 /* L200: */
00920                     }
00921 /* L210: */
00922                 }
00923             }
00924             ieig = ieig + nw - 1;
00925 
00926 L220:
00927             ;
00928         }
00929     }
00930 
00931 /*     Right eigenvectors */
00932 
00933     if (compr) {
00934         ieig = im + 1;
00935 
00936 /*        Main loop over eigenvalues */
00937 
00938         ilcplx = FALSE_;
00939         for (je = *n; je >= 1; --je) {
00940 
00941 /*           Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
00942 /*           (b) this would be the second of a complex pair. */
00943 /*           Check for complex eigenvalue, so as to be sure of which */
00944 /*           entry(-ies) of SELECT to look at -- if complex, SELECT(JE) */
00945 /*           or SELECT(JE-1). */
00946 /*           If this is a complex pair, the 2-by-2 diagonal block */
00947 /*           corresponding to the eigenvalue is in rows/columns JE-1:JE */
00948 
00949             if (ilcplx) {
00950                 ilcplx = FALSE_;
00951                 goto L500;
00952             }
00953             nw = 1;
00954             if (je > 1) {
00955                 if (s[je + (je - 1) * s_dim1] != 0.f) {
00956                     ilcplx = TRUE_;
00957                     nw = 2;
00958                 }
00959             }
00960             if (ilall) {
00961                 ilcomp = TRUE_;
00962             } else if (ilcplx) {
00963                 ilcomp = select[je] || select[je - 1];
00964             } else {
00965                 ilcomp = select[je];
00966             }
00967             if (! ilcomp) {
00968                 goto L500;
00969             }
00970 
00971 /*           Decide if (a) singular pencil, (b) real eigenvalue, or */
00972 /*           (c) complex eigenvalue. */
00973 
00974             if (! ilcplx) {
00975                 if ((r__1 = s[je + je * s_dim1], dabs(r__1)) <= safmin && (
00976                         r__2 = p[je + je * p_dim1], dabs(r__2)) <= safmin) {
00977 
00978 /*                 Singular matrix pencil -- unit eigenvector */
00979 
00980                     --ieig;
00981                     i__1 = *n;
00982                     for (jr = 1; jr <= i__1; ++jr) {
00983                         vr[jr + ieig * vr_dim1] = 0.f;
00984 /* L230: */
00985                     }
00986                     vr[ieig + ieig * vr_dim1] = 1.f;
00987                     goto L500;
00988                 }
00989             }
00990 
00991 /*           Clear vector */
00992 
00993             i__1 = nw - 1;
00994             for (jw = 0; jw <= i__1; ++jw) {
00995                 i__2 = *n;
00996                 for (jr = 1; jr <= i__2; ++jr) {
00997                     work[(jw + 2) * *n + jr] = 0.f;
00998 /* L240: */
00999                 }
01000 /* L250: */
01001             }
01002 
01003 /*           Compute coefficients in  ( a A - b B ) x = 0 */
01004 /*              a  is  ACOEF */
01005 /*              b  is  BCOEFR + i*BCOEFI */
01006 
01007             if (! ilcplx) {
01008 
01009 /*              Real eigenvalue */
01010 
01011 /* Computing MAX */
01012                 r__3 = (r__1 = s[je + je * s_dim1], dabs(r__1)) * ascale, 
01013                         r__4 = (r__2 = p[je + je * p_dim1], dabs(r__2)) * 
01014                         bscale, r__3 = max(r__3,r__4);
01015                 temp = 1.f / dmax(r__3,safmin);
01016                 salfar = temp * s[je + je * s_dim1] * ascale;
01017                 sbeta = temp * p[je + je * p_dim1] * bscale;
01018                 acoef = sbeta * ascale;
01019                 bcoefr = salfar * bscale;
01020                 bcoefi = 0.f;
01021 
01022 /*              Scale to avoid underflow */
01023 
01024                 scale = 1.f;
01025                 lsa = dabs(sbeta) >= safmin && dabs(acoef) < small;
01026                 lsb = dabs(salfar) >= safmin && dabs(bcoefr) < small;
01027                 if (lsa) {
01028                     scale = small / dabs(sbeta) * dmin(anorm,big);
01029                 }
01030                 if (lsb) {
01031 /* Computing MAX */
01032                     r__1 = scale, r__2 = small / dabs(salfar) * dmin(bnorm,
01033                             big);
01034                     scale = dmax(r__1,r__2);
01035                 }
01036                 if (lsa || lsb) {
01037 /* Computing MIN */
01038 /* Computing MAX */
01039                     r__3 = 1.f, r__4 = dabs(acoef), r__3 = max(r__3,r__4), 
01040                             r__4 = dabs(bcoefr);
01041                     r__1 = scale, r__2 = 1.f / (safmin * dmax(r__3,r__4));
01042                     scale = dmin(r__1,r__2);
01043                     if (lsa) {
01044                         acoef = ascale * (scale * sbeta);
01045                     } else {
01046                         acoef = scale * acoef;
01047                     }
01048                     if (lsb) {
01049                         bcoefr = bscale * (scale * salfar);
01050                     } else {
01051                         bcoefr = scale * bcoefr;
01052                     }
01053                 }
01054                 acoefa = dabs(acoef);
01055                 bcoefa = dabs(bcoefr);
01056 
01057 /*              First component is 1 */
01058 
01059                 work[(*n << 1) + je] = 1.f;
01060                 xmax = 1.f;
01061 
01062 /*              Compute contribution from column JE of A and B to sum */
01063 /*              (See "Further Details", above.) */
01064 
01065                 i__1 = je - 1;
01066                 for (jr = 1; jr <= i__1; ++jr) {
01067                     work[(*n << 1) + jr] = bcoefr * p[jr + je * p_dim1] - 
01068                             acoef * s[jr + je * s_dim1];
01069 /* L260: */
01070                 }
01071             } else {
01072 
01073 /*              Complex eigenvalue */
01074 
01075                 r__1 = safmin * 100.f;
01076                 slag2_(&s[je - 1 + (je - 1) * s_dim1], lds, &p[je - 1 + (je - 
01077                         1) * p_dim1], ldp, &r__1, &acoef, &temp, &bcoefr, &
01078                         temp2, &bcoefi);
01079                 if (bcoefi == 0.f) {
01080                     *info = je - 1;
01081                     return 0;
01082                 }
01083 
01084 /*              Scale to avoid over/underflow */
01085 
01086                 acoefa = dabs(acoef);
01087                 bcoefa = dabs(bcoefr) + dabs(bcoefi);
01088                 scale = 1.f;
01089                 if (acoefa * ulp < safmin && acoefa >= safmin) {
01090                     scale = safmin / ulp / acoefa;
01091                 }
01092                 if (bcoefa * ulp < safmin && bcoefa >= safmin) {
01093 /* Computing MAX */
01094                     r__1 = scale, r__2 = safmin / ulp / bcoefa;
01095                     scale = dmax(r__1,r__2);
01096                 }
01097                 if (safmin * acoefa > ascale) {
01098                     scale = ascale / (safmin * acoefa);
01099                 }
01100                 if (safmin * bcoefa > bscale) {
01101 /* Computing MIN */
01102                     r__1 = scale, r__2 = bscale / (safmin * bcoefa);
01103                     scale = dmin(r__1,r__2);
01104                 }
01105                 if (scale != 1.f) {
01106                     acoef = scale * acoef;
01107                     acoefa = dabs(acoef);
01108                     bcoefr = scale * bcoefr;
01109                     bcoefi = scale * bcoefi;
01110                     bcoefa = dabs(bcoefr) + dabs(bcoefi);
01111                 }
01112 
01113 /*              Compute first two components of eigenvector */
01114 /*              and contribution to sums */
01115 
01116                 temp = acoef * s[je + (je - 1) * s_dim1];
01117                 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je * 
01118                         p_dim1];
01119                 temp2i = -bcoefi * p[je + je * p_dim1];
01120                 if (dabs(temp) >= dabs(temp2r) + dabs(temp2i)) {
01121                     work[(*n << 1) + je] = 1.f;
01122                     work[*n * 3 + je] = 0.f;
01123                     work[(*n << 1) + je - 1] = -temp2r / temp;
01124                     work[*n * 3 + je - 1] = -temp2i / temp;
01125                 } else {
01126                     work[(*n << 1) + je - 1] = 1.f;
01127                     work[*n * 3 + je - 1] = 0.f;
01128                     temp = acoef * s[je - 1 + je * s_dim1];
01129                     work[(*n << 1) + je] = (bcoefr * p[je - 1 + (je - 1) * 
01130                             p_dim1] - acoef * s[je - 1 + (je - 1) * s_dim1]) /
01131                              temp;
01132                     work[*n * 3 + je] = bcoefi * p[je - 1 + (je - 1) * p_dim1]
01133                              / temp;
01134                 }
01135 
01136 /* Computing MAX */
01137                 r__5 = (r__1 = work[(*n << 1) + je], dabs(r__1)) + (r__2 = 
01138                         work[*n * 3 + je], dabs(r__2)), r__6 = (r__3 = work[(*
01139                         n << 1) + je - 1], dabs(r__3)) + (r__4 = work[*n * 3 
01140                         + je - 1], dabs(r__4));
01141                 xmax = dmax(r__5,r__6);
01142 
01143 /*              Compute contribution from columns JE and JE-1 */
01144 /*              of A and B to the sums. */
01145 
01146                 creala = acoef * work[(*n << 1) + je - 1];
01147                 cimaga = acoef * work[*n * 3 + je - 1];
01148                 crealb = bcoefr * work[(*n << 1) + je - 1] - bcoefi * work[*n 
01149                         * 3 + je - 1];
01150                 cimagb = bcoefi * work[(*n << 1) + je - 1] + bcoefr * work[*n 
01151                         * 3 + je - 1];
01152                 cre2a = acoef * work[(*n << 1) + je];
01153                 cim2a = acoef * work[*n * 3 + je];
01154                 cre2b = bcoefr * work[(*n << 1) + je] - bcoefi * work[*n * 3 
01155                         + je];
01156                 cim2b = bcoefi * work[(*n << 1) + je] + bcoefr * work[*n * 3 
01157                         + je];
01158                 i__1 = je - 2;
01159                 for (jr = 1; jr <= i__1; ++jr) {
01160                     work[(*n << 1) + jr] = -creala * s[jr + (je - 1) * s_dim1]
01161                              + crealb * p[jr + (je - 1) * p_dim1] - cre2a * s[
01162                             jr + je * s_dim1] + cre2b * p[jr + je * p_dim1];
01163                     work[*n * 3 + jr] = -cimaga * s[jr + (je - 1) * s_dim1] + 
01164                             cimagb * p[jr + (je - 1) * p_dim1] - cim2a * s[jr 
01165                             + je * s_dim1] + cim2b * p[jr + je * p_dim1];
01166 /* L270: */
01167                 }
01168             }
01169 
01170 /* Computing MAX */
01171             r__1 = ulp * acoefa * anorm, r__2 = ulp * bcoefa * bnorm, r__1 = 
01172                     max(r__1,r__2);
01173             dmin__ = dmax(r__1,safmin);
01174 
01175 /*           Columnwise triangular solve of  (a A - b B)  x = 0 */
01176 
01177             il2by2 = FALSE_;
01178             for (j = je - nw; j >= 1; --j) {
01179 
01180 /*              If a 2-by-2 block, is in position j-1:j, wait until */
01181 /*              next iteration to process it (when it will be j:j+1) */
01182 
01183                 if (! il2by2 && j > 1) {
01184                     if (s[j + (j - 1) * s_dim1] != 0.f) {
01185                         il2by2 = TRUE_;
01186                         goto L370;
01187                     }
01188                 }
01189                 bdiag[0] = p[j + j * p_dim1];
01190                 if (il2by2) {
01191                     na = 2;
01192                     bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
01193                 } else {
01194                     na = 1;
01195                 }
01196 
01197 /*              Compute x(j) (and x(j+1), if 2-by-2 block) */
01198 
01199                 slaln2_(&c_false, &na, &nw, &dmin__, &acoef, &s[j + j * 
01200                         s_dim1], lds, bdiag, &bdiag[1], &work[(*n << 1) + j], 
01201                         n, &bcoefr, &bcoefi, sum, &c__2, &scale, &temp, &
01202                         iinfo);
01203                 if (scale < 1.f) {
01204 
01205                     i__1 = nw - 1;
01206                     for (jw = 0; jw <= i__1; ++jw) {
01207                         i__2 = je;
01208                         for (jr = 1; jr <= i__2; ++jr) {
01209                             work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
01210                                      *n + jr];
01211 /* L280: */
01212                         }
01213 /* L290: */
01214                     }
01215                 }
01216 /* Computing MAX */
01217                 r__1 = scale * xmax;
01218                 xmax = dmax(r__1,temp);
01219 
01220                 i__1 = nw;
01221                 for (jw = 1; jw <= i__1; ++jw) {
01222                     i__2 = na;
01223                     for (ja = 1; ja <= i__2; ++ja) {
01224                         work[(jw + 1) * *n + j + ja - 1] = sum[ja + (jw << 1) 
01225                                 - 3];
01226 /* L300: */
01227                     }
01228 /* L310: */
01229                 }
01230 
01231 /*              w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling */
01232 
01233                 if (j > 1) {
01234 
01235 /*                 Check whether scaling is necessary for sum. */
01236 
01237                     xscale = 1.f / dmax(1.f,xmax);
01238                     temp = acoefa * work[j] + bcoefa * work[*n + j];
01239                     if (il2by2) {
01240 /* Computing MAX */
01241                         r__1 = temp, r__2 = acoefa * work[j + 1] + bcoefa * 
01242                                 work[*n + j + 1];
01243                         temp = dmax(r__1,r__2);
01244                     }
01245 /* Computing MAX */
01246                     r__1 = max(temp,acoefa);
01247                     temp = dmax(r__1,bcoefa);
01248                     if (temp > bignum * xscale) {
01249 
01250                         i__1 = nw - 1;
01251                         for (jw = 0; jw <= i__1; ++jw) {
01252                             i__2 = je;
01253                             for (jr = 1; jr <= i__2; ++jr) {
01254                                 work[(jw + 2) * *n + jr] = xscale * work[(jw 
01255                                         + 2) * *n + jr];
01256 /* L320: */
01257                             }
01258 /* L330: */
01259                         }
01260                         xmax *= xscale;
01261                     }
01262 
01263 /*                 Compute the contributions of the off-diagonals of */
01264 /*                 column j (and j+1, if 2-by-2 block) of A and B to the */
01265 /*                 sums. */
01266 
01267 
01268                     i__1 = na;
01269                     for (ja = 1; ja <= i__1; ++ja) {
01270                         if (ilcplx) {
01271                             creala = acoef * work[(*n << 1) + j + ja - 1];
01272                             cimaga = acoef * work[*n * 3 + j + ja - 1];
01273                             crealb = bcoefr * work[(*n << 1) + j + ja - 1] - 
01274                                     bcoefi * work[*n * 3 + j + ja - 1];
01275                             cimagb = bcoefi * work[(*n << 1) + j + ja - 1] + 
01276                                     bcoefr * work[*n * 3 + j + ja - 1];
01277                             i__2 = j - 1;
01278                             for (jr = 1; jr <= i__2; ++jr) {
01279                                 work[(*n << 1) + jr] = work[(*n << 1) + jr] - 
01280                                         creala * s[jr + (j + ja - 1) * s_dim1]
01281                                          + crealb * p[jr + (j + ja - 1) * 
01282                                         p_dim1];
01283                                 work[*n * 3 + jr] = work[*n * 3 + jr] - 
01284                                         cimaga * s[jr + (j + ja - 1) * s_dim1]
01285                                          + cimagb * p[jr + (j + ja - 1) * 
01286                                         p_dim1];
01287 /* L340: */
01288                             }
01289                         } else {
01290                             creala = acoef * work[(*n << 1) + j + ja - 1];
01291                             crealb = bcoefr * work[(*n << 1) + j + ja - 1];
01292                             i__2 = j - 1;
01293                             for (jr = 1; jr <= i__2; ++jr) {
01294                                 work[(*n << 1) + jr] = work[(*n << 1) + jr] - 
01295                                         creala * s[jr + (j + ja - 1) * s_dim1]
01296                                          + crealb * p[jr + (j + ja - 1) * 
01297                                         p_dim1];
01298 /* L350: */
01299                             }
01300                         }
01301 /* L360: */
01302                     }
01303                 }
01304 
01305                 il2by2 = FALSE_;
01306 L370:
01307                 ;
01308             }
01309 
01310 /*           Copy eigenvector to VR, back transforming if */
01311 /*           HOWMNY='B'. */
01312 
01313             ieig -= nw;
01314             if (ilback) {
01315 
01316                 i__1 = nw - 1;
01317                 for (jw = 0; jw <= i__1; ++jw) {
01318                     i__2 = *n;
01319                     for (jr = 1; jr <= i__2; ++jr) {
01320                         work[(jw + 4) * *n + jr] = work[(jw + 2) * *n + 1] * 
01321                                 vr[jr + vr_dim1];
01322 /* L380: */
01323                     }
01324 
01325 /*                 A series of compiler directives to defeat */
01326 /*                 vectorization for the next loop */
01327 
01328 
01329                     i__2 = je;
01330                     for (jc = 2; jc <= i__2; ++jc) {
01331                         i__3 = *n;
01332                         for (jr = 1; jr <= i__3; ++jr) {
01333                             work[(jw + 4) * *n + jr] += work[(jw + 2) * *n + 
01334                                     jc] * vr[jr + jc * vr_dim1];
01335 /* L390: */
01336                         }
01337 /* L400: */
01338                     }
01339 /* L410: */
01340                 }
01341 
01342                 i__1 = nw - 1;
01343                 for (jw = 0; jw <= i__1; ++jw) {
01344                     i__2 = *n;
01345                     for (jr = 1; jr <= i__2; ++jr) {
01346                         vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 4) * *n + 
01347                                 jr];
01348 /* L420: */
01349                     }
01350 /* L430: */
01351                 }
01352 
01353                 iend = *n;
01354             } else {
01355                 i__1 = nw - 1;
01356                 for (jw = 0; jw <= i__1; ++jw) {
01357                     i__2 = *n;
01358                     for (jr = 1; jr <= i__2; ++jr) {
01359                         vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 2) * *n + 
01360                                 jr];
01361 /* L440: */
01362                     }
01363 /* L450: */
01364                 }
01365 
01366                 iend = je;
01367             }
01368 
01369 /*           Scale eigenvector */
01370 
01371             xmax = 0.f;
01372             if (ilcplx) {
01373                 i__1 = iend;
01374                 for (j = 1; j <= i__1; ++j) {
01375 /* Computing MAX */
01376                     r__3 = xmax, r__4 = (r__1 = vr[j + ieig * vr_dim1], dabs(
01377                             r__1)) + (r__2 = vr[j + (ieig + 1) * vr_dim1], 
01378                             dabs(r__2));
01379                     xmax = dmax(r__3,r__4);
01380 /* L460: */
01381                 }
01382             } else {
01383                 i__1 = iend;
01384                 for (j = 1; j <= i__1; ++j) {
01385 /* Computing MAX */
01386                     r__2 = xmax, r__3 = (r__1 = vr[j + ieig * vr_dim1], dabs(
01387                             r__1));
01388                     xmax = dmax(r__2,r__3);
01389 /* L470: */
01390                 }
01391             }
01392 
01393             if (xmax > safmin) {
01394                 xscale = 1.f / xmax;
01395                 i__1 = nw - 1;
01396                 for (jw = 0; jw <= i__1; ++jw) {
01397                     i__2 = iend;
01398                     for (jr = 1; jr <= i__2; ++jr) {
01399                         vr[jr + (ieig + jw) * vr_dim1] = xscale * vr[jr + (
01400                                 ieig + jw) * vr_dim1];
01401 /* L480: */
01402                     }
01403 /* L490: */
01404                 }
01405             }
01406 L500:
01407             ;
01408         }
01409     }
01410 
01411     return 0;
01412 
01413 /*     End of STGEVC */
01414 
01415 } /* stgevc_ */


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