C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / strevc.c
1 #include <math.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <complex.h>
6 #ifdef complex
7 #undef complex
8 #endif
9 #ifdef I
10 #undef I
11 #endif
12
13 #if defined(_WIN64)
14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
16 #else
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
19 #endif
20
21 #ifdef LAPACK_ILP64
22 typedef BLASLONG blasint;
23 #if defined(_WIN64)
24 #define blasabs(x) llabs(x)
25 #else
26 #define blasabs(x) labs(x)
27 #endif
28 #else
29 typedef int blasint;
30 #define blasabs(x) abs(x)
31 #endif
32
33 typedef blasint integer;
34
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
38 typedef float real;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
42 #ifdef _MSC_VER
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
47 #else
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
52 #endif
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
55 typedef int logical;
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
59
60 #define TRUE_ (1)
61 #define FALSE_ (0)
62
63 /* Extern is for use with -E */
64 #ifndef Extern
65 #define Extern extern
66 #endif
67
68 /* I/O stuff */
69
70 typedef int flag;
71 typedef int ftnlen;
72 typedef int ftnint;
73
74 /*external read, write*/
75 typedef struct
76 {       flag cierr;
77         ftnint ciunit;
78         flag ciend;
79         char *cifmt;
80         ftnint cirec;
81 } cilist;
82
83 /*internal read, write*/
84 typedef struct
85 {       flag icierr;
86         char *iciunit;
87         flag iciend;
88         char *icifmt;
89         ftnint icirlen;
90         ftnint icirnum;
91 } icilist;
92
93 /*open*/
94 typedef struct
95 {       flag oerr;
96         ftnint ounit;
97         char *ofnm;
98         ftnlen ofnmlen;
99         char *osta;
100         char *oacc;
101         char *ofm;
102         ftnint orl;
103         char *oblnk;
104 } olist;
105
106 /*close*/
107 typedef struct
108 {       flag cerr;
109         ftnint cunit;
110         char *csta;
111 } cllist;
112
113 /*rewind, backspace, endfile*/
114 typedef struct
115 {       flag aerr;
116         ftnint aunit;
117 } alist;
118
119 /* inquire */
120 typedef struct
121 {       flag inerr;
122         ftnint inunit;
123         char *infile;
124         ftnlen infilen;
125         ftnint  *inex;  /*parameters in standard's order*/
126         ftnint  *inopen;
127         ftnint  *innum;
128         ftnint  *innamed;
129         char    *inname;
130         ftnlen  innamlen;
131         char    *inacc;
132         ftnlen  inacclen;
133         char    *inseq;
134         ftnlen  inseqlen;
135         char    *indir;
136         ftnlen  indirlen;
137         char    *infmt;
138         ftnlen  infmtlen;
139         char    *inform;
140         ftnint  informlen;
141         char    *inunf;
142         ftnlen  inunflen;
143         ftnint  *inrecl;
144         ftnint  *innrec;
145         char    *inblank;
146         ftnlen  inblanklen;
147 } inlist;
148
149 #define VOID void
150
151 union Multitype {       /* for multiple entry points */
152         integer1 g;
153         shortint h;
154         integer i;
155         /* longint j; */
156         real r;
157         doublereal d;
158         complex c;
159         doublecomplex z;
160         };
161
162 typedef union Multitype Multitype;
163
164 struct Vardesc {        /* for Namelist */
165         char *name;
166         char *addr;
167         ftnlen *dims;
168         int  type;
169         };
170 typedef struct Vardesc Vardesc;
171
172 struct Namelist {
173         char *name;
174         Vardesc **vars;
175         int nvars;
176         };
177 typedef struct Namelist Namelist;
178
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b)   ((a) >> (b) & 1)
186 #define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b)    ((a) |  ((uinteger)1 << (b)))
188
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
192 #ifdef _MSC_VER
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
195 #else
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
198 #endif
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) {         ftnlen i, nc, ll; char *f__rp, *lp;     ll = (llp); lp = (lpp);         for(i=0; i < (int)*(np); ++i) {                 nc = ll;                if((rnp)[i] < nc) nc = (rnp)[i];                ll -= nc;               f__rp = (rpp)[i];               while(--nc >= 0) *lp++ = *(f__rp)++;         }  while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
260
261 /* procedure parameter types for -A and -C++ */
262
263 #define F2C_proc_par_types 1
264 #ifdef __cplusplus
265 typedef logical (*L_fp)(...);
266 #else
267 typedef logical (*L_fp)();
268 #endif
269
270 static float spow_ui(float x, integer n) {
271         float pow=1.0; unsigned long int u;
272         if(n != 0) {
273                 if(n < 0) n = -n, x = 1/x;
274                 for(u = n; ; ) {
275                         if(u & 01) pow *= x;
276                         if(u >>= 1) x *= x;
277                         else break;
278                 }
279         }
280         return pow;
281 }
282 static double dpow_ui(double x, integer n) {
283         double pow=1.0; unsigned long int u;
284         if(n != 0) {
285                 if(n < 0) n = -n, x = 1/x;
286                 for(u = n; ; ) {
287                         if(u & 01) pow *= x;
288                         if(u >>= 1) x *= x;
289                         else break;
290                 }
291         }
292         return pow;
293 }
294 #ifdef _MSC_VER
295 static _Fcomplex cpow_ui(complex x, integer n) {
296         complex pow={1.0,0.0}; unsigned long int u;
297                 if(n != 0) {
298                 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
299                 for(u = n; ; ) {
300                         if(u & 01) pow.r *= x.r, pow.i *= x.i;
301                         if(u >>= 1) x.r *= x.r, x.i *= x.i;
302                         else break;
303                 }
304         }
305         _Fcomplex p={pow.r, pow.i};
306         return p;
307 }
308 #else
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310         _Complex float pow=1.0; unsigned long int u;
311         if(n != 0) {
312                 if(n < 0) n = -n, x = 1/x;
313                 for(u = n; ; ) {
314                         if(u & 01) pow *= x;
315                         if(u >>= 1) x *= x;
316                         else break;
317                 }
318         }
319         return pow;
320 }
321 #endif
322 #ifdef _MSC_VER
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324         _Dcomplex pow={1.0,0.0}; unsigned long int u;
325         if(n != 0) {
326                 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
327                 for(u = n; ; ) {
328                         if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329                         if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
330                         else break;
331                 }
332         }
333         _Dcomplex p = {pow._Val[0], pow._Val[1]};
334         return p;
335 }
336 #else
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338         _Complex double pow=1.0; unsigned long int u;
339         if(n != 0) {
340                 if(n < 0) n = -n, x = 1/x;
341                 for(u = n; ; ) {
342                         if(u & 01) pow *= x;
343                         if(u >>= 1) x *= x;
344                         else break;
345                 }
346         }
347         return pow;
348 }
349 #endif
350 static integer pow_ii(integer x, integer n) {
351         integer pow; unsigned long int u;
352         if (n <= 0) {
353                 if (n == 0 || x == 1) pow = 1;
354                 else if (x != -1) pow = x == 0 ? 1/x : 0;
355                 else n = -n;
356         }
357         if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
358                 u = n;
359                 for(pow = 1; ; ) {
360                         if(u & 01) pow *= x;
361                         if(u >>= 1) x *= x;
362                         else break;
363                 }
364         }
365         return pow;
366 }
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
368 {
369         double m; integer i, mi;
370         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371                 if (w[i-1]>m) mi=i ,m=w[i-1];
372         return mi-s+1;
373 }
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
375 {
376         float m; integer i, mi;
377         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378                 if (w[i-1]>m) mi=i ,m=w[i-1];
379         return mi-s+1;
380 }
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382         integer n = *n_, incx = *incx_, incy = *incy_, i;
383 #ifdef _MSC_VER
384         _Fcomplex zdotc = {0.0, 0.0};
385         if (incx == 1 && incy == 1) {
386                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387                         zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388                         zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
389                 }
390         } else {
391                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392                         zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393                         zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
394                 }
395         }
396         pCf(z) = zdotc;
397 }
398 #else
399         _Complex float zdotc = 0.0;
400         if (incx == 1 && incy == 1) {
401                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402                         zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
403                 }
404         } else {
405                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406                         zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
407                 }
408         }
409         pCf(z) = zdotc;
410 }
411 #endif
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413         integer n = *n_, incx = *incx_, incy = *incy_, i;
414 #ifdef _MSC_VER
415         _Dcomplex zdotc = {0.0, 0.0};
416         if (incx == 1 && incy == 1) {
417                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418                         zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419                         zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
420                 }
421         } else {
422                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423                         zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424                         zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
425                 }
426         }
427         pCd(z) = zdotc;
428 }
429 #else
430         _Complex double zdotc = 0.0;
431         if (incx == 1 && incy == 1) {
432                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433                         zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
434                 }
435         } else {
436                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437                         zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
438                 }
439         }
440         pCd(z) = zdotc;
441 }
442 #endif  
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444         integer n = *n_, incx = *incx_, incy = *incy_, i;
445 #ifdef _MSC_VER
446         _Fcomplex zdotc = {0.0, 0.0};
447         if (incx == 1 && incy == 1) {
448                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449                         zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450                         zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
451                 }
452         } else {
453                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454                         zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455                         zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
456                 }
457         }
458         pCf(z) = zdotc;
459 }
460 #else
461         _Complex float zdotc = 0.0;
462         if (incx == 1 && incy == 1) {
463                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464                         zdotc += Cf(&x[i]) * Cf(&y[i]);
465                 }
466         } else {
467                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468                         zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
469                 }
470         }
471         pCf(z) = zdotc;
472 }
473 #endif
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475         integer n = *n_, incx = *incx_, incy = *incy_, i;
476 #ifdef _MSC_VER
477         _Dcomplex zdotc = {0.0, 0.0};
478         if (incx == 1 && incy == 1) {
479                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480                         zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481                         zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
482                 }
483         } else {
484                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485                         zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486                         zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
487                 }
488         }
489         pCd(z) = zdotc;
490 }
491 #else
492         _Complex double zdotc = 0.0;
493         if (incx == 1 && incy == 1) {
494                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495                         zdotc += Cd(&x[i]) * Cd(&y[i]);
496                 }
497         } else {
498                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499                         zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
500                 }
501         }
502         pCd(z) = zdotc;
503 }
504 #endif
505 /*  -- translated by f2c (version 20000121).
506    You must link the resulting object file with the libraries:
507         -lf2c -lm   (in that order)
508 */
509
510
511
512
513 /* Table of constant values */
514
515 static logical c_false = FALSE_;
516 static integer c__1 = 1;
517 static real c_b22 = 1.f;
518 static real c_b25 = 0.f;
519 static integer c__2 = 2;
520 static logical c_true = TRUE_;
521
522 /* > \brief \b STREVC */
523
524 /*  =========== DOCUMENTATION =========== */
525
526 /* Online html documentation available at */
527 /*            http://www.netlib.org/lapack/explore-html/ */
528
529 /* > \htmlonly */
530 /* > Download STREVC + dependencies */
531 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/strevc.
532 f"> */
533 /* > [TGZ]</a> */
534 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/strevc.
535 f"> */
536 /* > [ZIP]</a> */
537 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/strevc.
538 f"> */
539 /* > [TXT]</a> */
540 /* > \endhtmlonly */
541
542 /*  Definition: */
543 /*  =========== */
544
545 /*       SUBROUTINE STREVC( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR, */
546 /*                          LDVR, MM, M, WORK, INFO ) */
547
548 /*       CHARACTER          HOWMNY, SIDE */
549 /*       INTEGER            INFO, LDT, LDVL, LDVR, M, MM, N */
550 /*       LOGICAL            SELECT( * ) */
551 /*       REAL               T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ), */
552 /*      $                   WORK( * ) */
553
554
555 /* > \par Purpose: */
556 /*  ============= */
557 /* > */
558 /* > \verbatim */
559 /* > */
560 /* > STREVC computes some or all of the right and/or left eigenvectors of */
561 /* > a real upper quasi-triangular matrix T. */
562 /* > Matrices of this type are produced by the Schur factorization of */
563 /* > a real general matrix:  A = Q*T*Q**T, as computed by SHSEQR. */
564 /* > */
565 /* > The right eigenvector x and the left eigenvector y of T corresponding */
566 /* > to an eigenvalue w are defined by: */
567 /* > */
568 /* >    T*x = w*x,     (y**H)*T = w*(y**H) */
569 /* > */
570 /* > where y**H denotes the conjugate transpose of y. */
571 /* > The eigenvalues are not input to this routine, but are read directly */
572 /* > from the diagonal blocks of T. */
573 /* > */
574 /* > This routine returns the matrices X and/or Y of right and left */
575 /* > eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an */
576 /* > input matrix.  If Q is the orthogonal factor that reduces a matrix */
577 /* > A to Schur form T, then Q*X and Q*Y are the matrices of right and */
578 /* > left eigenvectors of A. */
579 /* > \endverbatim */
580
581 /*  Arguments: */
582 /*  ========== */
583
584 /* > \param[in] SIDE */
585 /* > \verbatim */
586 /* >          SIDE is CHARACTER*1 */
587 /* >          = 'R':  compute right eigenvectors only; */
588 /* >          = 'L':  compute left eigenvectors only; */
589 /* >          = 'B':  compute both right and left eigenvectors. */
590 /* > \endverbatim */
591 /* > */
592 /* > \param[in] HOWMNY */
593 /* > \verbatim */
594 /* >          HOWMNY is CHARACTER*1 */
595 /* >          = 'A':  compute all right and/or left eigenvectors; */
596 /* >          = 'B':  compute all right and/or left eigenvectors, */
597 /* >                  backtransformed by the matrices in VR and/or VL; */
598 /* >          = 'S':  compute selected right and/or left eigenvectors, */
599 /* >                  as indicated by the logical array SELECT. */
600 /* > \endverbatim */
601 /* > */
602 /* > \param[in,out] SELECT */
603 /* > \verbatim */
604 /* >          SELECT is LOGICAL array, dimension (N) */
605 /* >          If HOWMNY = 'S', SELECT specifies the eigenvectors to be */
606 /* >          computed. */
607 /* >          If w(j) is a real eigenvalue, the corresponding real */
608 /* >          eigenvector is computed if SELECT(j) is .TRUE.. */
609 /* >          If w(j) and w(j+1) are the real and imaginary parts of a */
610 /* >          complex eigenvalue, the corresponding complex eigenvector is */
611 /* >          computed if either SELECT(j) or SELECT(j+1) is .TRUE., and */
612 /* >          on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is set to */
613 /* >          .FALSE.. */
614 /* >          Not referenced if HOWMNY = 'A' or 'B'. */
615 /* > \endverbatim */
616 /* > */
617 /* > \param[in] N */
618 /* > \verbatim */
619 /* >          N is INTEGER */
620 /* >          The order of the matrix T. N >= 0. */
621 /* > \endverbatim */
622 /* > */
623 /* > \param[in] T */
624 /* > \verbatim */
625 /* >          T is REAL array, dimension (LDT,N) */
626 /* >          The upper quasi-triangular matrix T in Schur canonical form. */
627 /* > \endverbatim */
628 /* > */
629 /* > \param[in] LDT */
630 /* > \verbatim */
631 /* >          LDT is INTEGER */
632 /* >          The leading dimension of the array T. LDT >= f2cmax(1,N). */
633 /* > \endverbatim */
634 /* > */
635 /* > \param[in,out] VL */
636 /* > \verbatim */
637 /* >          VL is REAL array, dimension (LDVL,MM) */
638 /* >          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must */
639 /* >          contain an N-by-N matrix Q (usually the orthogonal matrix Q */
640 /* >          of Schur vectors returned by SHSEQR). */
641 /* >          On exit, if SIDE = 'L' or 'B', VL contains: */
642 /* >          if HOWMNY = 'A', the matrix Y of left eigenvectors of T; */
643 /* >          if HOWMNY = 'B', the matrix Q*Y; */
644 /* >          if HOWMNY = 'S', the left eigenvectors of T specified by */
645 /* >                           SELECT, stored consecutively in the columns */
646 /* >                           of VL, in the same order as their */
647 /* >                           eigenvalues. */
648 /* >          A complex eigenvector corresponding to a complex eigenvalue */
649 /* >          is stored in two consecutive columns, the first holding the */
650 /* >          real part, and the second the imaginary part. */
651 /* >          Not referenced if SIDE = 'R'. */
652 /* > \endverbatim */
653 /* > */
654 /* > \param[in] LDVL */
655 /* > \verbatim */
656 /* >          LDVL is INTEGER */
657 /* >          The leading dimension of the array VL.  LDVL >= 1, and if */
658 /* >          SIDE = 'L' or 'B', LDVL >= N. */
659 /* > \endverbatim */
660 /* > */
661 /* > \param[in,out] VR */
662 /* > \verbatim */
663 /* >          VR is REAL array, dimension (LDVR,MM) */
664 /* >          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must */
665 /* >          contain an N-by-N matrix Q (usually the orthogonal matrix Q */
666 /* >          of Schur vectors returned by SHSEQR). */
667 /* >          On exit, if SIDE = 'R' or 'B', VR contains: */
668 /* >          if HOWMNY = 'A', the matrix X of right eigenvectors of T; */
669 /* >          if HOWMNY = 'B', the matrix Q*X; */
670 /* >          if HOWMNY = 'S', the right eigenvectors of T specified by */
671 /* >                           SELECT, stored consecutively in the columns */
672 /* >                           of VR, in the same order as their */
673 /* >                           eigenvalues. */
674 /* >          A complex eigenvector corresponding to a complex eigenvalue */
675 /* >          is stored in two consecutive columns, the first holding the */
676 /* >          real part and the second the imaginary part. */
677 /* >          Not referenced if SIDE = 'L'. */
678 /* > \endverbatim */
679 /* > */
680 /* > \param[in] LDVR */
681 /* > \verbatim */
682 /* >          LDVR is INTEGER */
683 /* >          The leading dimension of the array VR.  LDVR >= 1, and if */
684 /* >          SIDE = 'R' or 'B', LDVR >= N. */
685 /* > \endverbatim */
686 /* > */
687 /* > \param[in] MM */
688 /* > \verbatim */
689 /* >          MM is INTEGER */
690 /* >          The number of columns in the arrays VL and/or VR. MM >= M. */
691 /* > \endverbatim */
692 /* > */
693 /* > \param[out] M */
694 /* > \verbatim */
695 /* >          M is INTEGER */
696 /* >          The number of columns in the arrays VL and/or VR actually */
697 /* >          used to store the eigenvectors. */
698 /* >          If HOWMNY = 'A' or 'B', M is set to N. */
699 /* >          Each selected real eigenvector occupies one column and each */
700 /* >          selected complex eigenvector occupies two columns. */
701 /* > \endverbatim */
702 /* > */
703 /* > \param[out] WORK */
704 /* > \verbatim */
705 /* >          WORK is REAL array, dimension (3*N) */
706 /* > \endverbatim */
707 /* > */
708 /* > \param[out] INFO */
709 /* > \verbatim */
710 /* >          INFO is INTEGER */
711 /* >          = 0:  successful exit */
712 /* >          < 0:  if INFO = -i, the i-th argument had an illegal value */
713 /* > \endverbatim */
714
715 /*  Authors: */
716 /*  ======== */
717
718 /* > \author Univ. of Tennessee */
719 /* > \author Univ. of California Berkeley */
720 /* > \author Univ. of Colorado Denver */
721 /* > \author NAG Ltd. */
722
723 /* > \date December 2016 */
724
725 /* > \ingroup realOTHERcomputational */
726
727 /* > \par Further Details: */
728 /*  ===================== */
729 /* > */
730 /* > \verbatim */
731 /* > */
732 /* >  The algorithm used in this program is basically backward (forward) */
733 /* >  substitution, with scaling to make the the code robust against */
734 /* >  possible overflow. */
735 /* > */
736 /* >  Each eigenvector is normalized so that the element of largest */
737 /* >  magnitude has magnitude 1; here the magnitude of a complex number */
738 /* >  (x,y) is taken to be |x| + |y|. */
739 /* > \endverbatim */
740 /* > */
741 /*  ===================================================================== */
742 /* Subroutine */ int strevc_(char *side, char *howmny, logical *select, 
743         integer *n, real *t, integer *ldt, real *vl, integer *ldvl, real *vr, 
744         integer *ldvr, integer *mm, integer *m, real *work, integer *info)
745 {
746     /* System generated locals */
747     integer t_dim1, t_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, 
748             i__2, i__3;
749     real r__1, r__2, r__3, r__4;
750
751     /* Local variables */
752     real beta, emax;
753     logical pair, allv;
754     integer ierr;
755     real unfl, ovfl, smin;
756     extern real sdot_(integer *, real *, integer *, real *, integer *);
757     logical over;
758     real vmax;
759     integer jnxt, i__, j, k;
760     real scale, x[4]    /* was [2][2] */;
761     extern logical lsame_(char *, char *);
762     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
763     real remax;
764     logical leftv;
765     extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, 
766             real *, integer *, real *, integer *, real *, real *, integer *);
767     logical bothv;
768     real vcrit;
769     logical somev;
770     integer j1, j2;
771     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
772             integer *);
773     integer n2;
774     real xnorm;
775     extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 
776             real *, integer *), slaln2_(logical *, integer *, integer *, real 
777             *, real *, real *, integer *, real *, real *, real *, integer *, 
778             real *, real *, real *, integer *, real *, real *, integer *);
779     integer ii, ki;
780     extern /* Subroutine */ int slabad_(real *, real *);
781     integer ip, is;
782     real wi;
783     extern real slamch_(char *);
784     real wr;
785     extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
786     real bignum;
787     extern integer isamax_(integer *, real *, integer *);
788     logical rightv;
789     real smlnum, rec, ulp;
790
791
792 /*  -- LAPACK computational routine (version 3.7.0) -- */
793 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
794 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
795 /*     December 2016 */
796
797
798 /*  ===================================================================== */
799
800
801 /*     Decode and test the input parameters */
802
803     /* Parameter adjustments */
804     --select;
805     t_dim1 = *ldt;
806     t_offset = 1 + t_dim1 * 1;
807     t -= t_offset;
808     vl_dim1 = *ldvl;
809     vl_offset = 1 + vl_dim1 * 1;
810     vl -= vl_offset;
811     vr_dim1 = *ldvr;
812     vr_offset = 1 + vr_dim1 * 1;
813     vr -= vr_offset;
814     --work;
815
816     /* Function Body */
817     bothv = lsame_(side, "B");
818     rightv = lsame_(side, "R") || bothv;
819     leftv = lsame_(side, "L") || bothv;
820
821     allv = lsame_(howmny, "A");
822     over = lsame_(howmny, "B");
823     somev = lsame_(howmny, "S");
824
825     *info = 0;
826     if (! rightv && ! leftv) {
827         *info = -1;
828     } else if (! allv && ! over && ! somev) {
829         *info = -2;
830     } else if (*n < 0) {
831         *info = -4;
832     } else if (*ldt < f2cmax(1,*n)) {
833         *info = -6;
834     } else if (*ldvl < 1 || leftv && *ldvl < *n) {
835         *info = -8;
836     } else if (*ldvr < 1 || rightv && *ldvr < *n) {
837         *info = -10;
838     } else {
839
840 /*        Set M to the number of columns required to store the selected */
841 /*        eigenvectors, standardize the array SELECT if necessary, and */
842 /*        test MM. */
843
844         if (somev) {
845             *m = 0;
846             pair = FALSE_;
847             i__1 = *n;
848             for (j = 1; j <= i__1; ++j) {
849                 if (pair) {
850                     pair = FALSE_;
851                     select[j] = FALSE_;
852                 } else {
853                     if (j < *n) {
854                         if (t[j + 1 + j * t_dim1] == 0.f) {
855                             if (select[j]) {
856                                 ++(*m);
857                             }
858                         } else {
859                             pair = TRUE_;
860                             if (select[j] || select[j + 1]) {
861                                 select[j] = TRUE_;
862                                 *m += 2;
863                             }
864                         }
865                     } else {
866                         if (select[*n]) {
867                             ++(*m);
868                         }
869                     }
870                 }
871 /* L10: */
872             }
873         } else {
874             *m = *n;
875         }
876
877         if (*mm < *m) {
878             *info = -11;
879         }
880     }
881     if (*info != 0) {
882         i__1 = -(*info);
883         xerbla_("STREVC", &i__1, (ftnlen)6);
884         return 0;
885     }
886
887 /*     Quick return if possible. */
888
889     if (*n == 0) {
890         return 0;
891     }
892
893 /*     Set the constants to control overflow. */
894
895     unfl = slamch_("Safe minimum");
896     ovfl = 1.f / unfl;
897     slabad_(&unfl, &ovfl);
898     ulp = slamch_("Precision");
899     smlnum = unfl * (*n / ulp);
900     bignum = (1.f - ulp) / smlnum;
901
902 /*     Compute 1-norm of each column of strictly upper triangular */
903 /*     part of T to control overflow in triangular solver. */
904
905     work[1] = 0.f;
906     i__1 = *n;
907     for (j = 2; j <= i__1; ++j) {
908         work[j] = 0.f;
909         i__2 = j - 1;
910         for (i__ = 1; i__ <= i__2; ++i__) {
911             work[j] += (r__1 = t[i__ + j * t_dim1], abs(r__1));
912 /* L20: */
913         }
914 /* L30: */
915     }
916
917 /*     Index IP is used to specify the real or complex eigenvalue: */
918 /*       IP = 0, real eigenvalue, */
919 /*            1, first of conjugate complex pair: (wr,wi) */
920 /*           -1, second of conjugate complex pair: (wr,wi) */
921
922     n2 = *n << 1;
923
924     if (rightv) {
925
926 /*        Compute right eigenvectors. */
927
928         ip = 0;
929         is = *m;
930         for (ki = *n; ki >= 1; --ki) {
931
932             if (ip == 1) {
933                 goto L130;
934             }
935             if (ki == 1) {
936                 goto L40;
937             }
938             if (t[ki + (ki - 1) * t_dim1] == 0.f) {
939                 goto L40;
940             }
941             ip = -1;
942
943 L40:
944             if (somev) {
945                 if (ip == 0) {
946                     if (! select[ki]) {
947                         goto L130;
948                     }
949                 } else {
950                     if (! select[ki - 1]) {
951                         goto L130;
952                     }
953                 }
954             }
955
956 /*           Compute the KI-th eigenvalue (WR,WI). */
957
958             wr = t[ki + ki * t_dim1];
959             wi = 0.f;
960             if (ip != 0) {
961                 wi = sqrt((r__1 = t[ki + (ki - 1) * t_dim1], abs(r__1))) * 
962                         sqrt((r__2 = t[ki - 1 + ki * t_dim1], abs(r__2)));
963             }
964 /* Computing MAX */
965             r__1 = ulp * (abs(wr) + abs(wi));
966             smin = f2cmax(r__1,smlnum);
967
968             if (ip == 0) {
969
970 /*              Real right eigenvector */
971
972                 work[ki + *n] = 1.f;
973
974 /*              Form right-hand side */
975
976                 i__1 = ki - 1;
977                 for (k = 1; k <= i__1; ++k) {
978                     work[k + *n] = -t[k + ki * t_dim1];
979 /* L50: */
980                 }
981
982 /*              Solve the upper quasi-triangular system: */
983 /*                 (T(1:KI-1,1:KI-1) - WR)*X = SCALE*WORK. */
984
985                 jnxt = ki - 1;
986                 for (j = ki - 1; j >= 1; --j) {
987                     if (j > jnxt) {
988                         goto L60;
989                     }
990                     j1 = j;
991                     j2 = j;
992                     jnxt = j - 1;
993                     if (j > 1) {
994                         if (t[j + (j - 1) * t_dim1] != 0.f) {
995                             j1 = j - 1;
996                             jnxt = j - 2;
997                         }
998                     }
999
1000                     if (j1 == j2) {
1001
1002 /*                    1-by-1 diagonal block */
1003
1004                         slaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j + 
1005                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1006                                 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, 
1007                                 &ierr);
1008
1009 /*                    Scale X(1,1) to avoid overflow when updating */
1010 /*                    the right-hand side. */
1011
1012                         if (xnorm > 1.f) {
1013                             if (work[j] > bignum / xnorm) {
1014                                 x[0] /= xnorm;
1015                                 scale /= xnorm;
1016                             }
1017                         }
1018
1019 /*                    Scale if necessary */
1020
1021                         if (scale != 1.f) {
1022                             sscal_(&ki, &scale, &work[*n + 1], &c__1);
1023                         }
1024                         work[j + *n] = x[0];
1025
1026 /*                    Update right-hand side */
1027
1028                         i__1 = j - 1;
1029                         r__1 = -x[0];
1030                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1031                                 *n + 1], &c__1);
1032
1033                     } else {
1034
1035 /*                    2-by-2 diagonal block */
1036
1037                         slaln2_(&c_false, &c__2, &c__1, &smin, &c_b22, &t[j - 
1038                                 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, &
1039                                 work[j - 1 + *n], n, &wr, &c_b25, x, &c__2, &
1040                                 scale, &xnorm, &ierr);
1041
1042 /*                    Scale X(1,1) and X(2,1) to avoid overflow when */
1043 /*                    updating the right-hand side. */
1044
1045                         if (xnorm > 1.f) {
1046 /* Computing MAX */
1047                             r__1 = work[j - 1], r__2 = work[j];
1048                             beta = f2cmax(r__1,r__2);
1049                             if (beta > bignum / xnorm) {
1050                                 x[0] /= xnorm;
1051                                 x[1] /= xnorm;
1052                                 scale /= xnorm;
1053                             }
1054                         }
1055
1056 /*                    Scale if necessary */
1057
1058                         if (scale != 1.f) {
1059                             sscal_(&ki, &scale, &work[*n + 1], &c__1);
1060                         }
1061                         work[j - 1 + *n] = x[0];
1062                         work[j + *n] = x[1];
1063
1064 /*                    Update right-hand side */
1065
1066                         i__1 = j - 2;
1067                         r__1 = -x[0];
1068                         saxpy_(&i__1, &r__1, &t[(j - 1) * t_dim1 + 1], &c__1, 
1069                                 &work[*n + 1], &c__1);
1070                         i__1 = j - 2;
1071                         r__1 = -x[1];
1072                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1073                                 *n + 1], &c__1);
1074                     }
1075 L60:
1076                     ;
1077                 }
1078
1079 /*              Copy the vector x or Q*x to VR and normalize. */
1080
1081                 if (! over) {
1082                     scopy_(&ki, &work[*n + 1], &c__1, &vr[is * vr_dim1 + 1], &
1083                             c__1);
1084
1085                     ii = isamax_(&ki, &vr[is * vr_dim1 + 1], &c__1);
1086                     remax = 1.f / (r__1 = vr[ii + is * vr_dim1], abs(r__1));
1087                     sscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1);
1088
1089                     i__1 = *n;
1090                     for (k = ki + 1; k <= i__1; ++k) {
1091                         vr[k + is * vr_dim1] = 0.f;
1092 /* L70: */
1093                     }
1094                 } else {
1095                     if (ki > 1) {
1096                         i__1 = ki - 1;
1097                         sgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
1098                                 work[*n + 1], &c__1, &work[ki + *n], &vr[ki * 
1099                                 vr_dim1 + 1], &c__1);
1100                     }
1101
1102                     ii = isamax_(n, &vr[ki * vr_dim1 + 1], &c__1);
1103                     remax = 1.f / (r__1 = vr[ii + ki * vr_dim1], abs(r__1));
1104                     sscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1);
1105                 }
1106
1107             } else {
1108
1109 /*              Complex right eigenvector. */
1110
1111 /*              Initial solve */
1112 /*                [ (T(KI-1,KI-1) T(KI-1,KI) ) - (WR + I* WI)]*X = 0. */
1113 /*                [ (T(KI,KI-1)   T(KI,KI)   )               ] */
1114
1115                 if ((r__1 = t[ki - 1 + ki * t_dim1], abs(r__1)) >= (r__2 = t[
1116                         ki + (ki - 1) * t_dim1], abs(r__2))) {
1117                     work[ki - 1 + *n] = 1.f;
1118                     work[ki + n2] = wi / t[ki - 1 + ki * t_dim1];
1119                 } else {
1120                     work[ki - 1 + *n] = -wi / t[ki + (ki - 1) * t_dim1];
1121                     work[ki + n2] = 1.f;
1122                 }
1123                 work[ki + *n] = 0.f;
1124                 work[ki - 1 + n2] = 0.f;
1125
1126 /*              Form right-hand side */
1127
1128                 i__1 = ki - 2;
1129                 for (k = 1; k <= i__1; ++k) {
1130                     work[k + *n] = -work[ki - 1 + *n] * t[k + (ki - 1) * 
1131                             t_dim1];
1132                     work[k + n2] = -work[ki + n2] * t[k + ki * t_dim1];
1133 /* L80: */
1134                 }
1135
1136 /*              Solve upper quasi-triangular system: */
1137 /*              (T(1:KI-2,1:KI-2) - (WR+i*WI))*X = SCALE*(WORK+i*WORK2) */
1138
1139                 jnxt = ki - 2;
1140                 for (j = ki - 2; j >= 1; --j) {
1141                     if (j > jnxt) {
1142                         goto L90;
1143                     }
1144                     j1 = j;
1145                     j2 = j;
1146                     jnxt = j - 1;
1147                     if (j > 1) {
1148                         if (t[j + (j - 1) * t_dim1] != 0.f) {
1149                             j1 = j - 1;
1150                             jnxt = j - 2;
1151                         }
1152                     }
1153
1154                     if (j1 == j2) {
1155
1156 /*                    1-by-1 diagonal block */
1157
1158                         slaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j + 
1159                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1160                                 n], n, &wr, &wi, x, &c__2, &scale, &xnorm, &
1161                                 ierr);
1162
1163 /*                    Scale X(1,1) and X(1,2) to avoid overflow when */
1164 /*                    updating the right-hand side. */
1165
1166                         if (xnorm > 1.f) {
1167                             if (work[j] > bignum / xnorm) {
1168                                 x[0] /= xnorm;
1169                                 x[2] /= xnorm;
1170                                 scale /= xnorm;
1171                             }
1172                         }
1173
1174 /*                    Scale if necessary */
1175
1176                         if (scale != 1.f) {
1177                             sscal_(&ki, &scale, &work[*n + 1], &c__1);
1178                             sscal_(&ki, &scale, &work[n2 + 1], &c__1);
1179                         }
1180                         work[j + *n] = x[0];
1181                         work[j + n2] = x[2];
1182
1183 /*                    Update the right-hand side */
1184
1185                         i__1 = j - 1;
1186                         r__1 = -x[0];
1187                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1188                                 *n + 1], &c__1);
1189                         i__1 = j - 1;
1190                         r__1 = -x[2];
1191                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1192                                 n2 + 1], &c__1);
1193
1194                     } else {
1195
1196 /*                    2-by-2 diagonal block */
1197
1198                         slaln2_(&c_false, &c__2, &c__2, &smin, &c_b22, &t[j - 
1199                                 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, &
1200                                 work[j - 1 + *n], n, &wr, &wi, x, &c__2, &
1201                                 scale, &xnorm, &ierr);
1202
1203 /*                    Scale X to avoid overflow when updating */
1204 /*                    the right-hand side. */
1205
1206                         if (xnorm > 1.f) {
1207 /* Computing MAX */
1208                             r__1 = work[j - 1], r__2 = work[j];
1209                             beta = f2cmax(r__1,r__2);
1210                             if (beta > bignum / xnorm) {
1211                                 rec = 1.f / xnorm;
1212                                 x[0] *= rec;
1213                                 x[2] *= rec;
1214                                 x[1] *= rec;
1215                                 x[3] *= rec;
1216                                 scale *= rec;
1217                             }
1218                         }
1219
1220 /*                    Scale if necessary */
1221
1222                         if (scale != 1.f) {
1223                             sscal_(&ki, &scale, &work[*n + 1], &c__1);
1224                             sscal_(&ki, &scale, &work[n2 + 1], &c__1);
1225                         }
1226                         work[j - 1 + *n] = x[0];
1227                         work[j + *n] = x[1];
1228                         work[j - 1 + n2] = x[2];
1229                         work[j + n2] = x[3];
1230
1231 /*                    Update the right-hand side */
1232
1233                         i__1 = j - 2;
1234                         r__1 = -x[0];
1235                         saxpy_(&i__1, &r__1, &t[(j - 1) * t_dim1 + 1], &c__1, 
1236                                 &work[*n + 1], &c__1);
1237                         i__1 = j - 2;
1238                         r__1 = -x[1];
1239                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1240                                 *n + 1], &c__1);
1241                         i__1 = j - 2;
1242                         r__1 = -x[2];
1243                         saxpy_(&i__1, &r__1, &t[(j - 1) * t_dim1 + 1], &c__1, 
1244                                 &work[n2 + 1], &c__1);
1245                         i__1 = j - 2;
1246                         r__1 = -x[3];
1247                         saxpy_(&i__1, &r__1, &t[j * t_dim1 + 1], &c__1, &work[
1248                                 n2 + 1], &c__1);
1249                     }
1250 L90:
1251                     ;
1252                 }
1253
1254 /*              Copy the vector x or Q*x to VR and normalize. */
1255
1256                 if (! over) {
1257                     scopy_(&ki, &work[*n + 1], &c__1, &vr[(is - 1) * vr_dim1 
1258                             + 1], &c__1);
1259                     scopy_(&ki, &work[n2 + 1], &c__1, &vr[is * vr_dim1 + 1], &
1260                             c__1);
1261
1262                     emax = 0.f;
1263                     i__1 = ki;
1264                     for (k = 1; k <= i__1; ++k) {
1265 /* Computing MAX */
1266                         r__3 = emax, r__4 = (r__1 = vr[k + (is - 1) * vr_dim1]
1267                                 , abs(r__1)) + (r__2 = vr[k + is * vr_dim1], 
1268                                 abs(r__2));
1269                         emax = f2cmax(r__3,r__4);
1270 /* L100: */
1271                     }
1272
1273                     remax = 1.f / emax;
1274                     sscal_(&ki, &remax, &vr[(is - 1) * vr_dim1 + 1], &c__1);
1275                     sscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1);
1276
1277                     i__1 = *n;
1278                     for (k = ki + 1; k <= i__1; ++k) {
1279                         vr[k + (is - 1) * vr_dim1] = 0.f;
1280                         vr[k + is * vr_dim1] = 0.f;
1281 /* L110: */
1282                     }
1283
1284                 } else {
1285
1286                     if (ki > 2) {
1287                         i__1 = ki - 2;
1288                         sgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
1289                                 work[*n + 1], &c__1, &work[ki - 1 + *n], &vr[(
1290                                 ki - 1) * vr_dim1 + 1], &c__1);
1291                         i__1 = ki - 2;
1292                         sgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, &
1293                                 work[n2 + 1], &c__1, &work[ki + n2], &vr[ki * 
1294                                 vr_dim1 + 1], &c__1);
1295                     } else {
1296                         sscal_(n, &work[ki - 1 + *n], &vr[(ki - 1) * vr_dim1 
1297                                 + 1], &c__1);
1298                         sscal_(n, &work[ki + n2], &vr[ki * vr_dim1 + 1], &
1299                                 c__1);
1300                     }
1301
1302                     emax = 0.f;
1303                     i__1 = *n;
1304                     for (k = 1; k <= i__1; ++k) {
1305 /* Computing MAX */
1306                         r__3 = emax, r__4 = (r__1 = vr[k + (ki - 1) * vr_dim1]
1307                                 , abs(r__1)) + (r__2 = vr[k + ki * vr_dim1], 
1308                                 abs(r__2));
1309                         emax = f2cmax(r__3,r__4);
1310 /* L120: */
1311                     }
1312                     remax = 1.f / emax;
1313                     sscal_(n, &remax, &vr[(ki - 1) * vr_dim1 + 1], &c__1);
1314                     sscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1);
1315                 }
1316             }
1317
1318             --is;
1319             if (ip != 0) {
1320                 --is;
1321             }
1322 L130:
1323             if (ip == 1) {
1324                 ip = 0;
1325             }
1326             if (ip == -1) {
1327                 ip = 1;
1328             }
1329 /* L140: */
1330         }
1331     }
1332
1333     if (leftv) {
1334
1335 /*        Compute left eigenvectors. */
1336
1337         ip = 0;
1338         is = 1;
1339         i__1 = *n;
1340         for (ki = 1; ki <= i__1; ++ki) {
1341
1342             if (ip == -1) {
1343                 goto L250;
1344             }
1345             if (ki == *n) {
1346                 goto L150;
1347             }
1348             if (t[ki + 1 + ki * t_dim1] == 0.f) {
1349                 goto L150;
1350             }
1351             ip = 1;
1352
1353 L150:
1354             if (somev) {
1355                 if (! select[ki]) {
1356                     goto L250;
1357                 }
1358             }
1359
1360 /*           Compute the KI-th eigenvalue (WR,WI). */
1361
1362             wr = t[ki + ki * t_dim1];
1363             wi = 0.f;
1364             if (ip != 0) {
1365                 wi = sqrt((r__1 = t[ki + (ki + 1) * t_dim1], abs(r__1))) * 
1366                         sqrt((r__2 = t[ki + 1 + ki * t_dim1], abs(r__2)));
1367             }
1368 /* Computing MAX */
1369             r__1 = ulp * (abs(wr) + abs(wi));
1370             smin = f2cmax(r__1,smlnum);
1371
1372             if (ip == 0) {
1373
1374 /*              Real left eigenvector. */
1375
1376                 work[ki + *n] = 1.f;
1377
1378 /*              Form right-hand side */
1379
1380                 i__2 = *n;
1381                 for (k = ki + 1; k <= i__2; ++k) {
1382                     work[k + *n] = -t[ki + k * t_dim1];
1383 /* L160: */
1384                 }
1385
1386 /*              Solve the quasi-triangular system: */
1387 /*                 (T(KI+1:N,KI+1:N) - WR)**T*X = SCALE*WORK */
1388
1389                 vmax = 1.f;
1390                 vcrit = bignum;
1391
1392                 jnxt = ki + 1;
1393                 i__2 = *n;
1394                 for (j = ki + 1; j <= i__2; ++j) {
1395                     if (j < jnxt) {
1396                         goto L170;
1397                     }
1398                     j1 = j;
1399                     j2 = j;
1400                     jnxt = j + 1;
1401                     if (j < *n) {
1402                         if (t[j + 1 + j * t_dim1] != 0.f) {
1403                             j2 = j + 1;
1404                             jnxt = j + 2;
1405                         }
1406                     }
1407
1408                     if (j1 == j2) {
1409
1410 /*                    1-by-1 diagonal block */
1411
1412 /*                    Scale if necessary to avoid overflow when forming */
1413 /*                    the right-hand side. */
1414
1415                         if (work[j] > vcrit) {
1416                             rec = 1.f / vmax;
1417                             i__3 = *n - ki + 1;
1418                             sscal_(&i__3, &rec, &work[ki + *n], &c__1);
1419                             vmax = 1.f;
1420                             vcrit = bignum;
1421                         }
1422
1423                         i__3 = j - ki - 1;
1424                         work[j + *n] -= sdot_(&i__3, &t[ki + 1 + j * t_dim1], 
1425                                 &c__1, &work[ki + 1 + *n], &c__1);
1426
1427 /*                    Solve (T(J,J)-WR)**T*X = WORK */
1428
1429                         slaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j + 
1430                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1431                                 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, 
1432                                 &ierr);
1433
1434 /*                    Scale if necessary */
1435
1436                         if (scale != 1.f) {
1437                             i__3 = *n - ki + 1;
1438                             sscal_(&i__3, &scale, &work[ki + *n], &c__1);
1439                         }
1440                         work[j + *n] = x[0];
1441 /* Computing MAX */
1442                         r__2 = (r__1 = work[j + *n], abs(r__1));
1443                         vmax = f2cmax(r__2,vmax);
1444                         vcrit = bignum / vmax;
1445
1446                     } else {
1447
1448 /*                    2-by-2 diagonal block */
1449
1450 /*                    Scale if necessary to avoid overflow when forming */
1451 /*                    the right-hand side. */
1452
1453 /* Computing MAX */
1454                         r__1 = work[j], r__2 = work[j + 1];
1455                         beta = f2cmax(r__1,r__2);
1456                         if (beta > vcrit) {
1457                             rec = 1.f / vmax;
1458                             i__3 = *n - ki + 1;
1459                             sscal_(&i__3, &rec, &work[ki + *n], &c__1);
1460                             vmax = 1.f;
1461                             vcrit = bignum;
1462                         }
1463
1464                         i__3 = j - ki - 1;
1465                         work[j + *n] -= sdot_(&i__3, &t[ki + 1 + j * t_dim1], 
1466                                 &c__1, &work[ki + 1 + *n], &c__1);
1467
1468                         i__3 = j - ki - 1;
1469                         work[j + 1 + *n] -= sdot_(&i__3, &t[ki + 1 + (j + 1) *
1470                                  t_dim1], &c__1, &work[ki + 1 + *n], &c__1);
1471
1472 /*                    Solve */
1473 /*                      [T(J,J)-WR   T(J,J+1)     ]**T* X = SCALE*( WORK1 ) */
1474 /*                      [T(J+1,J)    T(J+1,J+1)-WR]               ( WORK2 ) */
1475
1476                         slaln2_(&c_true, &c__2, &c__1, &smin, &c_b22, &t[j + 
1477                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1478                                 n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, 
1479                                 &ierr);
1480
1481 /*                    Scale if necessary */
1482
1483                         if (scale != 1.f) {
1484                             i__3 = *n - ki + 1;
1485                             sscal_(&i__3, &scale, &work[ki + *n], &c__1);
1486                         }
1487                         work[j + *n] = x[0];
1488                         work[j + 1 + *n] = x[1];
1489
1490 /* Computing MAX */
1491                         r__3 = (r__1 = work[j + *n], abs(r__1)), r__4 = (r__2 
1492                                 = work[j + 1 + *n], abs(r__2)), r__3 = f2cmax(
1493                                 r__3,r__4);
1494                         vmax = f2cmax(r__3,vmax);
1495                         vcrit = bignum / vmax;
1496
1497                     }
1498 L170:
1499                     ;
1500                 }
1501
1502 /*              Copy the vector x or Q*x to VL and normalize. */
1503
1504                 if (! over) {
1505                     i__2 = *n - ki + 1;
1506                     scopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is * 
1507                             vl_dim1], &c__1);
1508
1509                     i__2 = *n - ki + 1;
1510                     ii = isamax_(&i__2, &vl[ki + is * vl_dim1], &c__1) + ki - 
1511                             1;
1512                     remax = 1.f / (r__1 = vl[ii + is * vl_dim1], abs(r__1));
1513                     i__2 = *n - ki + 1;
1514                     sscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1);
1515
1516                     i__2 = ki - 1;
1517                     for (k = 1; k <= i__2; ++k) {
1518                         vl[k + is * vl_dim1] = 0.f;
1519 /* L180: */
1520                     }
1521
1522                 } else {
1523
1524                     if (ki < *n) {
1525                         i__2 = *n - ki;
1526                         sgemv_("N", n, &i__2, &c_b22, &vl[(ki + 1) * vl_dim1 
1527                                 + 1], ldvl, &work[ki + 1 + *n], &c__1, &work[
1528                                 ki + *n], &vl[ki * vl_dim1 + 1], &c__1);
1529                     }
1530
1531                     ii = isamax_(n, &vl[ki * vl_dim1 + 1], &c__1);
1532                     remax = 1.f / (r__1 = vl[ii + ki * vl_dim1], abs(r__1));
1533                     sscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1);
1534
1535                 }
1536
1537             } else {
1538
1539 /*              Complex left eigenvector. */
1540
1541 /*               Initial solve: */
1542 /*                 ((T(KI,KI)    T(KI,KI+1) )**T - (WR - I* WI))*X = 0. */
1543 /*                 ((T(KI+1,KI) T(KI+1,KI+1))                ) */
1544
1545                 if ((r__1 = t[ki + (ki + 1) * t_dim1], abs(r__1)) >= (r__2 = 
1546                         t[ki + 1 + ki * t_dim1], abs(r__2))) {
1547                     work[ki + *n] = wi / t[ki + (ki + 1) * t_dim1];
1548                     work[ki + 1 + n2] = 1.f;
1549                 } else {
1550                     work[ki + *n] = 1.f;
1551                     work[ki + 1 + n2] = -wi / t[ki + 1 + ki * t_dim1];
1552                 }
1553                 work[ki + 1 + *n] = 0.f;
1554                 work[ki + n2] = 0.f;
1555
1556 /*              Form right-hand side */
1557
1558                 i__2 = *n;
1559                 for (k = ki + 2; k <= i__2; ++k) {
1560                     work[k + *n] = -work[ki + *n] * t[ki + k * t_dim1];
1561                     work[k + n2] = -work[ki + 1 + n2] * t[ki + 1 + k * t_dim1]
1562                             ;
1563 /* L190: */
1564                 }
1565
1566 /*              Solve complex quasi-triangular system: */
1567 /*              ( T(KI+2,N:KI+2,N) - (WR-i*WI) )*X = WORK1+i*WORK2 */
1568
1569                 vmax = 1.f;
1570                 vcrit = bignum;
1571
1572                 jnxt = ki + 2;
1573                 i__2 = *n;
1574                 for (j = ki + 2; j <= i__2; ++j) {
1575                     if (j < jnxt) {
1576                         goto L200;
1577                     }
1578                     j1 = j;
1579                     j2 = j;
1580                     jnxt = j + 1;
1581                     if (j < *n) {
1582                         if (t[j + 1 + j * t_dim1] != 0.f) {
1583                             j2 = j + 1;
1584                             jnxt = j + 2;
1585                         }
1586                     }
1587
1588                     if (j1 == j2) {
1589
1590 /*                    1-by-1 diagonal block */
1591
1592 /*                    Scale if necessary to avoid overflow when */
1593 /*                    forming the right-hand side elements. */
1594
1595                         if (work[j] > vcrit) {
1596                             rec = 1.f / vmax;
1597                             i__3 = *n - ki + 1;
1598                             sscal_(&i__3, &rec, &work[ki + *n], &c__1);
1599                             i__3 = *n - ki + 1;
1600                             sscal_(&i__3, &rec, &work[ki + n2], &c__1);
1601                             vmax = 1.f;
1602                             vcrit = bignum;
1603                         }
1604
1605                         i__3 = j - ki - 2;
1606                         work[j + *n] -= sdot_(&i__3, &t[ki + 2 + j * t_dim1], 
1607                                 &c__1, &work[ki + 2 + *n], &c__1);
1608                         i__3 = j - ki - 2;
1609                         work[j + n2] -= sdot_(&i__3, &t[ki + 2 + j * t_dim1], 
1610                                 &c__1, &work[ki + 2 + n2], &c__1);
1611
1612 /*                    Solve (T(J,J)-(WR-i*WI))*(X11+i*X12)= WK+I*WK2 */
1613
1614                         r__1 = -wi;
1615                         slaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j + 
1616                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1617                                 n], n, &wr, &r__1, x, &c__2, &scale, &xnorm, &
1618                                 ierr);
1619
1620 /*                    Scale if necessary */
1621
1622                         if (scale != 1.f) {
1623                             i__3 = *n - ki + 1;
1624                             sscal_(&i__3, &scale, &work[ki + *n], &c__1);
1625                             i__3 = *n - ki + 1;
1626                             sscal_(&i__3, &scale, &work[ki + n2], &c__1);
1627                         }
1628                         work[j + *n] = x[0];
1629                         work[j + n2] = x[2];
1630 /* Computing MAX */
1631                         r__3 = (r__1 = work[j + *n], abs(r__1)), r__4 = (r__2 
1632                                 = work[j + n2], abs(r__2)), r__3 = f2cmax(r__3,
1633                                 r__4);
1634                         vmax = f2cmax(r__3,vmax);
1635                         vcrit = bignum / vmax;
1636
1637                     } else {
1638
1639 /*                    2-by-2 diagonal block */
1640
1641 /*                    Scale if necessary to avoid overflow when forming */
1642 /*                    the right-hand side elements. */
1643
1644 /* Computing MAX */
1645                         r__1 = work[j], r__2 = work[j + 1];
1646                         beta = f2cmax(r__1,r__2);
1647                         if (beta > vcrit) {
1648                             rec = 1.f / vmax;
1649                             i__3 = *n - ki + 1;
1650                             sscal_(&i__3, &rec, &work[ki + *n], &c__1);
1651                             i__3 = *n - ki + 1;
1652                             sscal_(&i__3, &rec, &work[ki + n2], &c__1);
1653                             vmax = 1.f;
1654                             vcrit = bignum;
1655                         }
1656
1657                         i__3 = j - ki - 2;
1658                         work[j + *n] -= sdot_(&i__3, &t[ki + 2 + j * t_dim1], 
1659                                 &c__1, &work[ki + 2 + *n], &c__1);
1660
1661                         i__3 = j - ki - 2;
1662                         work[j + n2] -= sdot_(&i__3, &t[ki + 2 + j * t_dim1], 
1663                                 &c__1, &work[ki + 2 + n2], &c__1);
1664
1665                         i__3 = j - ki - 2;
1666                         work[j + 1 + *n] -= sdot_(&i__3, &t[ki + 2 + (j + 1) *
1667                                  t_dim1], &c__1, &work[ki + 2 + *n], &c__1);
1668
1669                         i__3 = j - ki - 2;
1670                         work[j + 1 + n2] -= sdot_(&i__3, &t[ki + 2 + (j + 1) *
1671                                  t_dim1], &c__1, &work[ki + 2 + n2], &c__1);
1672
1673 /*                    Solve 2-by-2 complex linear equation */
1674 /*                      ([T(j,j)   T(j,j+1)  ]**T-(wr-i*wi)*I)*X = SCALE*B */
1675 /*                      ([T(j+1,j) T(j+1,j+1)]               ) */
1676
1677                         r__1 = -wi;
1678                         slaln2_(&c_true, &c__2, &c__2, &smin, &c_b22, &t[j + 
1679                                 j * t_dim1], ldt, &c_b22, &c_b22, &work[j + *
1680                                 n], n, &wr, &r__1, x, &c__2, &scale, &xnorm, &
1681                                 ierr);
1682
1683 /*                    Scale if necessary */
1684
1685                         if (scale != 1.f) {
1686                             i__3 = *n - ki + 1;
1687                             sscal_(&i__3, &scale, &work[ki + *n], &c__1);
1688                             i__3 = *n - ki + 1;
1689                             sscal_(&i__3, &scale, &work[ki + n2], &c__1);
1690                         }
1691                         work[j + *n] = x[0];
1692                         work[j + n2] = x[2];
1693                         work[j + 1 + *n] = x[1];
1694                         work[j + 1 + n2] = x[3];
1695 /* Computing MAX */
1696                         r__1 = abs(x[0]), r__2 = abs(x[2]), r__1 = f2cmax(r__1,
1697                                 r__2), r__2 = abs(x[1]), r__1 = f2cmax(r__1,r__2)
1698                                 , r__2 = abs(x[3]), r__1 = f2cmax(r__1,r__2);
1699                         vmax = f2cmax(r__1,vmax);
1700                         vcrit = bignum / vmax;
1701
1702                     }
1703 L200:
1704                     ;
1705                 }
1706
1707 /*              Copy the vector x or Q*x to VL and normalize. */
1708
1709                 if (! over) {
1710                     i__2 = *n - ki + 1;
1711                     scopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is * 
1712                             vl_dim1], &c__1);
1713                     i__2 = *n - ki + 1;
1714                     scopy_(&i__2, &work[ki + n2], &c__1, &vl[ki + (is + 1) * 
1715                             vl_dim1], &c__1);
1716
1717                     emax = 0.f;
1718                     i__2 = *n;
1719                     for (k = ki; k <= i__2; ++k) {
1720 /* Computing MAX */
1721                         r__3 = emax, r__4 = (r__1 = vl[k + is * vl_dim1], abs(
1722                                 r__1)) + (r__2 = vl[k + (is + 1) * vl_dim1], 
1723                                 abs(r__2));
1724                         emax = f2cmax(r__3,r__4);
1725 /* L220: */
1726                     }
1727                     remax = 1.f / emax;
1728                     i__2 = *n - ki + 1;
1729                     sscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1);
1730                     i__2 = *n - ki + 1;
1731                     sscal_(&i__2, &remax, &vl[ki + (is + 1) * vl_dim1], &c__1)
1732                             ;
1733
1734                     i__2 = ki - 1;
1735                     for (k = 1; k <= i__2; ++k) {
1736                         vl[k + is * vl_dim1] = 0.f;
1737                         vl[k + (is + 1) * vl_dim1] = 0.f;
1738 /* L230: */
1739                     }
1740                 } else {
1741                     if (ki < *n - 1) {
1742                         i__2 = *n - ki - 1;
1743                         sgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1 
1744                                 + 1], ldvl, &work[ki + 2 + *n], &c__1, &work[
1745                                 ki + *n], &vl[ki * vl_dim1 + 1], &c__1);
1746                         i__2 = *n - ki - 1;
1747                         sgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1 
1748                                 + 1], ldvl, &work[ki + 2 + n2], &c__1, &work[
1749                                 ki + 1 + n2], &vl[(ki + 1) * vl_dim1 + 1], &
1750                                 c__1);
1751                     } else {
1752                         sscal_(n, &work[ki + *n], &vl[ki * vl_dim1 + 1], &
1753                                 c__1);
1754                         sscal_(n, &work[ki + 1 + n2], &vl[(ki + 1) * vl_dim1 
1755                                 + 1], &c__1);
1756                     }
1757
1758                     emax = 0.f;
1759                     i__2 = *n;
1760                     for (k = 1; k <= i__2; ++k) {
1761 /* Computing MAX */
1762                         r__3 = emax, r__4 = (r__1 = vl[k + ki * vl_dim1], abs(
1763                                 r__1)) + (r__2 = vl[k + (ki + 1) * vl_dim1], 
1764                                 abs(r__2));
1765                         emax = f2cmax(r__3,r__4);
1766 /* L240: */
1767                     }
1768                     remax = 1.f / emax;
1769                     sscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1);
1770                     sscal_(n, &remax, &vl[(ki + 1) * vl_dim1 + 1], &c__1);
1771
1772                 }
1773
1774             }
1775
1776             ++is;
1777             if (ip != 0) {
1778                 ++is;
1779             }
1780 L250:
1781             if (ip == -1) {
1782                 ip = 0;
1783             }
1784             if (ip == 1) {
1785                 ip = -1;
1786             }
1787
1788 /* L260: */
1789         }
1790
1791     }
1792
1793     return 0;
1794
1795 /*     End of STREVC */
1796
1797 } /* strevc_ */
1798