1 /* ../netlib/stgevc.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib;
2  on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
3 #include "FLA_f2c.h" /* Table of constant values */
4 static logical c_true = TRUE_;
5 static integer c__2 = 2;
6 static real c_b34 = 1.f;
7 static integer c__1 = 1;
8 static real c_b36 = 0.f;
9 static logical c_false = FALSE_;
10 /* > \brief \b STGEVC */
11 /* =========== DOCUMENTATION =========== */
12 /* Online html documentation available at */
13 /* http://www.netlib.org/lapack/explore-html/ */
14 /* > \htmlonly */
15 /* > Download STGEVC + dependencies */
16 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stgevc. f"> */
17 /* > [TGZ]</a> */
18 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stgevc. f"> */
19 /* > [ZIP]</a> */
20 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stgevc. f"> */
21 /* > [TXT]</a> */
22 /* > \endhtmlonly */
23 /* Definition: */
24 /* =========== */
25 /* SUBROUTINE STGEVC( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL, */
26 /* LDVL, VR, LDVR, MM, M, WORK, INFO ) */
27 /* .. Scalar Arguments .. */
28 /* CHARACTER HOWMNY, SIDE */
29 /* INTEGER INFO, LDP, LDS, LDVL, LDVR, M, MM, N */
30 /* .. */
31 /* .. Array Arguments .. */
32 /* LOGICAL SELECT( * ) */
33 /* REAL P( LDP, * ), S( LDS, * ), VL( LDVL, * ), */
34 /* $ VR( LDVR, * ), WORK( * ) */
35 /* .. */
36 /* > \par Purpose: */
37 /* ============= */
38 /* > */
39 /* > \verbatim */
40 /* > */
41 /* > STGEVC computes some or all of the right and/or left eigenvectors of */
42 /* > a pair of real matrices (S,P), where S is a quasi-triangular matrix */
43 /* > and P is upper triangular. Matrix pairs of this type are produced by */
44 /* > the generalized Schur factorization of a matrix pair (A,B): */
45 /* > */
46 /* > A = Q*S*Z**T, B = Q*P*Z**T */
47 /* > */
48 /* > as computed by SGGHRD + SHGEQZ. */
49 /* > */
50 /* > The right eigenvector x and the left eigenvector y of (S,P) */
51 /* > corresponding to an eigenvalue w are defined by: */
52 /* > */
53 /* > S*x = w*P*x, (y**H)*S = w*(y**H)*P, */
54 /* > */
55 /* > where y**H denotes the conjugate tranpose of y. */
56 /* > The eigenvalues are not input to this routine, but are computed */
57 /* > directly from the diagonal blocks of S and P. */
58 /* > */
59 /* > This routine returns the matrices X and/or Y of right and left */
60 /* > eigenvectors of (S,P), or the products Z*X and/or Q*Y, */
61 /* > where Z and Q are input matrices. */
62 /* > If Q and Z are the orthogonal factors from the generalized Schur */
63 /* > factorization of a matrix pair (A,B), then Z*X and Q*Y */
64 /* > are the matrices of right and left eigenvectors of (A,B). */
65 /* > */
66 /* > \endverbatim */
67 /* Arguments: */
68 /* ========== */
69 /* > \param[in] SIDE */
70 /* > \verbatim */
71 /* > SIDE is CHARACTER*1 */
72 /* > = 'R': compute right eigenvectors only;
73 */
74 /* > = 'L': compute left eigenvectors only;
75 */
76 /* > = 'B': compute both right and left eigenvectors. */
77 /* > \endverbatim */
78 /* > */
79 /* > \param[in] HOWMNY */
80 /* > \verbatim */
81 /* > HOWMNY is CHARACTER*1 */
82 /* > = 'A': compute all right and/or left eigenvectors;
83 */
84 /* > = 'B': compute all right and/or left eigenvectors, */
85 /* > backtransformed by the matrices in VR and/or VL;
86 */
87 /* > = 'S': compute selected right and/or left eigenvectors, */
88 /* > specified by the logical array SELECT. */
89 /* > \endverbatim */
90 /* > */
91 /* > \param[in] SELECT */
92 /* > \verbatim */
93 /* > SELECT is LOGICAL array, dimension (N) */
94 /* > If HOWMNY='S', SELECT specifies the eigenvectors to be */
95 /* > computed. If w(j) is a real eigenvalue, the corresponding */
96 /* > real eigenvector is computed if SELECT(j) is .TRUE.. */
97 /* > If w(j) and w(j+1) are the real and imaginary parts of a */
98 /* > complex eigenvalue, the corresponding complex eigenvector */
99 /* > is computed if either SELECT(j) or SELECT(j+1) is .TRUE., */
100 /* > and on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is */
101 /* > set to .FALSE.. */
102 /* > Not referenced if HOWMNY = 'A' or 'B'. */
103 /* > \endverbatim */
104 /* > */
105 /* > \param[in] N */
106 /* > \verbatim */
107 /* > N is INTEGER */
108 /* > The order of the matrices S and P. N >= 0. */
109 /* > \endverbatim */
110 /* > */
111 /* > \param[in] S */
112 /* > \verbatim */
113 /* > S is REAL array, dimension (LDS,N) */
114 /* > The upper quasi-triangular matrix S from a generalized Schur */
115 /* > factorization, as computed by SHGEQZ. */
116 /* > \endverbatim */
117 /* > */
118 /* > \param[in] LDS */
119 /* > \verbatim */
120 /* > LDS is INTEGER */
121 /* > The leading dimension of array S. LDS >= max(1,N). */
122 /* > \endverbatim */
123 /* > */
124 /* > \param[in] P */
125 /* > \verbatim */
126 /* > P is REAL array, dimension (LDP,N) */
127 /* > The upper triangular matrix P from a generalized Schur */
128 /* > factorization, as computed by SHGEQZ. */
129 /* > 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks */
130 /* > of S must be in positive diagonal form. */
131 /* > \endverbatim */
132 /* > */
133 /* > \param[in] LDP */
134 /* > \verbatim */
135 /* > LDP is INTEGER */
136 /* > The leading dimension of array P. LDP >= max(1,N). */
137 /* > \endverbatim */
138 /* > */
139 /* > \param[in,out] VL */
140 /* > \verbatim */
141 /* > VL is REAL array, dimension (LDVL,MM) */
142 /* > On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must */
143 /* > contain an N-by-N matrix Q (usually the orthogonal matrix Q */
144 /* > of left Schur vectors returned by SHGEQZ). */
145 /* > On exit, if SIDE = 'L' or 'B', VL contains: */
146 /* > if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P);
147 */
148 /* > if HOWMNY = 'B', the matrix Q*Y;
149 */
150 /* > if HOWMNY = 'S', the left eigenvectors of (S,P) specified by */
151 /* > SELECT, stored consecutively in the columns of */
152 /* > VL, in the same order as their eigenvalues. */
153 /* > */
154 /* > A complex eigenvector corresponding to a complex eigenvalue */
155 /* > is stored in two consecutive columns, the first holding the */
156 /* > real part, and the second the imaginary part. */
157 /* > */
158 /* > Not referenced if SIDE = 'R'. */
159 /* > \endverbatim */
160 /* > */
161 /* > \param[in] LDVL */
162 /* > \verbatim */
163 /* > LDVL is INTEGER */
164 /* > The leading dimension of array VL. LDVL >= 1, and if */
165 /* > SIDE = 'L' or 'B', LDVL >= N. */
166 /* > \endverbatim */
167 /* > */
168 /* > \param[in,out] VR */
169 /* > \verbatim */
170 /* > VR is REAL array, dimension (LDVR,MM) */
171 /* > On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must */
172 /* > contain an N-by-N matrix Z (usually the orthogonal matrix Z */
173 /* > of right Schur vectors returned by SHGEQZ). */
174 /* > */
175 /* > On exit, if SIDE = 'R' or 'B', VR contains: */
176 /* > if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P);
177 */
178 /* > if HOWMNY = 'B' or 'b', the matrix Z*X;
179 */
180 /* > if HOWMNY = 'S' or 's', the right eigenvectors of (S,P) */
181 /* > specified by SELECT, stored consecutively in the */
182 /* > columns of VR, in the same order as their */
183 /* > eigenvalues. */
184 /* > */
185 /* > A complex eigenvector corresponding to a complex eigenvalue */
186 /* > is stored in two consecutive columns, the first holding the */
187 /* > real part and the second the imaginary part. */
188 /* > */
189 /* > Not referenced if SIDE = 'L'. */
190 /* > \endverbatim */
191 /* > */
192 /* > \param[in] LDVR */
193 /* > \verbatim */
194 /* > LDVR is INTEGER */
195 /* > The leading dimension of the array VR. LDVR >= 1, and if */
196 /* > SIDE = 'R' or 'B', LDVR >= N. */
197 /* > \endverbatim */
198 /* > */
199 /* > \param[in] MM */
200 /* > \verbatim */
201 /* > MM is INTEGER */
202 /* > The number of columns in the arrays VL and/or VR. MM >= M. */
203 /* > \endverbatim */
204 /* > */
205 /* > \param[out] M */
206 /* > \verbatim */
207 /* > M is INTEGER */
208 /* > The number of columns in the arrays VL and/or VR actually */
209 /* > used to store the eigenvectors. If HOWMNY = 'A' or 'B', M */
210 /* > is set to N. Each selected real eigenvector occupies one */
211 /* > column and each selected complex eigenvector occupies two */
212 /* > columns. */
213 /* > \endverbatim */
214 /* > */
215 /* > \param[out] WORK */
216 /* > \verbatim */
217 /* > WORK is REAL array, dimension (6*N) */
218 /* > \endverbatim */
219 /* > */
220 /* > \param[out] INFO */
221 /* > \verbatim */
222 /* > INFO is INTEGER */
223 /* > = 0: successful exit. */
224 /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
225 /* > > 0: the 2-by-2 block (INFO:INFO+1) does not have a complex */
226 /* > eigenvalue. */
227 /* > \endverbatim */
228 /* Authors: */
229 /* ======== */
230 /* > \author Univ. of Tennessee */
231 /* > \author Univ. of California Berkeley */
232 /* > \author Univ. of Colorado Denver */
233 /* > \author NAG Ltd. */
234 /* > \date November 2011 */
235 /* > \ingroup realGEcomputational */
236 /* > \par Further Details: */
237 /* ===================== */
238 /* > */
239 /* > \verbatim */
240 /* > */
241 /* > Allocation of workspace: */
242 /* > ---------- -- --------- */
243 /* > */
244 /* > WORK( j ) = 1-norm of j-th column of A, above the diagonal */
245 /* > WORK( N+j ) = 1-norm of j-th column of B, above the diagonal */
246 /* > WORK( 2*N+1:3*N ) = real part of eigenvector */
247 /* > WORK( 3*N+1:4*N ) = imaginary part of eigenvector */
248 /* > WORK( 4*N+1:5*N ) = real part of back-transformed eigenvector */
249 /* > WORK( 5*N+1:6*N ) = imaginary part of back-transformed eigenvector */
250 /* > */
251 /* > Rowwise vs. columnwise solution methods: */
252 /* > ------- -- ---------- -------- ------- */
253 /* > */
254 /* > Finding a generalized eigenvector consists basically of solving the */
255 /* > singular triangular system */
256 /* > */
257 /* > (A - w B) x = 0 (for right) or: (A - w B)**H y = 0 (for left) */
258 /* > */
259 /* > Consider finding the i-th right eigenvector (assume all eigenvalues */
260 /* > are real). The equation to be solved is: */
261 /* > n i */
262 /* > 0 = sum C(j,k) v(k) = sum C(j,k) v(k) for j = i,. . .,1 */
263 /* > k=j k=j */
264 /* > */
265 /* > where C = (A - w B) (The components v(i+1:n) are 0.) */
266 /* > */
267 /* > The "rowwise" method is: */
268 /* > */
269 /* > (1) v(i) := 1 */
270 /* > for j = i-1,. . .,1: */
271 /* > i */
272 /* > (2) compute s = - sum C(j,k) v(k) and */
273 /* > k=j+1 */
274 /* > */
275 /* > (3) v(j) := s / C(j,j) */
276 /* > */
277 /* > Step 2 is sometimes called the "dot product" step, since it is an */
278 /* > inner product between the j-th row and the portion of the eigenvector */
279 /* > that has been computed so far. */
280 /* > */
281 /* > The "columnwise" method consists basically in doing the sums */
282 /* > for all the rows in parallel. As each v(j) is computed, the */
283 /* > contribution of v(j) times the j-th column of C is added to the */
284 /* > partial sums. Since FORTRAN arrays are stored columnwise, this has */
285 /* > the advantage that at each step, the elements of C that are accessed */
286 /* > are adjacent to one another, whereas with the rowwise method, the */
287 /* > elements accessed at a step are spaced LDS (and LDP) words apart. */
288 /* > */
289 /* > When finding left eigenvectors, the matrix in question is the */
290 /* > transpose of the one in storage, so the rowwise method then */
291 /* > actually accesses columns of A and B at each step, and so is the */
292 /* > preferred method. */
293 /* > \endverbatim */
294 /* > */
295 /* ===================================================================== */
296 /* Subroutine */
stgevc_(char * side,char * howmny,logical * select,integer * n,real * s,integer * lds,real * p,integer * ldp,real * vl,integer * ldvl,real * vr,integer * ldvr,integer * mm,integer * m,real * work,integer * info)297 int stgevc_(char *side, char *howmny, logical *select, integer *n, real *s, integer *lds, real *p, integer *ldp, real *vl, integer *ldvl, real *vr, integer *ldvr, integer *mm, integer *m, real *work, integer *info)
298 {
299     /* System generated locals */
300     integer p_dim1, p_offset, s_dim1, s_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, i__2, i__3, i__4, i__5;
301     real r__1, r__2, r__3, r__4, r__5, r__6;
302     /* Local variables */
303     integer i__, j, ja, jc, je, na, im, jr, jw, nw;
304     real big;
305     logical lsa, lsb;
306     real ulp, sum[4] /* was [2][2] */
307     ;
308     integer ibeg, ieig, iend;
309     real dmin__, temp, xmax, sump[4] /* was [2][2] */
310     , sums[4] /* was [2][2] */
311     , cim2a, cim2b, cre2a, cre2b;
312     extern /* Subroutine */
313     int slag2_(real *, integer *, real *, integer *, real *, real *, real *, real *, real *, real *);
314     real temp2, bdiag[2], acoef, scale;
315     logical ilall;
316     integer iside;
317     real sbeta;
318     extern logical lsame_(char *, char *);
319     logical il2by2;
320     integer iinfo;
321     real small;
322     logical compl;
323     real anorm, bnorm;
324     logical compr;
325     extern /* Subroutine */
326     int sgemv_(char *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *), slaln2_(logical *, integer *, integer *, real *, real *, real *, integer *, real *, real *, real *, integer *, real *, real *, real *, integer *, real *, real *, integer *);
327     real temp2i, temp2r;
328     logical ilabad, ilbbad;
329     real acoefa, bcoefa, cimaga, cimagb;
330     logical ilback;
331     extern /* Subroutine */
332     int slabad_(real *, real *);
333     real bcoefi, ascale, bscale, creala, crealb, bcoefr;
334     extern real slamch_(char *);
335     real salfar, safmin;
336     extern /* Subroutine */
337     int xerbla_(char *, integer *);
338     real xscale, bignum;
339     logical ilcomp, ilcplx;
340     extern /* Subroutine */
341     int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *);
342     integer ihwmny;
343     /* -- LAPACK computational routine (version 3.4.0) -- */
344     /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
345     /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
346     /* November 2011 */
347     /* .. Scalar Arguments .. */
348     /* .. */
349     /* .. Array Arguments .. */
350     /* .. */
351     /* ===================================================================== */
352     /* .. Parameters .. */
353     /* .. */
354     /* .. Local Scalars .. */
355     /* .. */
356     /* .. Local Arrays .. */
357     /* .. */
358     /* .. External Functions .. */
359     /* .. */
360     /* .. External Subroutines .. */
361     /* .. */
362     /* .. Intrinsic Functions .. */
363     /* .. */
364     /* .. Executable Statements .. */
365     /* Decode and Test the input parameters */
366     /* Parameter adjustments */
367     --select;
368     s_dim1 = *lds;
369     s_offset = 1 + s_dim1;
370     s -= s_offset;
371     p_dim1 = *ldp;
372     p_offset = 1 + p_dim1;
373     p -= p_offset;
374     vl_dim1 = *ldvl;
375     vl_offset = 1 + vl_dim1;
376     vl -= vl_offset;
377     vr_dim1 = *ldvr;
378     vr_offset = 1 + vr_dim1;
379     vr -= vr_offset;
380     --work;
381     /* Function Body */
382     if (lsame_(howmny, "A"))
383     {
384         ihwmny = 1;
385         ilall = TRUE_;
386         ilback = FALSE_;
387     }
388     else if (lsame_(howmny, "S"))
389     {
390         ihwmny = 2;
391         ilall = FALSE_;
392         ilback = FALSE_;
393     }
394     else if (lsame_(howmny, "B"))
395     {
396         ihwmny = 3;
397         ilall = TRUE_;
398         ilback = TRUE_;
399     }
400     else
401     {
402         ihwmny = -1;
403         ilall = TRUE_;
404     }
405     if (lsame_(side, "R"))
406     {
407         iside = 1;
408         compl = FALSE_;
409         compr = TRUE_;
410     }
411     else if (lsame_(side, "L"))
412     {
413         iside = 2;
414         compl = TRUE_;
415         compr = FALSE_;
416     }
417     else if (lsame_(side, "B"))
418     {
419         iside = 3;
420         compl = TRUE_;
421         compr = TRUE_;
422     }
423     else
424     {
425         iside = -1;
426     }
427     *info = 0;
428     if (iside < 0)
429     {
430         *info = -1;
431     }
432     else if (ihwmny < 0)
433     {
434         *info = -2;
435     }
436     else if (*n < 0)
437     {
438         *info = -4;
439     }
440     else if (*lds < max(1,*n))
441     {
442         *info = -6;
443     }
444     else if (*ldp < max(1,*n))
445     {
446         *info = -8;
447     }
448     if (*info != 0)
449     {
450         i__1 = -(*info);
451         xerbla_("STGEVC", &i__1);
452         return 0;
453     }
454     /* Count the number of eigenvectors to be computed */
455     if (! ilall)
456     {
457         im = 0;
458         ilcplx = FALSE_;
459         i__1 = *n;
460         for (j = 1;
461                 j <= i__1;
462                 ++j)
463         {
464             if (ilcplx)
465             {
466                 ilcplx = FALSE_;
467                 goto L10;
468             }
469             if (j < *n)
470             {
471                 if (s[j + 1 + j * s_dim1] != 0.f)
472                 {
473                     ilcplx = TRUE_;
474                 }
475             }
476             if (ilcplx)
477             {
478                 if (select[j] || select[j + 1])
479                 {
480                     im += 2;
481                 }
482             }
483             else
484             {
485                 if (select[j])
486                 {
487                     ++im;
488                 }
489             }
490 L10:
491             ;
492         }
493     }
494     else
495     {
496         im = *n;
497     }
498     /* Check 2-by-2 diagonal blocks of A, B */
499     ilabad = FALSE_;
500     ilbbad = FALSE_;
501     i__1 = *n - 1;
502     for (j = 1;
503             j <= i__1;
504             ++j)
505     {
506         if (s[j + 1 + j * s_dim1] != 0.f)
507         {
508             if (p[j + j * p_dim1] == 0.f || p[j + 1 + (j + 1) * p_dim1] == 0.f || p[j + (j + 1) * p_dim1] != 0.f)
509             {
510                 ilbbad = TRUE_;
511             }
512             if (j < *n - 1)
513             {
514                 if (s[j + 2 + (j + 1) * s_dim1] != 0.f)
515                 {
516                     ilabad = TRUE_;
517                 }
518             }
519         }
520         /* L20: */
521     }
522     if (ilabad)
523     {
524         *info = -5;
525     }
526     else if (ilbbad)
527     {
528         *info = -7;
529     }
530     else if (compl && *ldvl < *n || *ldvl < 1)
531     {
532         *info = -10;
533     }
534     else if (compr && *ldvr < *n || *ldvr < 1)
535     {
536         *info = -12;
537     }
538     else if (*mm < im)
539     {
540         *info = -13;
541     }
542     if (*info != 0)
543     {
544         i__1 = -(*info);
545         xerbla_("STGEVC", &i__1);
546         return 0;
547     }
548     /* Quick return if possible */
549     *m = im;
550     if (*n == 0)
551     {
552         return 0;
553     }
554     /* Machine Constants */
555     safmin = slamch_("Safe minimum");
556     big = 1.f / safmin;
557     slabad_(&safmin, &big);
558     ulp = slamch_("Epsilon") * slamch_("Base");
559     small = safmin * *n / ulp;
560     big = 1.f / small;
561     bignum = 1.f / (safmin * *n);
562     /* Compute the 1-norm of each column of the strictly upper triangular */
563     /* part (i.e., excluding all elements belonging to the diagonal */
564     /* blocks) of A and B to check for possible overflow in the */
565     /* triangular solver. */
566     anorm = (r__1 = s[s_dim1 + 1], f2c_abs(r__1));
567     if (*n > 1)
568     {
569         anorm += (r__1 = s[s_dim1 + 2], f2c_abs(r__1));
570     }
571     bnorm = (r__1 = p[p_dim1 + 1], f2c_abs(r__1));
572     work[1] = 0.f;
573     work[*n + 1] = 0.f;
574     i__1 = *n;
575     for (j = 2;
576             j <= i__1;
577             ++j)
578     {
579         temp = 0.f;
580         temp2 = 0.f;
581         if (s[j + (j - 1) * s_dim1] == 0.f)
582         {
583             iend = j - 1;
584         }
585         else
586         {
587             iend = j - 2;
588         }
589         i__2 = iend;
590         for (i__ = 1;
591                 i__ <= i__2;
592                 ++i__)
593         {
594             temp += (r__1 = s[i__ + j * s_dim1], f2c_abs(r__1));
595             temp2 += (r__1 = p[i__ + j * p_dim1], f2c_abs(r__1));
596             /* L30: */
597         }
598         work[j] = temp;
599         work[*n + j] = temp2;
600         /* Computing MIN */
601         i__3 = j + 1;
602         i__2 = min(i__3,*n);
603         for (i__ = iend + 1;
604                 i__ <= i__2;
605                 ++i__)
606         {
607             temp += (r__1 = s[i__ + j * s_dim1], f2c_abs(r__1));
608             temp2 += (r__1 = p[i__ + j * p_dim1], f2c_abs(r__1));
609             /* L40: */
610         }
611         anorm = max(anorm,temp);
612         bnorm = max(bnorm,temp2);
613         /* L50: */
614     }
615     ascale = 1.f / max(anorm,safmin);
616     bscale = 1.f / max(bnorm,safmin);
617     /* Left eigenvectors */
618     if (compl)
619     {
620         ieig = 0;
621         /* Main loop over eigenvalues */
622         ilcplx = FALSE_;
623         i__1 = *n;
624         for (je = 1;
625                 je <= i__1;
626                 ++je)
627         {
628             /* Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
629             /* (b) this would be the second of a complex pair. */
630             /* Check for complex eigenvalue, so as to be sure of which */
631             /* entry(-ies) of SELECT to look at. */
632             if (ilcplx)
633             {
634                 ilcplx = FALSE_;
635                 goto L220;
636             }
637             nw = 1;
638             if (je < *n)
639             {
640                 if (s[je + 1 + je * s_dim1] != 0.f)
641                 {
642                     ilcplx = TRUE_;
643                     nw = 2;
644                 }
645             }
646             if (ilall)
647             {
648                 ilcomp = TRUE_;
649             }
650             else if (ilcplx)
651             {
652                 ilcomp = select[je] || select[je + 1];
653             }
654             else
655             {
656                 ilcomp = select[je];
657             }
658             if (! ilcomp)
659             {
660                 goto L220;
661             }
662             /* Decide if (a) singular pencil, (b) real eigenvalue, or */
663             /* (c) complex eigenvalue. */
664             if (! ilcplx)
665             {
666                 if ((r__1 = s[je + je * s_dim1], f2c_abs(r__1)) <= safmin && ( r__2 = p[je + je * p_dim1], f2c_abs(r__2)) <= safmin)
667                 {
668                     /* Singular matrix pencil -- return unit eigenvector */
669                     ++ieig;
670                     i__2 = *n;
671                     for (jr = 1;
672                             jr <= i__2;
673                             ++jr)
674                     {
675                         vl[jr + ieig * vl_dim1] = 0.f;
676                         /* L60: */
677                     }
678                     vl[ieig + ieig * vl_dim1] = 1.f;
679                     goto L220;
680                 }
681             }
682             /* Clear vector */
683             i__2 = nw * *n;
684             for (jr = 1;
685                     jr <= i__2;
686                     ++jr)
687             {
688                 work[(*n << 1) + jr] = 0.f;
689                 /* L70: */
690             }
691             /* T */
692             /* Compute coefficients in ( a A - b B ) y = 0 */
693             /* a is ACOEF */
694             /* b is BCOEFR + i*BCOEFI */
695             if (! ilcplx)
696             {
697                 /* Real eigenvalue */
698                 /* Computing MAX */
699                 r__3 = (r__1 = s[je + je * s_dim1], f2c_abs(r__1)) * ascale;
700                 r__4 = (r__2 = p[je + je * p_dim1], f2c_abs(r__2)) * bscale;
701                 r__3 = max(r__3,r__4); // ; expr subst
702                 temp = 1.f / max(r__3,safmin);
703                 salfar = temp * s[je + je * s_dim1] * ascale;
704                 sbeta = temp * p[je + je * p_dim1] * bscale;
705                 acoef = sbeta * ascale;
706                 bcoefr = salfar * bscale;
707                 bcoefi = 0.f;
708                 /* Scale to avoid underflow */
709                 scale = 1.f;
710                 lsa = f2c_abs(sbeta) >= safmin && f2c_abs(acoef) < small;
711                 lsb = f2c_abs(salfar) >= safmin && f2c_abs(bcoefr) < small;
712                 if (lsa)
713                 {
714                     scale = small / f2c_abs(sbeta) * min(anorm,big);
715                 }
716                 if (lsb)
717                 {
718                     /* Computing MAX */
719                     r__1 = scale;
720                     r__2 = small / f2c_abs(salfar) * min(bnorm,big); // , expr subst
721                     scale = max(r__1,r__2);
722                 }
723                 if (lsa || lsb)
724                 {
725                     /* Computing MIN */
726                     /* Computing MAX */
727                     r__3 = 1.f, r__4 = f2c_abs(acoef);
728                     r__3 = max(r__3,r__4);
729                     r__4 = f2c_abs(bcoefr); // ; expr subst
730                     r__1 = scale;
731                     r__2 = 1.f / (safmin * max(r__3,r__4)); // , expr subst
732                     scale = min(r__1,r__2);
733                     if (lsa)
734                     {
735                         acoef = ascale * (scale * sbeta);
736                     }
737                     else
738                     {
739                         acoef = scale * acoef;
740                     }
741                     if (lsb)
742                     {
743                         bcoefr = bscale * (scale * salfar);
744                     }
745                     else
746                     {
747                         bcoefr = scale * bcoefr;
748                     }
749                 }
750                 acoefa = f2c_abs(acoef);
751                 bcoefa = f2c_abs(bcoefr);
752                 /* First component is 1 */
753                 work[(*n << 1) + je] = 1.f;
754                 xmax = 1.f;
755             }
756             else
757             {
758                 /* Complex eigenvalue */
759                 r__1 = safmin * 100.f;
760                 slag2_(&s[je + je * s_dim1], lds, &p[je + je * p_dim1], ldp, & r__1, &acoef, &temp, &bcoefr, &temp2, &bcoefi);
761                 bcoefi = -bcoefi;
762                 if (bcoefi == 0.f)
763                 {
764                     *info = je;
765                     return 0;
766                 }
767                 /* Scale to avoid over/underflow */
768                 acoefa = f2c_abs(acoef);
769                 bcoefa = f2c_abs(bcoefr) + f2c_abs(bcoefi);
770                 scale = 1.f;
771                 if (acoefa * ulp < safmin && acoefa >= safmin)
772                 {
773                     scale = safmin / ulp / acoefa;
774                 }
775                 if (bcoefa * ulp < safmin && bcoefa >= safmin)
776                 {
777                     /* Computing MAX */
778                     r__1 = scale;
779                     r__2 = safmin / ulp / bcoefa; // , expr subst
780                     scale = max(r__1,r__2);
781                 }
782                 if (safmin * acoefa > ascale)
783                 {
784                     scale = ascale / (safmin * acoefa);
785                 }
786                 if (safmin * bcoefa > bscale)
787                 {
788                     /* Computing MIN */
789                     r__1 = scale;
790                     r__2 = bscale / (safmin * bcoefa); // , expr subst
791                     scale = min(r__1,r__2);
792                 }
793                 if (scale != 1.f)
794                 {
795                     acoef = scale * acoef;
796                     acoefa = f2c_abs(acoef);
797                     bcoefr = scale * bcoefr;
798                     bcoefi = scale * bcoefi;
799                     bcoefa = f2c_abs(bcoefr) + f2c_abs(bcoefi);
800                 }
801                 /* Compute first two components of eigenvector */
802                 temp = acoef * s[je + 1 + je * s_dim1];
803                 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je * p_dim1];
804                 temp2i = -bcoefi * p[je + je * p_dim1];
805                 if (f2c_abs(temp) > f2c_abs(temp2r) + f2c_abs(temp2i))
806                 {
807                     work[(*n << 1) + je] = 1.f;
808                     work[*n * 3 + je] = 0.f;
809                     work[(*n << 1) + je + 1] = -temp2r / temp;
810                     work[*n * 3 + je + 1] = -temp2i / temp;
811                 }
812                 else
813                 {
814                     work[(*n << 1) + je + 1] = 1.f;
815                     work[*n * 3 + je + 1] = 0.f;
816                     temp = acoef * s[je + (je + 1) * s_dim1];
817                     work[(*n << 1) + je] = (bcoefr * p[je + 1 + (je + 1) * p_dim1] - acoef * s[je + 1 + (je + 1) * s_dim1]) / temp;
818                     work[*n * 3 + je] = bcoefi * p[je + 1 + (je + 1) * p_dim1] / temp;
819                 }
820                 /* Computing MAX */
821                 r__5 = (r__1 = work[(*n << 1) + je], f2c_abs(r__1)) + (r__2 = work[*n * 3 + je], f2c_abs(r__2));
822                 r__6 = (r__3 = work[(* n << 1) + je + 1], f2c_abs(r__3)) + (r__4 = work[*n * 3 + je + 1], f2c_abs(r__4)); // , expr subst
823                 xmax = max(r__5,r__6);
824             }
825             /* Computing MAX */
826             r__1 = ulp * acoefa * anorm;
827             r__2 = ulp * bcoefa * bnorm;
828             r__1 = max(r__1,r__2); // ; expr subst
829             dmin__ = max(r__1,safmin);
830             /* T */
831             /* Triangular solve of (a A - b B) y = 0 */
832             /* T */
833             /* (rowwise in (a A - b B) , or columnwise in (a A - b B) ) */
834             il2by2 = FALSE_;
835             i__2 = *n;
836             for (j = je + nw;
837                     j <= i__2;
838                     ++j)
839             {
840                 if (il2by2)
841                 {
842                     il2by2 = FALSE_;
843                     goto L160;
844                 }
845                 na = 1;
846                 bdiag[0] = p[j + j * p_dim1];
847                 if (j < *n)
848                 {
849                     if (s[j + 1 + j * s_dim1] != 0.f)
850                     {
851                         il2by2 = TRUE_;
852                         bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
853                         na = 2;
854                     }
855                 }
856                 /* Check whether scaling is necessary for dot products */
857                 xscale = 1.f / max(1.f,xmax);
858                 /* Computing MAX */
859                 r__1 = work[j], r__2 = work[*n + j];
860                 r__1 = max(r__1,r__2);
861                 r__2 = acoefa * work[j] + bcoefa * work[*n + j]; // ; expr subst
862                 temp = max(r__1,r__2);
863                 if (il2by2)
864                 {
865                     /* Computing MAX */
866                     r__1 = temp, r__2 = work[j + 1], r__1 = max(r__1,r__2), r__2 = work[*n + j + 1];
867                     r__1 = max(r__1,r__2);
868                     r__2 = acoefa * work[j + 1] + bcoefa * work[*n + j + 1]; // ; expr subst
869                     temp = max(r__1,r__2);
870                 }
871                 if (temp > bignum * xscale)
872                 {
873                     i__3 = nw - 1;
874                     for (jw = 0;
875                             jw <= i__3;
876                             ++jw)
877                     {
878                         i__4 = j - 1;
879                         for (jr = je;
880                                 jr <= i__4;
881                                 ++jr)
882                         {
883                             work[(jw + 2) * *n + jr] = xscale * work[(jw + 2) * *n + jr];
884                             /* L80: */
885                         }
886                         /* L90: */
887                     }
888                     xmax *= xscale;
889                 }
890                 /* Compute dot products */
891                 /* j-1 */
892                 /* SUM = sum conjg( a*S(k,j) - b*P(k,j) )*x(k) */
893                 /* k=je */
894                 /* To reduce the op count, this is done as */
895                 /* _ j-1 _ j-1 */
896                 /* a*conjg( sum S(k,j)*x(k) ) - b*conjg( sum P(k,j)*x(k) ) */
897                 /* k=je k=je */
898                 /* which may cause underflow problems if A or B are close */
899                 /* to underflow. (E.g., less than SMALL.) */
900                 i__3 = nw;
901                 for (jw = 1;
902                         jw <= i__3;
903                         ++jw)
904                 {
905                     i__4 = na;
906                     for (ja = 1;
907                             ja <= i__4;
908                             ++ja)
909                     {
910                         sums[ja + (jw << 1) - 3] = 0.f;
911                         sump[ja + (jw << 1) - 3] = 0.f;
912                         i__5 = j - 1;
913                         for (jr = je;
914                                 jr <= i__5;
915                                 ++jr)
916                         {
917                             sums[ja + (jw << 1) - 3] += s[jr + (j + ja - 1) * s_dim1] * work[(jw + 1) * *n + jr];
918                             sump[ja + (jw << 1) - 3] += p[jr + (j + ja - 1) * p_dim1] * work[(jw + 1) * *n + jr];
919                             /* L100: */
920                         }
921                         /* L110: */
922                     }
923                     /* L120: */
924                 }
925                 i__3 = na;
926                 for (ja = 1;
927                         ja <= i__3;
928                         ++ja)
929                 {
930                     if (ilcplx)
931                     {
932                         sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[ ja - 1] - bcoefi * sump[ja + 1];
933                         sum[ja + 1] = -acoef * sums[ja + 1] + bcoefr * sump[ ja + 1] + bcoefi * sump[ja - 1];
934                     }
935                     else
936                     {
937                         sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[ ja - 1];
938                     }
939                     /* L130: */
940                 }
941                 /* T */
942                 /* Solve ( a A - b B ) y = SUM(,) */
943                 /* with scaling and perturbation of the denominator */
944                 slaln2_(&c_true, &na, &nw, &dmin__, &acoef, &s[j + j * s_dim1] , lds, bdiag, &bdiag[1], sum, &c__2, &bcoefr, &bcoefi, &work[(*n << 1) + j], n, &scale, &temp, &iinfo);
945                 if (scale < 1.f)
946                 {
947                     i__3 = nw - 1;
948                     for (jw = 0;
949                             jw <= i__3;
950                             ++jw)
951                     {
952                         i__4 = j - 1;
953                         for (jr = je;
954                                 jr <= i__4;
955                                 ++jr)
956                         {
957                             work[(jw + 2) * *n + jr] = scale * work[(jw + 2) * *n + jr];
958                             /* L140: */
959                         }
960                         /* L150: */
961                     }
962                     xmax = scale * xmax;
963                 }
964                 xmax = max(xmax,temp);
965 L160:
966                 ;
967             }
968             /* Copy eigenvector to VL, back transforming if */
969             /* HOWMNY='B'. */
970             ++ieig;
971             if (ilback)
972             {
973                 i__2 = nw - 1;
974                 for (jw = 0;
975                         jw <= i__2;
976                         ++jw)
977                 {
978                     i__3 = *n + 1 - je;
979                     sgemv_("N", n, &i__3, &c_b34, &vl[je * vl_dim1 + 1], ldvl, &work[(jw + 2) * *n + je], &c__1, &c_b36, &work[( jw + 4) * *n + 1], &c__1);
980                     /* L170: */
981                 }
982                 slacpy_(" ", n, &nw, &work[(*n << 2) + 1], n, &vl[je * vl_dim1 + 1], ldvl);
983                 ibeg = 1;
984             }
985             else
986             {
987                 slacpy_(" ", n, &nw, &work[(*n << 1) + 1], n, &vl[ieig * vl_dim1 + 1], ldvl);
988                 ibeg = je;
989             }
990             /* Scale eigenvector */
991             xmax = 0.f;
992             if (ilcplx)
993             {
994                 i__2 = *n;
995                 for (j = ibeg;
996                         j <= i__2;
997                         ++j)
998                 {
999                     /* Computing MAX */
1000                     r__3 = xmax;
1001                     r__4 = (r__1 = vl[j + ieig * vl_dim1], f2c_abs( r__1)) + (r__2 = vl[j + (ieig + 1) * vl_dim1], f2c_abs(r__2)); // , expr subst
1002                     xmax = max(r__3,r__4);
1003                     /* L180: */
1004                 }
1005             }
1006             else
1007             {
1008                 i__2 = *n;
1009                 for (j = ibeg;
1010                         j <= i__2;
1011                         ++j)
1012                 {
1013                     /* Computing MAX */
1014                     r__2 = xmax;
1015                     r__3 = (r__1 = vl[j + ieig * vl_dim1], f2c_abs( r__1)); // , expr subst
1016                     xmax = max(r__2,r__3);
1017                     /* L190: */
1018                 }
1019             }
1020             if (xmax > safmin)
1021             {
1022                 xscale = 1.f / xmax;
1023                 i__2 = nw - 1;
1024                 for (jw = 0;
1025                         jw <= i__2;
1026                         ++jw)
1027                 {
1028                     i__3 = *n;
1029                     for (jr = ibeg;
1030                             jr <= i__3;
1031                             ++jr)
1032                     {
1033                         vl[jr + (ieig + jw) * vl_dim1] = xscale * vl[jr + ( ieig + jw) * vl_dim1];
1034                         /* L200: */
1035                     }
1036                     /* L210: */
1037                 }
1038             }
1039             ieig = ieig + nw - 1;
1040 L220:
1041             ;
1042         }
1043     }
1044     /* Right eigenvectors */
1045     if (compr)
1046     {
1047         ieig = im + 1;
1048         /* Main loop over eigenvalues */
1049         ilcplx = FALSE_;
1050         for (je = *n;
1051                 je >= 1;
1052                 --je)
1053         {
1054             /* Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
1055             /* (b) this would be the second of a complex pair. */
1056             /* Check for complex eigenvalue, so as to be sure of which */
1057             /* entry(-ies) of SELECT to look at -- if complex, SELECT(JE) */
1058             /* or SELECT(JE-1). */
1059             /* If this is a complex pair, the 2-by-2 diagonal block */
1060             /* corresponding to the eigenvalue is in rows/columns JE-1:JE */
1061             if (ilcplx)
1062             {
1063                 ilcplx = FALSE_;
1064                 goto L500;
1065             }
1066             nw = 1;
1067             if (je > 1)
1068             {
1069                 if (s[je + (je - 1) * s_dim1] != 0.f)
1070                 {
1071                     ilcplx = TRUE_;
1072                     nw = 2;
1073                 }
1074             }
1075             if (ilall)
1076             {
1077                 ilcomp = TRUE_;
1078             }
1079             else if (ilcplx)
1080             {
1081                 ilcomp = select[je] || select[je - 1];
1082             }
1083             else
1084             {
1085                 ilcomp = select[je];
1086             }
1087             if (! ilcomp)
1088             {
1089                 goto L500;
1090             }
1091             /* Decide if (a) singular pencil, (b) real eigenvalue, or */
1092             /* (c) complex eigenvalue. */
1093             if (! ilcplx)
1094             {
1095                 if ((r__1 = s[je + je * s_dim1], f2c_abs(r__1)) <= safmin && ( r__2 = p[je + je * p_dim1], f2c_abs(r__2)) <= safmin)
1096                 {
1097                     /* Singular matrix pencil -- unit eigenvector */
1098                     --ieig;
1099                     i__1 = *n;
1100                     for (jr = 1;
1101                             jr <= i__1;
1102                             ++jr)
1103                     {
1104                         vr[jr + ieig * vr_dim1] = 0.f;
1105                         /* L230: */
1106                     }
1107                     vr[ieig + ieig * vr_dim1] = 1.f;
1108                     goto L500;
1109                 }
1110             }
1111             /* Clear vector */
1112             i__1 = nw - 1;
1113             for (jw = 0;
1114                     jw <= i__1;
1115                     ++jw)
1116             {
1117                 i__2 = *n;
1118                 for (jr = 1;
1119                         jr <= i__2;
1120                         ++jr)
1121                 {
1122                     work[(jw + 2) * *n + jr] = 0.f;
1123                     /* L240: */
1124                 }
1125                 /* L250: */
1126             }
1127             /* Compute coefficients in ( a A - b B ) x = 0 */
1128             /* a is ACOEF */
1129             /* b is BCOEFR + i*BCOEFI */
1130             if (! ilcplx)
1131             {
1132                 /* Real eigenvalue */
1133                 /* Computing MAX */
1134                 r__3 = (r__1 = s[je + je * s_dim1], f2c_abs(r__1)) * ascale;
1135                 r__4 = (r__2 = p[je + je * p_dim1], f2c_abs(r__2)) * bscale;
1136                 r__3 = max(r__3,r__4); // ; expr subst
1137                 temp = 1.f / max(r__3,safmin);
1138                 salfar = temp * s[je + je * s_dim1] * ascale;
1139                 sbeta = temp * p[je + je * p_dim1] * bscale;
1140                 acoef = sbeta * ascale;
1141                 bcoefr = salfar * bscale;
1142                 bcoefi = 0.f;
1143                 /* Scale to avoid underflow */
1144                 scale = 1.f;
1145                 lsa = f2c_abs(sbeta) >= safmin && f2c_abs(acoef) < small;
1146                 lsb = f2c_abs(salfar) >= safmin && f2c_abs(bcoefr) < small;
1147                 if (lsa)
1148                 {
1149                     scale = small / f2c_abs(sbeta) * min(anorm,big);
1150                 }
1151                 if (lsb)
1152                 {
1153                     /* Computing MAX */
1154                     r__1 = scale;
1155                     r__2 = small / f2c_abs(salfar) * min(bnorm,big); // , expr subst
1156                     scale = max(r__1,r__2);
1157                 }
1158                 if (lsa || lsb)
1159                 {
1160                     /* Computing MIN */
1161                     /* Computing MAX */
1162                     r__3 = 1.f, r__4 = f2c_abs(acoef);
1163                     r__3 = max(r__3,r__4);
1164                     r__4 = f2c_abs(bcoefr); // ; expr subst
1165                     r__1 = scale;
1166                     r__2 = 1.f / (safmin * max(r__3,r__4)); // , expr subst
1167                     scale = min(r__1,r__2);
1168                     if (lsa)
1169                     {
1170                         acoef = ascale * (scale * sbeta);
1171                     }
1172                     else
1173                     {
1174                         acoef = scale * acoef;
1175                     }
1176                     if (lsb)
1177                     {
1178                         bcoefr = bscale * (scale * salfar);
1179                     }
1180                     else
1181                     {
1182                         bcoefr = scale * bcoefr;
1183                     }
1184                 }
1185                 acoefa = f2c_abs(acoef);
1186                 bcoefa = f2c_abs(bcoefr);
1187                 /* First component is 1 */
1188                 work[(*n << 1) + je] = 1.f;
1189                 xmax = 1.f;
1190                 /* Compute contribution from column JE of A and B to sum */
1191                 /* (See "Further Details", above.) */
1192                 i__1 = je - 1;
1193                 for (jr = 1;
1194                         jr <= i__1;
1195                         ++jr)
1196                 {
1197                     work[(*n << 1) + jr] = bcoefr * p[jr + je * p_dim1] - acoef * s[jr + je * s_dim1];
1198                     /* L260: */
1199                 }
1200             }
1201             else
1202             {
1203                 /* Complex eigenvalue */
1204                 r__1 = safmin * 100.f;
1205                 slag2_(&s[je - 1 + (je - 1) * s_dim1], lds, &p[je - 1 + (je - 1) * p_dim1], ldp, &r__1, &acoef, &temp, &bcoefr, & temp2, &bcoefi);
1206                 if (bcoefi == 0.f)
1207                 {
1208                     *info = je - 1;
1209                     return 0;
1210                 }
1211                 /* Scale to avoid over/underflow */
1212                 acoefa = f2c_abs(acoef);
1213                 bcoefa = f2c_abs(bcoefr) + f2c_abs(bcoefi);
1214                 scale = 1.f;
1215                 if (acoefa * ulp < safmin && acoefa >= safmin)
1216                 {
1217                     scale = safmin / ulp / acoefa;
1218                 }
1219                 if (bcoefa * ulp < safmin && bcoefa >= safmin)
1220                 {
1221                     /* Computing MAX */
1222                     r__1 = scale;
1223                     r__2 = safmin / ulp / bcoefa; // , expr subst
1224                     scale = max(r__1,r__2);
1225                 }
1226                 if (safmin * acoefa > ascale)
1227                 {
1228                     scale = ascale / (safmin * acoefa);
1229                 }
1230                 if (safmin * bcoefa > bscale)
1231                 {
1232                     /* Computing MIN */
1233                     r__1 = scale;
1234                     r__2 = bscale / (safmin * bcoefa); // , expr subst
1235                     scale = min(r__1,r__2);
1236                 }
1237                 if (scale != 1.f)
1238                 {
1239                     acoef = scale * acoef;
1240                     acoefa = f2c_abs(acoef);
1241                     bcoefr = scale * bcoefr;
1242                     bcoefi = scale * bcoefi;
1243                     bcoefa = f2c_abs(bcoefr) + f2c_abs(bcoefi);
1244                 }
1245                 /* Compute first two components of eigenvector */
1246                 /* and contribution to sums */
1247                 temp = acoef * s[je + (je - 1) * s_dim1];
1248                 temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je * p_dim1];
1249                 temp2i = -bcoefi * p[je + je * p_dim1];
1250                 if (f2c_abs(temp) >= f2c_abs(temp2r) + f2c_abs(temp2i))
1251                 {
1252                     work[(*n << 1) + je] = 1.f;
1253                     work[*n * 3 + je] = 0.f;
1254                     work[(*n << 1) + je - 1] = -temp2r / temp;
1255                     work[*n * 3 + je - 1] = -temp2i / temp;
1256                 }
1257                 else
1258                 {
1259                     work[(*n << 1) + je - 1] = 1.f;
1260                     work[*n * 3 + je - 1] = 0.f;
1261                     temp = acoef * s[je - 1 + je * s_dim1];
1262                     work[(*n << 1) + je] = (bcoefr * p[je - 1 + (je - 1) * p_dim1] - acoef * s[je - 1 + (je - 1) * s_dim1]) / temp;
1263                     work[*n * 3 + je] = bcoefi * p[je - 1 + (je - 1) * p_dim1] / temp;
1264                 }
1265                 /* Computing MAX */
1266                 r__5 = (r__1 = work[(*n << 1) + je], f2c_abs(r__1)) + (r__2 = work[*n * 3 + je], f2c_abs(r__2));
1267                 r__6 = (r__3 = work[(* n << 1) + je - 1], f2c_abs(r__3)) + (r__4 = work[*n * 3 + je - 1], f2c_abs(r__4)); // , expr subst
1268                 xmax = max(r__5,r__6);
1269                 /* Compute contribution from columns JE and JE-1 */
1270                 /* of A and B to the sums. */
1271                 creala = acoef * work[(*n << 1) + je - 1];
1272                 cimaga = acoef * work[*n * 3 + je - 1];
1273                 crealb = bcoefr * work[(*n << 1) + je - 1] - bcoefi * work[*n * 3 + je - 1];
1274                 cimagb = bcoefi * work[(*n << 1) + je - 1] + bcoefr * work[*n * 3 + je - 1];
1275                 cre2a = acoef * work[(*n << 1) + je];
1276                 cim2a = acoef * work[*n * 3 + je];
1277                 cre2b = bcoefr * work[(*n << 1) + je] - bcoefi * work[*n * 3 + je];
1278                 cim2b = bcoefi * work[(*n << 1) + je] + bcoefr * work[*n * 3 + je];
1279                 i__1 = je - 2;
1280                 for (jr = 1;
1281                         jr <= i__1;
1282                         ++jr)
1283                 {
1284                     work[(*n << 1) + jr] = -creala * s[jr + (je - 1) * s_dim1] + crealb * p[jr + (je - 1) * p_dim1] - cre2a * s[ jr + je * s_dim1] + cre2b * p[jr + je * p_dim1];
1285                     work[*n * 3 + jr] = -cimaga * s[jr + (je - 1) * s_dim1] + cimagb * p[jr + (je - 1) * p_dim1] - cim2a * s[jr + je * s_dim1] + cim2b * p[jr + je * p_dim1];
1286                     /* L270: */
1287                 }
1288             }
1289             /* Computing MAX */
1290             r__1 = ulp * acoefa * anorm;
1291             r__2 = ulp * bcoefa * bnorm;
1292             r__1 = max(r__1,r__2); // ; expr subst
1293             dmin__ = max(r__1,safmin);
1294             /* Columnwise triangular solve of (a A - b B) x = 0 */
1295             il2by2 = FALSE_;
1296             for (j = je - nw;
1297                     j >= 1;
1298                     --j)
1299             {
1300                 /* If a 2-by-2 block, is in position j-1:j, wait until */
1301                 /* next iteration to process it (when it will be j:j+1) */
1302                 if (! il2by2 && j > 1)
1303                 {
1304                     if (s[j + (j - 1) * s_dim1] != 0.f)
1305                     {
1306                         il2by2 = TRUE_;
1307                         goto L370;
1308                     }
1309                 }
1310                 bdiag[0] = p[j + j * p_dim1];
1311                 if (il2by2)
1312                 {
1313                     na = 2;
1314                     bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
1315                 }
1316                 else
1317                 {
1318                     na = 1;
1319                 }
1320                 /* Compute x(j) (and x(j+1), if 2-by-2 block) */
1321                 slaln2_(&c_false, &na, &nw, &dmin__, &acoef, &s[j + j * s_dim1], lds, bdiag, &bdiag[1], &work[(*n << 1) + j], n, &bcoefr, &bcoefi, sum, &c__2, &scale, &temp, & iinfo);
1322                 if (scale < 1.f)
1323                 {
1324                     i__1 = nw - 1;
1325                     for (jw = 0;
1326                             jw <= i__1;
1327                             ++jw)
1328                     {
1329                         i__2 = je;
1330                         for (jr = 1;
1331                                 jr <= i__2;
1332                                 ++jr)
1333                         {
1334                             work[(jw + 2) * *n + jr] = scale * work[(jw + 2) * *n + jr];
1335                             /* L280: */
1336                         }
1337                         /* L290: */
1338                     }
1339                 }
1340                 /* Computing MAX */
1341                 r__1 = scale * xmax;
1342                 xmax = max(r__1,temp);
1343                 i__1 = nw;
1344                 for (jw = 1;
1345                         jw <= i__1;
1346                         ++jw)
1347                 {
1348                     i__2 = na;
1349                     for (ja = 1;
1350                             ja <= i__2;
1351                             ++ja)
1352                     {
1353                         work[(jw + 1) * *n + j + ja - 1] = sum[ja + (jw << 1) - 3];
1354                         /* L300: */
1355                     }
1356                     /* L310: */
1357                 }
1358                 /* w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling */
1359                 if (j > 1)
1360                 {
1361                     /* Check whether scaling is necessary for sum. */
1362                     xscale = 1.f / max(1.f,xmax);
1363                     temp = acoefa * work[j] + bcoefa * work[*n + j];
1364                     if (il2by2)
1365                     {
1366                         /* Computing MAX */
1367                         r__1 = temp;
1368                         r__2 = acoefa * work[j + 1] + bcoefa * work[*n + j + 1]; // , expr subst
1369                         temp = max(r__1,r__2);
1370                     }
1371                     /* Computing MAX */
1372                     r__1 = max(temp,acoefa);
1373                     temp = max(r__1,bcoefa);
1374                     if (temp > bignum * xscale)
1375                     {
1376                         i__1 = nw - 1;
1377                         for (jw = 0;
1378                                 jw <= i__1;
1379                                 ++jw)
1380                         {
1381                             i__2 = je;
1382                             for (jr = 1;
1383                                     jr <= i__2;
1384                                     ++jr)
1385                             {
1386                                 work[(jw + 2) * *n + jr] = xscale * work[(jw + 2) * *n + jr];
1387                                 /* L320: */
1388                             }
1389                             /* L330: */
1390                         }
1391                         xmax *= xscale;
1392                     }
1393                     /* Compute the contributions of the off-diagonals of */
1394                     /* column j (and j+1, if 2-by-2 block) of A and B to the */
1395                     /* sums. */
1396                     i__1 = na;
1397                     for (ja = 1;
1398                             ja <= i__1;
1399                             ++ja)
1400                     {
1401                         if (ilcplx)
1402                         {
1403                             creala = acoef * work[(*n << 1) + j + ja - 1];
1404                             cimaga = acoef * work[*n * 3 + j + ja - 1];
1405                             crealb = bcoefr * work[(*n << 1) + j + ja - 1] - bcoefi * work[*n * 3 + j + ja - 1];
1406                             cimagb = bcoefi * work[(*n << 1) + j + ja - 1] + bcoefr * work[*n * 3 + j + ja - 1];
1407                             i__2 = j - 1;
1408                             for (jr = 1;
1409                                     jr <= i__2;
1410                                     ++jr)
1411                             {
1412                                 work[(*n << 1) + jr] = work[(*n << 1) + jr] - creala * s[jr + (j + ja - 1) * s_dim1] + crealb * p[jr + (j + ja - 1) * p_dim1];
1413                                 work[*n * 3 + jr] = work[*n * 3 + jr] - cimaga * s[jr + (j + ja - 1) * s_dim1] + cimagb * p[jr + (j + ja - 1) * p_dim1];
1414                                 /* L340: */
1415                             }
1416                         }
1417                         else
1418                         {
1419                             creala = acoef * work[(*n << 1) + j + ja - 1];
1420                             crealb = bcoefr * work[(*n << 1) + j + ja - 1];
1421                             i__2 = j - 1;
1422                             for (jr = 1;
1423                                     jr <= i__2;
1424                                     ++jr)
1425                             {
1426                                 work[(*n << 1) + jr] = work[(*n << 1) + jr] - creala * s[jr + (j + ja - 1) * s_dim1] + crealb * p[jr + (j + ja - 1) * p_dim1];
1427                                 /* L350: */
1428                             }
1429                         }
1430                         /* L360: */
1431                     }
1432                 }
1433                 il2by2 = FALSE_;
1434 L370:
1435                 ;
1436             }
1437             /* Copy eigenvector to VR, back transforming if */
1438             /* HOWMNY='B'. */
1439             ieig -= nw;
1440             if (ilback)
1441             {
1442                 i__1 = nw - 1;
1443                 for (jw = 0;
1444                         jw <= i__1;
1445                         ++jw)
1446                 {
1447                     i__2 = *n;
1448                     for (jr = 1;
1449                             jr <= i__2;
1450                             ++jr)
1451                     {
1452                         work[(jw + 4) * *n + jr] = work[(jw + 2) * *n + 1] * vr[jr + vr_dim1];
1453                         /* L380: */
1454                     }
1455                     /* A series of compiler directives to defeat */
1456                     /* vectorization for the next loop */
1457                     i__2 = je;
1458                     for (jc = 2;
1459                             jc <= i__2;
1460                             ++jc)
1461                     {
1462                         i__3 = *n;
1463                         for (jr = 1;
1464                                 jr <= i__3;
1465                                 ++jr)
1466                         {
1467                             work[(jw + 4) * *n + jr] += work[(jw + 2) * *n + jc] * vr[jr + jc * vr_dim1];
1468                             /* L390: */
1469                         }
1470                         /* L400: */
1471                     }
1472                     /* L410: */
1473                 }
1474                 i__1 = nw - 1;
1475                 for (jw = 0;
1476                         jw <= i__1;
1477                         ++jw)
1478                 {
1479                     i__2 = *n;
1480                     for (jr = 1;
1481                             jr <= i__2;
1482                             ++jr)
1483                     {
1484                         vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 4) * *n + jr];
1485                         /* L420: */
1486                     }
1487                     /* L430: */
1488                 }
1489                 iend = *n;
1490             }
1491             else
1492             {
1493                 i__1 = nw - 1;
1494                 for (jw = 0;
1495                         jw <= i__1;
1496                         ++jw)
1497                 {
1498                     i__2 = *n;
1499                     for (jr = 1;
1500                             jr <= i__2;
1501                             ++jr)
1502                     {
1503                         vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 2) * *n + jr];
1504                         /* L440: */
1505                     }
1506                     /* L450: */
1507                 }
1508                 iend = je;
1509             }
1510             /* Scale eigenvector */
1511             xmax = 0.f;
1512             if (ilcplx)
1513             {
1514                 i__1 = iend;
1515                 for (j = 1;
1516                         j <= i__1;
1517                         ++j)
1518                 {
1519                     /* Computing MAX */
1520                     r__3 = xmax;
1521                     r__4 = (r__1 = vr[j + ieig * vr_dim1], f2c_abs( r__1)) + (r__2 = vr[j + (ieig + 1) * vr_dim1], f2c_abs(r__2)); // , expr subst
1522                     xmax = max(r__3,r__4);
1523                     /* L460: */
1524                 }
1525             }
1526             else
1527             {
1528                 i__1 = iend;
1529                 for (j = 1;
1530                         j <= i__1;
1531                         ++j)
1532                 {
1533                     /* Computing MAX */
1534                     r__2 = xmax;
1535                     r__3 = (r__1 = vr[j + ieig * vr_dim1], f2c_abs( r__1)); // , expr subst
1536                     xmax = max(r__2,r__3);
1537                     /* L470: */
1538                 }
1539             }
1540             if (xmax > safmin)
1541             {
1542                 xscale = 1.f / xmax;
1543                 i__1 = nw - 1;
1544                 for (jw = 0;
1545                         jw <= i__1;
1546                         ++jw)
1547                 {
1548                     i__2 = iend;
1549                     for (jr = 1;
1550                             jr <= i__2;
1551                             ++jr)
1552                     {
1553                         vr[jr + (ieig + jw) * vr_dim1] = xscale * vr[jr + ( ieig + jw) * vr_dim1];
1554                         /* L480: */
1555                     }
1556                     /* L490: */
1557                 }
1558             }
1559 L500:
1560             ;
1561         }
1562     }
1563     return 0;
1564     /* End of STGEVC */
1565 }
1566 /* stgevc_ */
1567