You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sggev3.c 33 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef int logical;
  50. typedef short int shortlogical;
  51. typedef char logical1;
  52. typedef char integer1;
  53. #define TRUE_ (1)
  54. #define FALSE_ (0)
  55. /* Extern is for use with -E */
  56. #ifndef Extern
  57. #define Extern extern
  58. #endif
  59. /* I/O stuff */
  60. typedef int flag;
  61. typedef int ftnlen;
  62. typedef int ftnint;
  63. /*external read, write*/
  64. typedef struct
  65. { flag cierr;
  66. ftnint ciunit;
  67. flag ciend;
  68. char *cifmt;
  69. ftnint cirec;
  70. } cilist;
  71. /*internal read, write*/
  72. typedef struct
  73. { flag icierr;
  74. char *iciunit;
  75. flag iciend;
  76. char *icifmt;
  77. ftnint icirlen;
  78. ftnint icirnum;
  79. } icilist;
  80. /*open*/
  81. typedef struct
  82. { flag oerr;
  83. ftnint ounit;
  84. char *ofnm;
  85. ftnlen ofnmlen;
  86. char *osta;
  87. char *oacc;
  88. char *ofm;
  89. ftnint orl;
  90. char *oblnk;
  91. } olist;
  92. /*close*/
  93. typedef struct
  94. { flag cerr;
  95. ftnint cunit;
  96. char *csta;
  97. } cllist;
  98. /*rewind, backspace, endfile*/
  99. typedef struct
  100. { flag aerr;
  101. ftnint aunit;
  102. } alist;
  103. /* inquire */
  104. typedef struct
  105. { flag inerr;
  106. ftnint inunit;
  107. char *infile;
  108. ftnlen infilen;
  109. ftnint *inex; /*parameters in standard's order*/
  110. ftnint *inopen;
  111. ftnint *innum;
  112. ftnint *innamed;
  113. char *inname;
  114. ftnlen innamlen;
  115. char *inacc;
  116. ftnlen inacclen;
  117. char *inseq;
  118. ftnlen inseqlen;
  119. char *indir;
  120. ftnlen indirlen;
  121. char *infmt;
  122. ftnlen infmtlen;
  123. char *inform;
  124. ftnint informlen;
  125. char *inunf;
  126. ftnlen inunflen;
  127. ftnint *inrecl;
  128. ftnint *innrec;
  129. char *inblank;
  130. ftnlen inblanklen;
  131. } inlist;
  132. #define VOID void
  133. union Multitype { /* for multiple entry points */
  134. integer1 g;
  135. shortint h;
  136. integer i;
  137. /* longint j; */
  138. real r;
  139. doublereal d;
  140. complex c;
  141. doublecomplex z;
  142. };
  143. typedef union Multitype Multitype;
  144. struct Vardesc { /* for Namelist */
  145. char *name;
  146. char *addr;
  147. ftnlen *dims;
  148. int type;
  149. };
  150. typedef struct Vardesc Vardesc;
  151. struct Namelist {
  152. char *name;
  153. Vardesc **vars;
  154. int nvars;
  155. };
  156. typedef struct Namelist Namelist;
  157. #define abs(x) ((x) >= 0 ? (x) : -(x))
  158. #define dabs(x) (fabs(x))
  159. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  160. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  161. #define dmin(a,b) (f2cmin(a,b))
  162. #define dmax(a,b) (f2cmax(a,b))
  163. #define bit_test(a,b) ((a) >> (b) & 1)
  164. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  165. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  166. #define abort_() { sig_die("Fortran abort routine called", 1); }
  167. #define c_abs(z) (cabsf(Cf(z)))
  168. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  169. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  170. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  171. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  172. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  173. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  174. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  175. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  176. #define d_abs(x) (fabs(*(x)))
  177. #define d_acos(x) (acos(*(x)))
  178. #define d_asin(x) (asin(*(x)))
  179. #define d_atan(x) (atan(*(x)))
  180. #define d_atn2(x, y) (atan2(*(x),*(y)))
  181. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  182. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  183. #define d_cos(x) (cos(*(x)))
  184. #define d_cosh(x) (cosh(*(x)))
  185. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  186. #define d_exp(x) (exp(*(x)))
  187. #define d_imag(z) (cimag(Cd(z)))
  188. #define r_imag(z) (cimag(Cf(z)))
  189. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  191. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  193. #define d_log(x) (log(*(x)))
  194. #define d_mod(x, y) (fmod(*(x), *(y)))
  195. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  196. #define d_nint(x) u_nint(*(x))
  197. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  198. #define d_sign(a,b) u_sign(*(a),*(b))
  199. #define r_sign(a,b) u_sign(*(a),*(b))
  200. #define d_sin(x) (sin(*(x)))
  201. #define d_sinh(x) (sinh(*(x)))
  202. #define d_sqrt(x) (sqrt(*(x)))
  203. #define d_tan(x) (tan(*(x)))
  204. #define d_tanh(x) (tanh(*(x)))
  205. #define i_abs(x) abs(*(x))
  206. #define i_dnnt(x) ((integer)u_nint(*(x)))
  207. #define i_len(s, n) (n)
  208. #define i_nint(x) ((integer)u_nint(*(x)))
  209. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  210. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  211. #define pow_si(B,E) spow_ui(*(B),*(E))
  212. #define pow_ri(B,E) spow_ui(*(B),*(E))
  213. #define pow_di(B,E) dpow_ui(*(B),*(E))
  214. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  215. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  216. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  217. #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++ = ' '; }
  218. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  219. #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]; }
  220. #define sig_die(s, kill) { exit(1); }
  221. #define s_stop(s, n) {exit(0);}
  222. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  223. #define z_abs(z) (cabs(Cd(z)))
  224. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  225. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  226. #define myexit_() break;
  227. #define mycycle() continue;
  228. #define myceiling(w) {ceil(w)}
  229. #define myhuge(w) {HUGE_VAL}
  230. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  231. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  232. /* procedure parameter types for -A and -C++ */
  233. #define F2C_proc_par_types 1
  234. #ifdef __cplusplus
  235. typedef logical (*L_fp)(...);
  236. #else
  237. typedef logical (*L_fp)();
  238. #endif
  239. static float spow_ui(float x, integer n) {
  240. float pow=1.0; unsigned long int u;
  241. if(n != 0) {
  242. if(n < 0) n = -n, x = 1/x;
  243. for(u = n; ; ) {
  244. if(u & 01) pow *= x;
  245. if(u >>= 1) x *= x;
  246. else break;
  247. }
  248. }
  249. return pow;
  250. }
  251. static double dpow_ui(double x, integer n) {
  252. double pow=1.0; unsigned long int u;
  253. if(n != 0) {
  254. if(n < 0) n = -n, x = 1/x;
  255. for(u = n; ; ) {
  256. if(u & 01) pow *= x;
  257. if(u >>= 1) x *= x;
  258. else break;
  259. }
  260. }
  261. return pow;
  262. }
  263. static _Complex float cpow_ui(_Complex float x, integer n) {
  264. _Complex float pow=1.0; unsigned long int u;
  265. if(n != 0) {
  266. if(n < 0) n = -n, x = 1/x;
  267. for(u = n; ; ) {
  268. if(u & 01) pow *= x;
  269. if(u >>= 1) x *= x;
  270. else break;
  271. }
  272. }
  273. return pow;
  274. }
  275. static _Complex double zpow_ui(_Complex double x, integer n) {
  276. _Complex double pow=1.0; unsigned long int u;
  277. if(n != 0) {
  278. if(n < 0) n = -n, x = 1/x;
  279. for(u = n; ; ) {
  280. if(u & 01) pow *= x;
  281. if(u >>= 1) x *= x;
  282. else break;
  283. }
  284. }
  285. return pow;
  286. }
  287. static integer pow_ii(integer x, integer n) {
  288. integer pow; unsigned long int u;
  289. if (n <= 0) {
  290. if (n == 0 || x == 1) pow = 1;
  291. else if (x != -1) pow = x == 0 ? 1/x : 0;
  292. else n = -n;
  293. }
  294. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  295. u = n;
  296. for(pow = 1; ; ) {
  297. if(u & 01) pow *= x;
  298. if(u >>= 1) x *= x;
  299. else break;
  300. }
  301. }
  302. return pow;
  303. }
  304. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  305. {
  306. double m; integer i, mi;
  307. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  308. if (w[i-1]>m) mi=i ,m=w[i-1];
  309. return mi-s+1;
  310. }
  311. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  312. {
  313. float m; integer i, mi;
  314. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  315. if (w[i-1]>m) mi=i ,m=w[i-1];
  316. return mi-s+1;
  317. }
  318. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  319. integer n = *n_, incx = *incx_, incy = *incy_, i;
  320. _Complex float zdotc = 0.0;
  321. if (incx == 1 && incy == 1) {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  324. }
  325. } else {
  326. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  327. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  328. }
  329. }
  330. pCf(z) = zdotc;
  331. }
  332. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  333. integer n = *n_, incx = *incx_, incy = *incy_, i;
  334. _Complex double zdotc = 0.0;
  335. if (incx == 1 && incy == 1) {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  338. }
  339. } else {
  340. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  341. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  342. }
  343. }
  344. pCd(z) = zdotc;
  345. }
  346. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  347. integer n = *n_, incx = *incx_, incy = *incy_, i;
  348. _Complex float zdotc = 0.0;
  349. if (incx == 1 && incy == 1) {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cf(&x[i]) * Cf(&y[i]);
  352. }
  353. } else {
  354. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  355. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  356. }
  357. }
  358. pCf(z) = zdotc;
  359. }
  360. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  361. integer n = *n_, incx = *incx_, incy = *incy_, i;
  362. _Complex double zdotc = 0.0;
  363. if (incx == 1 && incy == 1) {
  364. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  365. zdotc += Cd(&x[i]) * Cd(&y[i]);
  366. }
  367. } else {
  368. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  369. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  370. }
  371. }
  372. pCd(z) = zdotc;
  373. }
  374. #endif
  375. /* -- translated by f2c (version 20000121).
  376. You must link the resulting object file with the libraries:
  377. -lf2c -lm (in that order)
  378. */
  379. /* Table of constant values */
  380. static integer c_n1 = -1;
  381. static integer c__1 = 1;
  382. static integer c__0 = 0;
  383. static real c_b34 = 0.f;
  384. static real c_b35 = 1.f;
  385. /* > \brief <b> SGGEV3 computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE mat
  386. rices (blocked algorithm)</b> */
  387. /* =========== DOCUMENTATION =========== */
  388. /* Online html documentation available at */
  389. /* http://www.netlib.org/lapack/explore-html/ */
  390. /* > \htmlonly */
  391. /* > Download SGGEV3 + dependencies */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sggev3.
  393. f"> */
  394. /* > [TGZ]</a> */
  395. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sggev3.
  396. f"> */
  397. /* > [ZIP]</a> */
  398. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sggev3.
  399. f"> */
  400. /* > [TXT]</a> */
  401. /* > \endhtmlonly */
  402. /* Definition: */
  403. /* =========== */
  404. /* SUBROUTINE SGGEV3( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR, */
  405. /* $ ALPHAI, BETA, VL, LDVL, VR, LDVR, WORK, LWORK, */
  406. /* $ INFO ) */
  407. /* CHARACTER JOBVL, JOBVR */
  408. /* INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N */
  409. /* REAL A( LDA, * ), ALPHAI( * ), ALPHAR( * ), */
  410. /* $ B( LDB, * ), BETA( * ), VL( LDVL, * ), */
  411. /* $ VR( LDVR, * ), WORK( * ) */
  412. /* > \par Purpose: */
  413. /* ============= */
  414. /* > */
  415. /* > \verbatim */
  416. /* > */
  417. /* > SGGEV3 computes for a pair of N-by-N real nonsymmetric matrices (A,B) */
  418. /* > the generalized eigenvalues, and optionally, the left and/or right */
  419. /* > generalized eigenvectors. */
  420. /* > */
  421. /* > A generalized eigenvalue for a pair of matrices (A,B) is a scalar */
  422. /* > lambda or a ratio alpha/beta = lambda, such that A - lambda*B is */
  423. /* > singular. It is usually represented as the pair (alpha,beta), as */
  424. /* > there is a reasonable interpretation for beta=0, and even for both */
  425. /* > being zero. */
  426. /* > */
  427. /* > The right eigenvector v(j) corresponding to the eigenvalue lambda(j) */
  428. /* > of (A,B) satisfies */
  429. /* > */
  430. /* > A * v(j) = lambda(j) * B * v(j). */
  431. /* > */
  432. /* > The left eigenvector u(j) corresponding to the eigenvalue lambda(j) */
  433. /* > of (A,B) satisfies */
  434. /* > */
  435. /* > u(j)**H * A = lambda(j) * u(j)**H * B . */
  436. /* > */
  437. /* > where u(j)**H is the conjugate-transpose of u(j). */
  438. /* > */
  439. /* > \endverbatim */
  440. /* Arguments: */
  441. /* ========== */
  442. /* > \param[in] JOBVL */
  443. /* > \verbatim */
  444. /* > JOBVL is CHARACTER*1 */
  445. /* > = 'N': do not compute the left generalized eigenvectors; */
  446. /* > = 'V': compute the left generalized eigenvectors. */
  447. /* > \endverbatim */
  448. /* > */
  449. /* > \param[in] JOBVR */
  450. /* > \verbatim */
  451. /* > JOBVR is CHARACTER*1 */
  452. /* > = 'N': do not compute the right generalized eigenvectors; */
  453. /* > = 'V': compute the right generalized eigenvectors. */
  454. /* > \endverbatim */
  455. /* > */
  456. /* > \param[in] N */
  457. /* > \verbatim */
  458. /* > N is INTEGER */
  459. /* > The order of the matrices A, B, VL, and VR. N >= 0. */
  460. /* > \endverbatim */
  461. /* > */
  462. /* > \param[in,out] A */
  463. /* > \verbatim */
  464. /* > A is REAL array, dimension (LDA, N) */
  465. /* > On entry, the matrix A in the pair (A,B). */
  466. /* > On exit, A has been overwritten. */
  467. /* > \endverbatim */
  468. /* > */
  469. /* > \param[in] LDA */
  470. /* > \verbatim */
  471. /* > LDA is INTEGER */
  472. /* > The leading dimension of A. LDA >= f2cmax(1,N). */
  473. /* > \endverbatim */
  474. /* > */
  475. /* > \param[in,out] B */
  476. /* > \verbatim */
  477. /* > B is REAL array, dimension (LDB, N) */
  478. /* > On entry, the matrix B in the pair (A,B). */
  479. /* > On exit, B has been overwritten. */
  480. /* > \endverbatim */
  481. /* > */
  482. /* > \param[in] LDB */
  483. /* > \verbatim */
  484. /* > LDB is INTEGER */
  485. /* > The leading dimension of B. LDB >= f2cmax(1,N). */
  486. /* > \endverbatim */
  487. /* > */
  488. /* > \param[out] ALPHAR */
  489. /* > \verbatim */
  490. /* > ALPHAR is REAL array, dimension (N) */
  491. /* > \endverbatim */
  492. /* > */
  493. /* > \param[out] ALPHAI */
  494. /* > \verbatim */
  495. /* > ALPHAI is REAL array, dimension (N) */
  496. /* > \endverbatim */
  497. /* > */
  498. /* > \param[out] BETA */
  499. /* > \verbatim */
  500. /* > BETA is REAL array, dimension (N) */
  501. /* > On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */
  502. /* > be the generalized eigenvalues. If ALPHAI(j) is zero, then */
  503. /* > the j-th eigenvalue is real; if positive, then the j-th and */
  504. /* > (j+1)-st eigenvalues are a complex conjugate pair, with */
  505. /* > ALPHAI(j+1) negative. */
  506. /* > */
  507. /* > Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */
  508. /* > may easily over- or underflow, and BETA(j) may even be zero. */
  509. /* > Thus, the user should avoid naively computing the ratio */
  510. /* > alpha/beta. However, ALPHAR and ALPHAI will be always less */
  511. /* > than and usually comparable with norm(A) in magnitude, and */
  512. /* > BETA always less than and usually comparable with norm(B). */
  513. /* > \endverbatim */
  514. /* > */
  515. /* > \param[out] VL */
  516. /* > \verbatim */
  517. /* > VL is REAL array, dimension (LDVL,N) */
  518. /* > If JOBVL = 'V', the left eigenvectors u(j) are stored one */
  519. /* > after another in the columns of VL, in the same order as */
  520. /* > their eigenvalues. If the j-th eigenvalue is real, then */
  521. /* > u(j) = VL(:,j), the j-th column of VL. If the j-th and */
  522. /* > (j+1)-th eigenvalues form a complex conjugate pair, then */
  523. /* > u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1). */
  524. /* > Each eigenvector is scaled so the largest component has */
  525. /* > abs(real part)+abs(imag. part)=1. */
  526. /* > Not referenced if JOBVL = 'N'. */
  527. /* > \endverbatim */
  528. /* > */
  529. /* > \param[in] LDVL */
  530. /* > \verbatim */
  531. /* > LDVL is INTEGER */
  532. /* > The leading dimension of the matrix VL. LDVL >= 1, and */
  533. /* > if JOBVL = 'V', LDVL >= N. */
  534. /* > \endverbatim */
  535. /* > */
  536. /* > \param[out] VR */
  537. /* > \verbatim */
  538. /* > VR is REAL array, dimension (LDVR,N) */
  539. /* > If JOBVR = 'V', the right eigenvectors v(j) are stored one */
  540. /* > after another in the columns of VR, in the same order as */
  541. /* > their eigenvalues. If the j-th eigenvalue is real, then */
  542. /* > v(j) = VR(:,j), the j-th column of VR. If the j-th and */
  543. /* > (j+1)-th eigenvalues form a complex conjugate pair, then */
  544. /* > v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1). */
  545. /* > Each eigenvector is scaled so the largest component has */
  546. /* > abs(real part)+abs(imag. part)=1. */
  547. /* > Not referenced if JOBVR = 'N'. */
  548. /* > \endverbatim */
  549. /* > */
  550. /* > \param[in] LDVR */
  551. /* > \verbatim */
  552. /* > LDVR is INTEGER */
  553. /* > The leading dimension of the matrix VR. LDVR >= 1, and */
  554. /* > if JOBVR = 'V', LDVR >= N. */
  555. /* > \endverbatim */
  556. /* > */
  557. /* > \param[out] WORK */
  558. /* > \verbatim */
  559. /* > WORK is REAL array, dimension (MAX(1,LWORK)) */
  560. /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  561. /* > \endverbatim */
  562. /* > */
  563. /* > \param[in] LWORK */
  564. /* > \verbatim */
  565. /* > LWORK is INTEGER */
  566. /* > */
  567. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  568. /* > only calculates the optimal size of the WORK array, returns */
  569. /* > this value as the first entry of the WORK array, and no error */
  570. /* > message related to LWORK is issued by XERBLA. */
  571. /* > \endverbatim */
  572. /* > */
  573. /* > \param[out] INFO */
  574. /* > \verbatim */
  575. /* > INFO is INTEGER */
  576. /* > = 0: successful exit */
  577. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  578. /* > = 1,...,N: */
  579. /* > The QZ iteration failed. No eigenvectors have been */
  580. /* > calculated, but ALPHAR(j), ALPHAI(j), and BETA(j) */
  581. /* > should be correct for j=INFO+1,...,N. */
  582. /* > > N: =N+1: other than QZ iteration failed in SHGEQZ. */
  583. /* > =N+2: error return from STGEVC. */
  584. /* > \endverbatim */
  585. /* Authors: */
  586. /* ======== */
  587. /* > \author Univ. of Tennessee */
  588. /* > \author Univ. of California Berkeley */
  589. /* > \author Univ. of Colorado Denver */
  590. /* > \author NAG Ltd. */
  591. /* > \date January 2015 */
  592. /* > \ingroup realGEeigen */
  593. /* ===================================================================== */
  594. /* Subroutine */ int sggev3_(char *jobvl, char *jobvr, integer *n, real *a,
  595. integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real
  596. *beta, real *vl, integer *ldvl, real *vr, integer *ldvr, real *work,
  597. integer *lwork, integer *info)
  598. {
  599. /* System generated locals */
  600. integer a_dim1, a_offset, b_dim1, b_offset, vl_dim1, vl_offset, vr_dim1,
  601. vr_offset, i__1, i__2;
  602. real r__1, r__2, r__3, r__4;
  603. /* Local variables */
  604. real anrm, bnrm;
  605. integer ierr, itau;
  606. real temp;
  607. logical ilvl, ilvr;
  608. integer iwrk;
  609. extern logical lsame_(char *, char *);
  610. integer ileft, icols, irows;
  611. extern /* Subroutine */ int sgghd3_(char *, char *, integer *, integer *,
  612. integer *, real *, integer *, real *, integer *, real *, integer *
  613. , real *, integer *, real *, integer *, integer *)
  614. ;
  615. integer jc;
  616. extern /* Subroutine */ int slabad_(real *, real *);
  617. integer in, jr;
  618. extern /* Subroutine */ int sggbak_(char *, char *, integer *, integer *,
  619. integer *, real *, real *, integer *, real *, integer *, integer *
  620. ), sggbal_(char *, integer *, real *, integer *,
  621. real *, integer *, integer *, integer *, real *, real *, real *,
  622. integer *);
  623. logical ilascl, ilbscl;
  624. extern real slamch_(char *), slange_(char *, integer *, integer *,
  625. real *, integer *, real *);
  626. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  627. logical ldumma[1];
  628. char chtemp[1];
  629. real bignum;
  630. extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *,
  631. real *, integer *, integer *, real *, integer *, integer *);
  632. integer ijobvl, iright;
  633. extern /* Subroutine */ int sgeqrf_(integer *, integer *, real *, integer
  634. *, real *, real *, integer *, integer *);
  635. integer ijobvr;
  636. extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *,
  637. integer *, real *, integer *), slaset_(char *, integer *,
  638. integer *, real *, real *, real *, integer *), stgevc_(
  639. char *, char *, logical *, integer *, real *, integer *, real *,
  640. integer *, real *, integer *, real *, integer *, integer *,
  641. integer *, real *, integer *);
  642. real anrmto, bnrmto;
  643. extern /* Subroutine */ int shgeqz_(char *, char *, char *, integer *,
  644. integer *, integer *, real *, integer *, real *, integer *, real *
  645. , real *, real *, real *, integer *, real *, integer *, real *,
  646. integer *, integer *);
  647. real smlnum;
  648. extern /* Subroutine */ int sorgqr_(integer *, integer *, integer *, real
  649. *, integer *, real *, real *, integer *, integer *);
  650. integer lwkopt;
  651. logical lquery;
  652. extern /* Subroutine */ int sormqr_(char *, char *, integer *, integer *,
  653. integer *, real *, integer *, real *, real *, integer *, real *,
  654. integer *, integer *);
  655. integer ihi, ilo;
  656. real eps;
  657. logical ilv;
  658. /* -- LAPACK driver routine (version 3.6.0) -- */
  659. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  660. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  661. /* January 2015 */
  662. /* ===================================================================== */
  663. /* Decode the input arguments */
  664. /* Parameter adjustments */
  665. a_dim1 = *lda;
  666. a_offset = 1 + a_dim1 * 1;
  667. a -= a_offset;
  668. b_dim1 = *ldb;
  669. b_offset = 1 + b_dim1 * 1;
  670. b -= b_offset;
  671. --alphar;
  672. --alphai;
  673. --beta;
  674. vl_dim1 = *ldvl;
  675. vl_offset = 1 + vl_dim1 * 1;
  676. vl -= vl_offset;
  677. vr_dim1 = *ldvr;
  678. vr_offset = 1 + vr_dim1 * 1;
  679. vr -= vr_offset;
  680. --work;
  681. /* Function Body */
  682. if (lsame_(jobvl, "N")) {
  683. ijobvl = 1;
  684. ilvl = FALSE_;
  685. } else if (lsame_(jobvl, "V")) {
  686. ijobvl = 2;
  687. ilvl = TRUE_;
  688. } else {
  689. ijobvl = -1;
  690. ilvl = FALSE_;
  691. }
  692. if (lsame_(jobvr, "N")) {
  693. ijobvr = 1;
  694. ilvr = FALSE_;
  695. } else if (lsame_(jobvr, "V")) {
  696. ijobvr = 2;
  697. ilvr = TRUE_;
  698. } else {
  699. ijobvr = -1;
  700. ilvr = FALSE_;
  701. }
  702. ilv = ilvl || ilvr;
  703. /* Test the input arguments */
  704. *info = 0;
  705. lquery = *lwork == -1;
  706. if (ijobvl <= 0) {
  707. *info = -1;
  708. } else if (ijobvr <= 0) {
  709. *info = -2;
  710. } else if (*n < 0) {
  711. *info = -3;
  712. } else if (*lda < f2cmax(1,*n)) {
  713. *info = -5;
  714. } else if (*ldb < f2cmax(1,*n)) {
  715. *info = -7;
  716. } else if (*ldvl < 1 || ilvl && *ldvl < *n) {
  717. *info = -12;
  718. } else if (*ldvr < 1 || ilvr && *ldvr < *n) {
  719. *info = -14;
  720. } else /* if(complicated condition) */ {
  721. /* Computing MAX */
  722. i__1 = 1, i__2 = *n << 3;
  723. if (*lwork < f2cmax(i__1,i__2) && ! lquery) {
  724. *info = -16;
  725. }
  726. }
  727. /* Compute workspace */
  728. if (*info == 0) {
  729. sgeqrf_(n, n, &b[b_offset], ldb, &work[1], &work[1], &c_n1, &ierr);
  730. /* Computing MAX */
  731. i__1 = 1, i__2 = *n << 3, i__1 = f2cmax(i__1,i__2), i__2 = *n * 3 + (
  732. integer) work[1];
  733. lwkopt = f2cmax(i__1,i__2);
  734. sormqr_("L", "T", n, n, n, &b[b_offset], ldb, &work[1], &a[a_offset],
  735. lda, &work[1], &c_n1, &ierr);
  736. /* Computing MAX */
  737. i__1 = lwkopt, i__2 = *n * 3 + (integer) work[1];
  738. lwkopt = f2cmax(i__1,i__2);
  739. sgghd3_(jobvl, jobvr, n, &c__1, n, &a[a_offset], lda, &b[b_offset],
  740. ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &work[1], &
  741. c_n1, &ierr);
  742. /* Computing MAX */
  743. i__1 = lwkopt, i__2 = *n * 3 + (integer) work[1];
  744. lwkopt = f2cmax(i__1,i__2);
  745. if (ilvl) {
  746. sorgqr_(n, n, n, &vl[vl_offset], ldvl, &work[1], &work[1], &c_n1,
  747. &ierr);
  748. /* Computing MAX */
  749. i__1 = lwkopt, i__2 = *n * 3 + (integer) work[1];
  750. lwkopt = f2cmax(i__1,i__2);
  751. shgeqz_("S", jobvl, jobvr, n, &c__1, n, &a[a_offset], lda, &b[
  752. b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[
  753. vl_offset], ldvl, &vr[vr_offset], ldvr, &work[1], &c_n1, &
  754. ierr);
  755. /* Computing MAX */
  756. i__1 = lwkopt, i__2 = (*n << 1) + (integer) work[1];
  757. lwkopt = f2cmax(i__1,i__2);
  758. } else {
  759. shgeqz_("E", jobvl, jobvr, n, &c__1, n, &a[a_offset], lda, &b[
  760. b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[
  761. vl_offset], ldvl, &vr[vr_offset], ldvr, &work[1], &c_n1, &
  762. ierr);
  763. /* Computing MAX */
  764. i__1 = lwkopt, i__2 = (*n << 1) + (integer) work[1];
  765. lwkopt = f2cmax(i__1,i__2);
  766. }
  767. work[1] = (real) lwkopt;
  768. }
  769. if (*info != 0) {
  770. i__1 = -(*info);
  771. xerbla_("SGGEV3 ", &i__1, (ftnlen)7);
  772. return 0;
  773. } else if (lquery) {
  774. return 0;
  775. }
  776. /* Quick return if possible */
  777. if (*n == 0) {
  778. return 0;
  779. }
  780. /* Get machine constants */
  781. eps = slamch_("P");
  782. smlnum = slamch_("S");
  783. bignum = 1.f / smlnum;
  784. slabad_(&smlnum, &bignum);
  785. smlnum = sqrt(smlnum) / eps;
  786. bignum = 1.f / smlnum;
  787. /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */
  788. anrm = slange_("M", n, n, &a[a_offset], lda, &work[1]);
  789. ilascl = FALSE_;
  790. if (anrm > 0.f && anrm < smlnum) {
  791. anrmto = smlnum;
  792. ilascl = TRUE_;
  793. } else if (anrm > bignum) {
  794. anrmto = bignum;
  795. ilascl = TRUE_;
  796. }
  797. if (ilascl) {
  798. slascl_("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, &
  799. ierr);
  800. }
  801. /* Scale B if f2cmax element outside range [SMLNUM,BIGNUM] */
  802. bnrm = slange_("M", n, n, &b[b_offset], ldb, &work[1]);
  803. ilbscl = FALSE_;
  804. if (bnrm > 0.f && bnrm < smlnum) {
  805. bnrmto = smlnum;
  806. ilbscl = TRUE_;
  807. } else if (bnrm > bignum) {
  808. bnrmto = bignum;
  809. ilbscl = TRUE_;
  810. }
  811. if (ilbscl) {
  812. slascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, &
  813. ierr);
  814. }
  815. /* Permute the matrices A, B to isolate eigenvalues if possible */
  816. ileft = 1;
  817. iright = *n + 1;
  818. iwrk = iright + *n;
  819. sggbal_("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[
  820. ileft], &work[iright], &work[iwrk], &ierr);
  821. /* Reduce B to triangular form (QR decomposition of B) */
  822. irows = ihi + 1 - ilo;
  823. if (ilv) {
  824. icols = *n + 1 - ilo;
  825. } else {
  826. icols = irows;
  827. }
  828. itau = iwrk;
  829. iwrk = itau + irows;
  830. i__1 = *lwork + 1 - iwrk;
  831. sgeqrf_(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[
  832. iwrk], &i__1, &ierr);
  833. /* Apply the orthogonal transformation to matrix A */
  834. i__1 = *lwork + 1 - iwrk;
  835. sormqr_("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, &
  836. work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, &
  837. ierr);
  838. /* Initialize VL */
  839. if (ilvl) {
  840. slaset_("Full", n, n, &c_b34, &c_b35, &vl[vl_offset], ldvl)
  841. ;
  842. if (irows > 1) {
  843. i__1 = irows - 1;
  844. i__2 = irows - 1;
  845. slacpy_("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vl[
  846. ilo + 1 + ilo * vl_dim1], ldvl);
  847. }
  848. i__1 = *lwork + 1 - iwrk;
  849. sorgqr_(&irows, &irows, &irows, &vl[ilo + ilo * vl_dim1], ldvl, &work[
  850. itau], &work[iwrk], &i__1, &ierr);
  851. }
  852. /* Initialize VR */
  853. if (ilvr) {
  854. slaset_("Full", n, n, &c_b34, &c_b35, &vr[vr_offset], ldvr)
  855. ;
  856. }
  857. /* Reduce to generalized Hessenberg form */
  858. if (ilv) {
  859. /* Eigenvectors requested -- work on whole matrix. */
  860. i__1 = *lwork + 1 - iwrk;
  861. sgghd3_(jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset],
  862. ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &work[iwrk],
  863. &i__1, &ierr);
  864. } else {
  865. i__1 = *lwork + 1 - iwrk;
  866. sgghd3_("N", "N", &irows, &c__1, &irows, &a[ilo + ilo * a_dim1], lda,
  867. &b[ilo + ilo * b_dim1], ldb, &vl[vl_offset], ldvl, &vr[
  868. vr_offset], ldvr, &work[iwrk], &i__1, &ierr);
  869. }
  870. /* Perform QZ algorithm (Compute eigenvalues, and optionally, the */
  871. /* Schur forms and Schur vectors) */
  872. iwrk = itau;
  873. if (ilv) {
  874. *(unsigned char *)chtemp = 'S';
  875. } else {
  876. *(unsigned char *)chtemp = 'E';
  877. }
  878. i__1 = *lwork + 1 - iwrk;
  879. shgeqz_(chtemp, jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[
  880. b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[vl_offset],
  881. ldvl, &vr[vr_offset], ldvr, &work[iwrk], &i__1, &ierr);
  882. if (ierr != 0) {
  883. if (ierr > 0 && ierr <= *n) {
  884. *info = ierr;
  885. } else if (ierr > *n && ierr <= *n << 1) {
  886. *info = ierr - *n;
  887. } else {
  888. *info = *n + 1;
  889. }
  890. goto L110;
  891. }
  892. /* Compute Eigenvectors */
  893. if (ilv) {
  894. if (ilvl) {
  895. if (ilvr) {
  896. *(unsigned char *)chtemp = 'B';
  897. } else {
  898. *(unsigned char *)chtemp = 'L';
  899. }
  900. } else {
  901. *(unsigned char *)chtemp = 'R';
  902. }
  903. stgevc_(chtemp, "B", ldumma, n, &a[a_offset], lda, &b[b_offset], ldb,
  904. &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, n, &in, &work[
  905. iwrk], &ierr);
  906. if (ierr != 0) {
  907. *info = *n + 2;
  908. goto L110;
  909. }
  910. /* Undo balancing on VL and VR and normalization */
  911. if (ilvl) {
  912. sggbak_("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, &
  913. vl[vl_offset], ldvl, &ierr);
  914. i__1 = *n;
  915. for (jc = 1; jc <= i__1; ++jc) {
  916. if (alphai[jc] < 0.f) {
  917. goto L50;
  918. }
  919. temp = 0.f;
  920. if (alphai[jc] == 0.f) {
  921. i__2 = *n;
  922. for (jr = 1; jr <= i__2; ++jr) {
  923. /* Computing MAX */
  924. r__2 = temp, r__3 = (r__1 = vl[jr + jc * vl_dim1],
  925. abs(r__1));
  926. temp = f2cmax(r__2,r__3);
  927. /* L10: */
  928. }
  929. } else {
  930. i__2 = *n;
  931. for (jr = 1; jr <= i__2; ++jr) {
  932. /* Computing MAX */
  933. r__3 = temp, r__4 = (r__1 = vl[jr + jc * vl_dim1],
  934. abs(r__1)) + (r__2 = vl[jr + (jc + 1) *
  935. vl_dim1], abs(r__2));
  936. temp = f2cmax(r__3,r__4);
  937. /* L20: */
  938. }
  939. }
  940. if (temp < smlnum) {
  941. goto L50;
  942. }
  943. temp = 1.f / temp;
  944. if (alphai[jc] == 0.f) {
  945. i__2 = *n;
  946. for (jr = 1; jr <= i__2; ++jr) {
  947. vl[jr + jc * vl_dim1] *= temp;
  948. /* L30: */
  949. }
  950. } else {
  951. i__2 = *n;
  952. for (jr = 1; jr <= i__2; ++jr) {
  953. vl[jr + jc * vl_dim1] *= temp;
  954. vl[jr + (jc + 1) * vl_dim1] *= temp;
  955. /* L40: */
  956. }
  957. }
  958. L50:
  959. ;
  960. }
  961. }
  962. if (ilvr) {
  963. sggbak_("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, &
  964. vr[vr_offset], ldvr, &ierr);
  965. i__1 = *n;
  966. for (jc = 1; jc <= i__1; ++jc) {
  967. if (alphai[jc] < 0.f) {
  968. goto L100;
  969. }
  970. temp = 0.f;
  971. if (alphai[jc] == 0.f) {
  972. i__2 = *n;
  973. for (jr = 1; jr <= i__2; ++jr) {
  974. /* Computing MAX */
  975. r__2 = temp, r__3 = (r__1 = vr[jr + jc * vr_dim1],
  976. abs(r__1));
  977. temp = f2cmax(r__2,r__3);
  978. /* L60: */
  979. }
  980. } else {
  981. i__2 = *n;
  982. for (jr = 1; jr <= i__2; ++jr) {
  983. /* Computing MAX */
  984. r__3 = temp, r__4 = (r__1 = vr[jr + jc * vr_dim1],
  985. abs(r__1)) + (r__2 = vr[jr + (jc + 1) *
  986. vr_dim1], abs(r__2));
  987. temp = f2cmax(r__3,r__4);
  988. /* L70: */
  989. }
  990. }
  991. if (temp < smlnum) {
  992. goto L100;
  993. }
  994. temp = 1.f / temp;
  995. if (alphai[jc] == 0.f) {
  996. i__2 = *n;
  997. for (jr = 1; jr <= i__2; ++jr) {
  998. vr[jr + jc * vr_dim1] *= temp;
  999. /* L80: */
  1000. }
  1001. } else {
  1002. i__2 = *n;
  1003. for (jr = 1; jr <= i__2; ++jr) {
  1004. vr[jr + jc * vr_dim1] *= temp;
  1005. vr[jr + (jc + 1) * vr_dim1] *= temp;
  1006. /* L90: */
  1007. }
  1008. }
  1009. L100:
  1010. ;
  1011. }
  1012. }
  1013. /* End of eigenvector calculation */
  1014. }
  1015. /* Undo scaling if necessary */
  1016. L110:
  1017. if (ilascl) {
  1018. slascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, &
  1019. ierr);
  1020. slascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, &
  1021. ierr);
  1022. }
  1023. if (ilbscl) {
  1024. slascl_("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, &
  1025. ierr);
  1026. }
  1027. work[1] = (real) lwkopt;
  1028. return 0;
  1029. /* End of SGGEV3 */
  1030. } /* sggev3_ */