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.

sgeevx.c 34 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef blasint logical;
  52. typedef char logical1;
  53. typedef char integer1;
  54. #define TRUE_ (1)
  55. #define FALSE_ (0)
  56. /* Extern is for use with -E */
  57. #ifndef Extern
  58. #define Extern extern
  59. #endif
  60. /* I/O stuff */
  61. typedef int flag;
  62. typedef int ftnlen;
  63. typedef int ftnint;
  64. /*external read, write*/
  65. typedef struct
  66. { flag cierr;
  67. ftnint ciunit;
  68. flag ciend;
  69. char *cifmt;
  70. ftnint cirec;
  71. } cilist;
  72. /*internal read, write*/
  73. typedef struct
  74. { flag icierr;
  75. char *iciunit;
  76. flag iciend;
  77. char *icifmt;
  78. ftnint icirlen;
  79. ftnint icirnum;
  80. } icilist;
  81. /*open*/
  82. typedef struct
  83. { flag oerr;
  84. ftnint ounit;
  85. char *ofnm;
  86. ftnlen ofnmlen;
  87. char *osta;
  88. char *oacc;
  89. char *ofm;
  90. ftnint orl;
  91. char *oblnk;
  92. } olist;
  93. /*close*/
  94. typedef struct
  95. { flag cerr;
  96. ftnint cunit;
  97. char *csta;
  98. } cllist;
  99. /*rewind, backspace, endfile*/
  100. typedef struct
  101. { flag aerr;
  102. ftnint aunit;
  103. } alist;
  104. /* inquire */
  105. typedef struct
  106. { flag inerr;
  107. ftnint inunit;
  108. char *infile;
  109. ftnlen infilen;
  110. ftnint *inex; /*parameters in standard's order*/
  111. ftnint *inopen;
  112. ftnint *innum;
  113. ftnint *innamed;
  114. char *inname;
  115. ftnlen innamlen;
  116. char *inacc;
  117. ftnlen inacclen;
  118. char *inseq;
  119. ftnlen inseqlen;
  120. char *indir;
  121. ftnlen indirlen;
  122. char *infmt;
  123. ftnlen infmtlen;
  124. char *inform;
  125. ftnint informlen;
  126. char *inunf;
  127. ftnlen inunflen;
  128. ftnint *inrecl;
  129. ftnint *innrec;
  130. char *inblank;
  131. ftnlen inblanklen;
  132. } inlist;
  133. #define VOID void
  134. union Multitype { /* for multiple entry points */
  135. integer1 g;
  136. shortint h;
  137. integer i;
  138. /* longint j; */
  139. real r;
  140. doublereal d;
  141. complex c;
  142. doublecomplex z;
  143. };
  144. typedef union Multitype Multitype;
  145. struct Vardesc { /* for Namelist */
  146. char *name;
  147. char *addr;
  148. ftnlen *dims;
  149. int type;
  150. };
  151. typedef struct Vardesc Vardesc;
  152. struct Namelist {
  153. char *name;
  154. Vardesc **vars;
  155. int nvars;
  156. };
  157. typedef struct Namelist Namelist;
  158. #define abs(x) ((x) >= 0 ? (x) : -(x))
  159. #define dabs(x) (fabs(x))
  160. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  161. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  162. #define dmin(a,b) (f2cmin(a,b))
  163. #define dmax(a,b) (f2cmax(a,b))
  164. #define bit_test(a,b) ((a) >> (b) & 1)
  165. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  166. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  167. #define abort_() { sig_die("Fortran abort routine called", 1); }
  168. #define c_abs(z) (cabsf(Cf(z)))
  169. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  170. #ifdef _MSC_VER
  171. #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]);}
  172. #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]);}
  173. #else
  174. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  175. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  176. #endif
  177. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  178. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  179. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  180. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  181. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  182. #define d_abs(x) (fabs(*(x)))
  183. #define d_acos(x) (acos(*(x)))
  184. #define d_asin(x) (asin(*(x)))
  185. #define d_atan(x) (atan(*(x)))
  186. #define d_atn2(x, y) (atan2(*(x),*(y)))
  187. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  188. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  189. #define d_cos(x) (cos(*(x)))
  190. #define d_cosh(x) (cosh(*(x)))
  191. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  192. #define d_exp(x) (exp(*(x)))
  193. #define d_imag(z) (cimag(Cd(z)))
  194. #define r_imag(z) (cimagf(Cf(z)))
  195. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  196. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  198. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define d_log(x) (log(*(x)))
  200. #define d_mod(x, y) (fmod(*(x), *(y)))
  201. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  202. #define d_nint(x) u_nint(*(x))
  203. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  204. #define d_sign(a,b) u_sign(*(a),*(b))
  205. #define r_sign(a,b) u_sign(*(a),*(b))
  206. #define d_sin(x) (sin(*(x)))
  207. #define d_sinh(x) (sinh(*(x)))
  208. #define d_sqrt(x) (sqrt(*(x)))
  209. #define d_tan(x) (tan(*(x)))
  210. #define d_tanh(x) (tanh(*(x)))
  211. #define i_abs(x) abs(*(x))
  212. #define i_dnnt(x) ((integer)u_nint(*(x)))
  213. #define i_len(s, n) (n)
  214. #define i_nint(x) ((integer)u_nint(*(x)))
  215. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  216. #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++ = ' '; }
  217. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  218. #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]; }
  219. #define sig_die(s, kill) { exit(1); }
  220. #define s_stop(s, n) {exit(0);}
  221. #define z_abs(z) (cabs(Cd(z)))
  222. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  223. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  224. #define myexit_() break;
  225. #define mycycle() continue;
  226. #define myceiling(w) {ceil(w)}
  227. #define myhuge(w) {HUGE_VAL}
  228. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  229. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  230. /* -- translated by f2c (version 20000121).
  231. You must link the resulting object file with the libraries:
  232. -lf2c -lm (in that order)
  233. */
  234. /* Table of constant values */
  235. static integer c__1 = 1;
  236. static integer c__0 = 0;
  237. static integer c_n1 = -1;
  238. /* > \brief <b> SGEEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE mat
  239. rices</b> */
  240. /* =========== DOCUMENTATION =========== */
  241. /* Online html documentation available at */
  242. /* http://www.netlib.org/lapack/explore-html/ */
  243. /* > \htmlonly */
  244. /* > Download SGEEVX + dependencies */
  245. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeevx.
  246. f"> */
  247. /* > [TGZ]</a> */
  248. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeevx.
  249. f"> */
  250. /* > [ZIP]</a> */
  251. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeevx.
  252. f"> */
  253. /* > [TXT]</a> */
  254. /* > \endhtmlonly */
  255. /* Definition: */
  256. /* =========== */
  257. /* SUBROUTINE SGEEVX( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, WR, WI, */
  258. /* VL, LDVL, VR, LDVR, ILO, IHI, SCALE, ABNRM, */
  259. /* RCONDE, RCONDV, WORK, LWORK, IWORK, INFO ) */
  260. /* CHARACTER BALANC, JOBVL, JOBVR, SENSE */
  261. /* INTEGER IHI, ILO, INFO, LDA, LDVL, LDVR, LWORK, N */
  262. /* REAL ABNRM */
  263. /* INTEGER IWORK( * ) */
  264. /* REAL A( LDA, * ), RCONDE( * ), RCONDV( * ), */
  265. /* $ SCALE( * ), VL( LDVL, * ), VR( LDVR, * ), */
  266. /* $ WI( * ), WORK( * ), WR( * ) */
  267. /* > \par Purpose: */
  268. /* ============= */
  269. /* > */
  270. /* > \verbatim */
  271. /* > */
  272. /* > SGEEVX computes for an N-by-N real nonsymmetric matrix A, the */
  273. /* > eigenvalues and, optionally, the left and/or right eigenvectors. */
  274. /* > */
  275. /* > Optionally also, it computes a balancing transformation to improve */
  276. /* > the conditioning of the eigenvalues and eigenvectors (ILO, IHI, */
  277. /* > SCALE, and ABNRM), reciprocal condition numbers for the eigenvalues */
  278. /* > (RCONDE), and reciprocal condition numbers for the right */
  279. /* > eigenvectors (RCONDV). */
  280. /* > */
  281. /* > The right eigenvector v(j) of A satisfies */
  282. /* > A * v(j) = lambda(j) * v(j) */
  283. /* > where lambda(j) is its eigenvalue. */
  284. /* > The left eigenvector u(j) of A satisfies */
  285. /* > u(j)**H * A = lambda(j) * u(j)**H */
  286. /* > where u(j)**H denotes the conjugate-transpose of u(j). */
  287. /* > */
  288. /* > The computed eigenvectors are normalized to have Euclidean norm */
  289. /* > equal to 1 and largest component real. */
  290. /* > */
  291. /* > Balancing a matrix means permuting the rows and columns to make it */
  292. /* > more nearly upper triangular, and applying a diagonal similarity */
  293. /* > transformation D * A * D**(-1), where D is a diagonal matrix, to */
  294. /* > make its rows and columns closer in norm and the condition numbers */
  295. /* > of its eigenvalues and eigenvectors smaller. The computed */
  296. /* > reciprocal condition numbers correspond to the balanced matrix. */
  297. /* > Permuting rows and columns will not change the condition numbers */
  298. /* > (in exact arithmetic) but diagonal scaling will. For further */
  299. /* > explanation of balancing, see section 4.10.2 of the LAPACK */
  300. /* > Users' Guide. */
  301. /* > \endverbatim */
  302. /* Arguments: */
  303. /* ========== */
  304. /* > \param[in] BALANC */
  305. /* > \verbatim */
  306. /* > BALANC is CHARACTER*1 */
  307. /* > Indicates how the input matrix should be diagonally scaled */
  308. /* > and/or permuted to improve the conditioning of its */
  309. /* > eigenvalues. */
  310. /* > = 'N': Do not diagonally scale or permute; */
  311. /* > = 'P': Perform permutations to make the matrix more nearly */
  312. /* > upper triangular. Do not diagonally scale; */
  313. /* > = 'S': Diagonally scale the matrix, i.e. replace A by */
  314. /* > D*A*D**(-1), where D is a diagonal matrix chosen */
  315. /* > to make the rows and columns of A more equal in */
  316. /* > norm. Do not permute; */
  317. /* > = 'B': Both diagonally scale and permute A. */
  318. /* > */
  319. /* > Computed reciprocal condition numbers will be for the matrix */
  320. /* > after balancing and/or permuting. Permuting does not change */
  321. /* > condition numbers (in exact arithmetic), but balancing does. */
  322. /* > \endverbatim */
  323. /* > */
  324. /* > \param[in] JOBVL */
  325. /* > \verbatim */
  326. /* > JOBVL is CHARACTER*1 */
  327. /* > = 'N': left eigenvectors of A are not computed; */
  328. /* > = 'V': left eigenvectors of A are computed. */
  329. /* > If SENSE = 'E' or 'B', JOBVL must = 'V'. */
  330. /* > \endverbatim */
  331. /* > */
  332. /* > \param[in] JOBVR */
  333. /* > \verbatim */
  334. /* > JOBVR is CHARACTER*1 */
  335. /* > = 'N': right eigenvectors of A are not computed; */
  336. /* > = 'V': right eigenvectors of A are computed. */
  337. /* > If SENSE = 'E' or 'B', JOBVR must = 'V'. */
  338. /* > \endverbatim */
  339. /* > */
  340. /* > \param[in] SENSE */
  341. /* > \verbatim */
  342. /* > SENSE is CHARACTER*1 */
  343. /* > Determines which reciprocal condition numbers are computed. */
  344. /* > = 'N': None are computed; */
  345. /* > = 'E': Computed for eigenvalues only; */
  346. /* > = 'V': Computed for right eigenvectors only; */
  347. /* > = 'B': Computed for eigenvalues and right eigenvectors. */
  348. /* > */
  349. /* > If SENSE = 'E' or 'B', both left and right eigenvectors */
  350. /* > must also be computed (JOBVL = 'V' and JOBVR = 'V'). */
  351. /* > \endverbatim */
  352. /* > */
  353. /* > \param[in] N */
  354. /* > \verbatim */
  355. /* > N is INTEGER */
  356. /* > The order of the matrix A. N >= 0. */
  357. /* > \endverbatim */
  358. /* > */
  359. /* > \param[in,out] A */
  360. /* > \verbatim */
  361. /* > A is REAL array, dimension (LDA,N) */
  362. /* > On entry, the N-by-N matrix A. */
  363. /* > On exit, A has been overwritten. If JOBVL = 'V' or */
  364. /* > JOBVR = 'V', A contains the real Schur form of the balanced */
  365. /* > version of the input matrix A. */
  366. /* > \endverbatim */
  367. /* > */
  368. /* > \param[in] LDA */
  369. /* > \verbatim */
  370. /* > LDA is INTEGER */
  371. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  372. /* > \endverbatim */
  373. /* > */
  374. /* > \param[out] WR */
  375. /* > \verbatim */
  376. /* > WR is REAL array, dimension (N) */
  377. /* > \endverbatim */
  378. /* > */
  379. /* > \param[out] WI */
  380. /* > \verbatim */
  381. /* > WI is REAL array, dimension (N) */
  382. /* > WR and WI contain the real and imaginary parts, */
  383. /* > respectively, of the computed eigenvalues. Complex */
  384. /* > conjugate pairs of eigenvalues will appear consecutively */
  385. /* > with the eigenvalue having the positive imaginary part */
  386. /* > first. */
  387. /* > \endverbatim */
  388. /* > */
  389. /* > \param[out] VL */
  390. /* > \verbatim */
  391. /* > VL is REAL array, dimension (LDVL,N) */
  392. /* > If JOBVL = 'V', the left eigenvectors u(j) are stored one */
  393. /* > after another in the columns of VL, in the same order */
  394. /* > as their eigenvalues. */
  395. /* > If JOBVL = 'N', VL is not referenced. */
  396. /* > If the j-th eigenvalue is real, then u(j) = VL(:,j), */
  397. /* > the j-th column of VL. */
  398. /* > If the j-th and (j+1)-st eigenvalues form a complex */
  399. /* > conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and */
  400. /* > u(j+1) = VL(:,j) - i*VL(:,j+1). */
  401. /* > \endverbatim */
  402. /* > */
  403. /* > \param[in] LDVL */
  404. /* > \verbatim */
  405. /* > LDVL is INTEGER */
  406. /* > The leading dimension of the array VL. LDVL >= 1; if */
  407. /* > JOBVL = 'V', LDVL >= N. */
  408. /* > \endverbatim */
  409. /* > */
  410. /* > \param[out] VR */
  411. /* > \verbatim */
  412. /* > VR is REAL array, dimension (LDVR,N) */
  413. /* > If JOBVR = 'V', the right eigenvectors v(j) are stored one */
  414. /* > after another in the columns of VR, in the same order */
  415. /* > as their eigenvalues. */
  416. /* > If JOBVR = 'N', VR is not referenced. */
  417. /* > If the j-th eigenvalue is real, then v(j) = VR(:,j), */
  418. /* > the j-th column of VR. */
  419. /* > If the j-th and (j+1)-st eigenvalues form a complex */
  420. /* > conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and */
  421. /* > v(j+1) = VR(:,j) - i*VR(:,j+1). */
  422. /* > \endverbatim */
  423. /* > */
  424. /* > \param[in] LDVR */
  425. /* > \verbatim */
  426. /* > LDVR is INTEGER */
  427. /* > The leading dimension of the array VR. LDVR >= 1, and if */
  428. /* > JOBVR = 'V', LDVR >= N. */
  429. /* > \endverbatim */
  430. /* > */
  431. /* > \param[out] ILO */
  432. /* > \verbatim */
  433. /* > ILO is INTEGER */
  434. /* > \endverbatim */
  435. /* > */
  436. /* > \param[out] IHI */
  437. /* > \verbatim */
  438. /* > IHI is INTEGER */
  439. /* > ILO and IHI are integer values determined when A was */
  440. /* > balanced. The balanced A(i,j) = 0 if I > J and */
  441. /* > J = 1,...,ILO-1 or I = IHI+1,...,N. */
  442. /* > \endverbatim */
  443. /* > */
  444. /* > \param[out] SCALE */
  445. /* > \verbatim */
  446. /* > SCALE is REAL array, dimension (N) */
  447. /* > Details of the permutations and scaling factors applied */
  448. /* > when balancing A. If P(j) is the index of the row and column */
  449. /* > interchanged with row and column j, and D(j) is the scaling */
  450. /* > factor applied to row and column j, then */
  451. /* > SCALE(J) = P(J), for J = 1,...,ILO-1 */
  452. /* > = D(J), for J = ILO,...,IHI */
  453. /* > = P(J) for J = IHI+1,...,N. */
  454. /* > The order in which the interchanges are made is N to IHI+1, */
  455. /* > then 1 to ILO-1. */
  456. /* > \endverbatim */
  457. /* > */
  458. /* > \param[out] ABNRM */
  459. /* > \verbatim */
  460. /* > ABNRM is REAL */
  461. /* > The one-norm of the balanced matrix (the maximum */
  462. /* > of the sum of absolute values of elements of any column). */
  463. /* > \endverbatim */
  464. /* > */
  465. /* > \param[out] RCONDE */
  466. /* > \verbatim */
  467. /* > RCONDE is REAL array, dimension (N) */
  468. /* > RCONDE(j) is the reciprocal condition number of the j-th */
  469. /* > eigenvalue. */
  470. /* > \endverbatim */
  471. /* > */
  472. /* > \param[out] RCONDV */
  473. /* > \verbatim */
  474. /* > RCONDV is REAL array, dimension (N) */
  475. /* > RCONDV(j) is the reciprocal condition number of the j-th */
  476. /* > right eigenvector. */
  477. /* > \endverbatim */
  478. /* > */
  479. /* > \param[out] WORK */
  480. /* > \verbatim */
  481. /* > WORK is REAL array, dimension (MAX(1,LWORK)) */
  482. /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  483. /* > \endverbatim */
  484. /* > */
  485. /* > \param[in] LWORK */
  486. /* > \verbatim */
  487. /* > LWORK is INTEGER */
  488. /* > The dimension of the array WORK. If SENSE = 'N' or 'E', */
  489. /* > LWORK >= f2cmax(1,2*N), and if JOBVL = 'V' or JOBVR = 'V', */
  490. /* > LWORK >= 3*N. If SENSE = 'V' or 'B', LWORK >= N*(N+6). */
  491. /* > For good performance, LWORK must generally be larger. */
  492. /* > */
  493. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  494. /* > only calculates the optimal size of the WORK array, returns */
  495. /* > this value as the first entry of the WORK array, and no error */
  496. /* > message related to LWORK is issued by XERBLA. */
  497. /* > \endverbatim */
  498. /* > */
  499. /* > \param[out] IWORK */
  500. /* > \verbatim */
  501. /* > IWORK is INTEGER array, dimension (2*N-2) */
  502. /* > If SENSE = 'N' or 'E', not referenced. */
  503. /* > \endverbatim */
  504. /* > */
  505. /* > \param[out] INFO */
  506. /* > \verbatim */
  507. /* > INFO is INTEGER */
  508. /* > = 0: successful exit */
  509. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  510. /* > > 0: if INFO = i, the QR algorithm failed to compute all the */
  511. /* > eigenvalues, and no eigenvectors or condition numbers */
  512. /* > have been computed; elements 1:ILO-1 and i+1:N of WR */
  513. /* > and WI contain eigenvalues which have converged. */
  514. /* > \endverbatim */
  515. /* Authors: */
  516. /* ======== */
  517. /* > \author Univ. of Tennessee */
  518. /* > \author Univ. of California Berkeley */
  519. /* > \author Univ. of Colorado Denver */
  520. /* > \author NAG Ltd. */
  521. /* > \date June 2016 */
  522. /* @generated from dgeevx.f, fortran d -> s, Tue Apr 19 01:47:44 2016 */
  523. /* > \ingroup realGEeigen */
  524. /* ===================================================================== */
  525. /* Subroutine */ void sgeevx_(char *balanc, char *jobvl, char *jobvr, char *
  526. sense, integer *n, real *a, integer *lda, real *wr, real *wi, real *
  527. vl, integer *ldvl, real *vr, integer *ldvr, integer *ilo, integer *
  528. ihi, real *scale, real *abnrm, real *rconde, real *rcondv, real *work,
  529. integer *lwork, integer *iwork, integer *info)
  530. {
  531. /* System generated locals */
  532. integer a_dim1, a_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1,
  533. i__2, i__3;
  534. real r__1, r__2;
  535. /* Local variables */
  536. char side[1];
  537. real anrm;
  538. integer ierr, itau, iwrk, nout;
  539. extern /* Subroutine */ void srot_(integer *, real *, integer *, real *,
  540. integer *, real *, real *);
  541. extern real snrm2_(integer *, real *, integer *);
  542. integer i__, k;
  543. real r__;
  544. integer icond;
  545. extern logical lsame_(char *, char *);
  546. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *);
  547. extern real slapy2_(real *, real *);
  548. real cs;
  549. extern /* Subroutine */ void slabad_(real *, real *);
  550. logical scalea;
  551. real cscale;
  552. extern /* Subroutine */ void sgebak_(char *, char *, integer *, integer *,
  553. integer *, real *, integer *, real *, integer *, integer *), sgebal_(char *, integer *, real *, integer *,
  554. integer *, integer *, real *, integer *);
  555. real sn;
  556. extern real slamch_(char *), slange_(char *, integer *, integer *,
  557. real *, integer *, real *);
  558. extern /* Subroutine */ void sgehrd_(integer *, integer *, integer *, real
  559. *, integer *, real *, real *, integer *, integer *);
  560. extern int xerbla_(char *, integer *, ftnlen);
  561. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  562. integer *, integer *, ftnlen, ftnlen);
  563. logical select[1];
  564. real bignum;
  565. extern /* Subroutine */ void slascl_(char *, integer *, integer *, real *,
  566. real *, integer *, integer *, real *, integer *, integer *);
  567. extern integer isamax_(integer *, real *, integer *);
  568. extern /* Subroutine */ void slacpy_(char *, integer *, integer *, real *,
  569. integer *, real *, integer *), slartg_(real *, real *,
  570. real *, real *, real *), sorghr_(integer *, integer *, integer *,
  571. real *, integer *, real *, real *, integer *, integer *), shseqr_(
  572. char *, char *, integer *, integer *, integer *, real *, integer *
  573. , real *, real *, real *, integer *, real *, integer *, integer *);
  574. integer minwrk, maxwrk;
  575. extern /* Subroutine */ void strsna_(char *, char *, logical *, integer *,
  576. real *, integer *, real *, integer *, real *, integer *, real *,
  577. real *, integer *, integer *, real *, integer *, integer *,
  578. integer *);
  579. logical wantvl, wntsnb;
  580. integer hswork;
  581. logical wntsne;
  582. real smlnum;
  583. logical lquery, wantvr, wntsnn, wntsnv;
  584. extern /* Subroutine */ void strevc3_(char *, char *, logical *, integer *,
  585. real *, integer *, real *, integer *, real *, integer *, integer
  586. *, integer *, real *, integer *, integer *);
  587. char job[1];
  588. real scl, dum[1], eps;
  589. integer lwork_trevc__;
  590. /* -- LAPACK driver routine (version 3.7.1) -- */
  591. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  592. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  593. /* June 2016 */
  594. /* ===================================================================== */
  595. /* Test the input arguments */
  596. /* Parameter adjustments */
  597. a_dim1 = *lda;
  598. a_offset = 1 + a_dim1 * 1;
  599. a -= a_offset;
  600. --wr;
  601. --wi;
  602. vl_dim1 = *ldvl;
  603. vl_offset = 1 + vl_dim1 * 1;
  604. vl -= vl_offset;
  605. vr_dim1 = *ldvr;
  606. vr_offset = 1 + vr_dim1 * 1;
  607. vr -= vr_offset;
  608. --scale;
  609. --rconde;
  610. --rcondv;
  611. --work;
  612. --iwork;
  613. /* Function Body */
  614. *info = 0;
  615. lquery = *lwork == -1;
  616. wantvl = lsame_(jobvl, "V");
  617. wantvr = lsame_(jobvr, "V");
  618. wntsnn = lsame_(sense, "N");
  619. wntsne = lsame_(sense, "E");
  620. wntsnv = lsame_(sense, "V");
  621. wntsnb = lsame_(sense, "B");
  622. if (! (lsame_(balanc, "N") || lsame_(balanc, "S") || lsame_(balanc, "P")
  623. || lsame_(balanc, "B"))) {
  624. *info = -1;
  625. } else if (! wantvl && ! lsame_(jobvl, "N")) {
  626. *info = -2;
  627. } else if (! wantvr && ! lsame_(jobvr, "N")) {
  628. *info = -3;
  629. } else if (! (wntsnn || wntsne || wntsnb || wntsnv) || (wntsne || wntsnb)
  630. && ! (wantvl && wantvr)) {
  631. *info = -4;
  632. } else if (*n < 0) {
  633. *info = -5;
  634. } else if (*lda < f2cmax(1,*n)) {
  635. *info = -7;
  636. } else if (*ldvl < 1 || wantvl && *ldvl < *n) {
  637. *info = -11;
  638. } else if (*ldvr < 1 || wantvr && *ldvr < *n) {
  639. *info = -13;
  640. }
  641. /* Compute workspace */
  642. /* (Note: Comments in the code beginning "Workspace:" describe the */
  643. /* minimal amount of workspace needed at that point in the code, */
  644. /* as well as the preferred amount for good performance. */
  645. /* NB refers to the optimal block size for the immediately */
  646. /* following subroutine, as returned by ILAENV. */
  647. /* HSWORK refers to the workspace preferred by SHSEQR, as */
  648. /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */
  649. /* the worst case.) */
  650. if (*info == 0) {
  651. if (*n == 0) {
  652. minwrk = 1;
  653. maxwrk = 1;
  654. } else {
  655. maxwrk = *n + *n * ilaenv_(&c__1, "SGEHRD", " ", n, &c__1, n, &
  656. c__0, (ftnlen)6, (ftnlen)1);
  657. if (wantvl) {
  658. strevc3_("L", "B", select, n, &a[a_offset], lda, &vl[
  659. vl_offset], ldvl, &vr[vr_offset], ldvr, n, &nout, &
  660. work[1], &c_n1, &ierr);
  661. lwork_trevc__ = (integer) work[1];
  662. /* Computing MAX */
  663. i__1 = maxwrk, i__2 = *n + lwork_trevc__;
  664. maxwrk = f2cmax(i__1,i__2);
  665. shseqr_("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[
  666. 1], &vl[vl_offset], ldvl, &work[1], &c_n1, info);
  667. } else if (wantvr) {
  668. strevc3_("R", "B", select, n, &a[a_offset], lda, &vl[
  669. vl_offset], ldvl, &vr[vr_offset], ldvr, n, &nout, &
  670. work[1], &c_n1, &ierr);
  671. lwork_trevc__ = (integer) work[1];
  672. /* Computing MAX */
  673. i__1 = maxwrk, i__2 = *n + lwork_trevc__;
  674. maxwrk = f2cmax(i__1,i__2);
  675. shseqr_("S", "V", n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[
  676. 1], &vr[vr_offset], ldvr, &work[1], &c_n1, info);
  677. } else {
  678. if (wntsnn) {
  679. shseqr_("E", "N", n, &c__1, n, &a[a_offset], lda, &wr[1],
  680. &wi[1], &vr[vr_offset], ldvr, &work[1], &c_n1,
  681. info);
  682. } else {
  683. shseqr_("S", "N", n, &c__1, n, &a[a_offset], lda, &wr[1],
  684. &wi[1], &vr[vr_offset], ldvr, &work[1], &c_n1,
  685. info);
  686. }
  687. }
  688. hswork = (integer) work[1];
  689. if (! wantvl && ! wantvr) {
  690. minwrk = *n << 1;
  691. if (! wntsnn) {
  692. /* Computing MAX */
  693. i__1 = minwrk, i__2 = *n * *n + *n * 6;
  694. minwrk = f2cmax(i__1,i__2);
  695. }
  696. maxwrk = f2cmax(maxwrk,hswork);
  697. if (! wntsnn) {
  698. /* Computing MAX */
  699. i__1 = maxwrk, i__2 = *n * *n + *n * 6;
  700. maxwrk = f2cmax(i__1,i__2);
  701. }
  702. } else {
  703. minwrk = *n * 3;
  704. if (! wntsnn && ! wntsne) {
  705. /* Computing MAX */
  706. i__1 = minwrk, i__2 = *n * *n + *n * 6;
  707. minwrk = f2cmax(i__1,i__2);
  708. }
  709. maxwrk = f2cmax(maxwrk,hswork);
  710. /* Computing MAX */
  711. i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "SORGHR",
  712. " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1);
  713. maxwrk = f2cmax(i__1,i__2);
  714. if (! wntsnn && ! wntsne) {
  715. /* Computing MAX */
  716. i__1 = maxwrk, i__2 = *n * *n + *n * 6;
  717. maxwrk = f2cmax(i__1,i__2);
  718. }
  719. /* Computing MAX */
  720. i__1 = maxwrk, i__2 = *n * 3;
  721. maxwrk = f2cmax(i__1,i__2);
  722. }
  723. maxwrk = f2cmax(maxwrk,minwrk);
  724. }
  725. work[1] = (real) maxwrk;
  726. if (*lwork < minwrk && ! lquery) {
  727. *info = -21;
  728. }
  729. }
  730. if (*info != 0) {
  731. i__1 = -(*info);
  732. xerbla_("SGEEVX", &i__1, (ftnlen)6);
  733. return;
  734. } else if (lquery) {
  735. return;
  736. }
  737. /* Quick return if possible */
  738. if (*n == 0) {
  739. return;
  740. }
  741. /* Get machine constants */
  742. eps = slamch_("P");
  743. smlnum = slamch_("S");
  744. bignum = 1.f / smlnum;
  745. slabad_(&smlnum, &bignum);
  746. smlnum = sqrt(smlnum) / eps;
  747. bignum = 1.f / smlnum;
  748. /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */
  749. icond = 0;
  750. anrm = slange_("M", n, n, &a[a_offset], lda, dum);
  751. scalea = FALSE_;
  752. if (anrm > 0.f && anrm < smlnum) {
  753. scalea = TRUE_;
  754. cscale = smlnum;
  755. } else if (anrm > bignum) {
  756. scalea = TRUE_;
  757. cscale = bignum;
  758. }
  759. if (scalea) {
  760. slascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, &
  761. ierr);
  762. }
  763. /* Balance the matrix and compute ABNRM */
  764. sgebal_(balanc, n, &a[a_offset], lda, ilo, ihi, &scale[1], &ierr);
  765. *abnrm = slange_("1", n, n, &a[a_offset], lda, dum);
  766. if (scalea) {
  767. dum[0] = *abnrm;
  768. slascl_("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, &c__1, &
  769. ierr);
  770. *abnrm = dum[0];
  771. }
  772. /* Reduce to upper Hessenberg form */
  773. /* (Workspace: need 2*N, prefer N+N*NB) */
  774. itau = 1;
  775. iwrk = itau + *n;
  776. i__1 = *lwork - iwrk + 1;
  777. sgehrd_(n, ilo, ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, &
  778. ierr);
  779. if (wantvl) {
  780. /* Want left eigenvectors */
  781. /* Copy Householder vectors to VL */
  782. *(unsigned char *)side = 'L';
  783. slacpy_("L", n, n, &a[a_offset], lda, &vl[vl_offset], ldvl)
  784. ;
  785. /* Generate orthogonal matrix in VL */
  786. /* (Workspace: need 2*N-1, prefer N+(N-1)*NB) */
  787. i__1 = *lwork - iwrk + 1;
  788. sorghr_(n, ilo, ihi, &vl[vl_offset], ldvl, &work[itau], &work[iwrk], &
  789. i__1, &ierr);
  790. /* Perform QR iteration, accumulating Schur vectors in VL */
  791. /* (Workspace: need 1, prefer HSWORK (see comments) ) */
  792. iwrk = itau;
  793. i__1 = *lwork - iwrk + 1;
  794. shseqr_("S", "V", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vl[
  795. vl_offset], ldvl, &work[iwrk], &i__1, info);
  796. if (wantvr) {
  797. /* Want left and right eigenvectors */
  798. /* Copy Schur vectors to VR */
  799. *(unsigned char *)side = 'B';
  800. slacpy_("F", n, n, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr);
  801. }
  802. } else if (wantvr) {
  803. /* Want right eigenvectors */
  804. /* Copy Householder vectors to VR */
  805. *(unsigned char *)side = 'R';
  806. slacpy_("L", n, n, &a[a_offset], lda, &vr[vr_offset], ldvr)
  807. ;
  808. /* Generate orthogonal matrix in VR */
  809. /* (Workspace: need 2*N-1, prefer N+(N-1)*NB) */
  810. i__1 = *lwork - iwrk + 1;
  811. sorghr_(n, ilo, ihi, &vr[vr_offset], ldvr, &work[itau], &work[iwrk], &
  812. i__1, &ierr);
  813. /* Perform QR iteration, accumulating Schur vectors in VR */
  814. /* (Workspace: need 1, prefer HSWORK (see comments) ) */
  815. iwrk = itau;
  816. i__1 = *lwork - iwrk + 1;
  817. shseqr_("S", "V", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vr[
  818. vr_offset], ldvr, &work[iwrk], &i__1, info);
  819. } else {
  820. /* Compute eigenvalues only */
  821. /* If condition numbers desired, compute Schur form */
  822. if (wntsnn) {
  823. *(unsigned char *)job = 'E';
  824. } else {
  825. *(unsigned char *)job = 'S';
  826. }
  827. /* (Workspace: need 1, prefer HSWORK (see comments) ) */
  828. iwrk = itau;
  829. i__1 = *lwork - iwrk + 1;
  830. shseqr_(job, "N", n, ilo, ihi, &a[a_offset], lda, &wr[1], &wi[1], &vr[
  831. vr_offset], ldvr, &work[iwrk], &i__1, info);
  832. }
  833. /* If INFO .NE. 0 from SHSEQR, then quit */
  834. if (*info != 0) {
  835. goto L50;
  836. }
  837. if (wantvl || wantvr) {
  838. /* Compute left and/or right eigenvectors */
  839. /* (Workspace: need 3*N, prefer N + 2*N*NB) */
  840. i__1 = *lwork - iwrk + 1;
  841. strevc3_(side, "B", select, n, &a[a_offset], lda, &vl[vl_offset],
  842. ldvl, &vr[vr_offset], ldvr, n, &nout, &work[iwrk], &i__1, &
  843. ierr);
  844. }
  845. /* Compute condition numbers if desired */
  846. /* (Workspace: need N*N+6*N unless SENSE = 'E') */
  847. if (! wntsnn) {
  848. strsna_(sense, "A", select, n, &a[a_offset], lda, &vl[vl_offset],
  849. ldvl, &vr[vr_offset], ldvr, &rconde[1], &rcondv[1], n, &nout,
  850. &work[iwrk], n, &iwork[1], &icond);
  851. }
  852. if (wantvl) {
  853. /* Undo balancing of left eigenvectors */
  854. sgebak_(balanc, "L", n, ilo, ihi, &scale[1], n, &vl[vl_offset], ldvl,
  855. &ierr);
  856. /* Normalize left eigenvectors and make largest component real */
  857. i__1 = *n;
  858. for (i__ = 1; i__ <= i__1; ++i__) {
  859. if (wi[i__] == 0.f) {
  860. scl = 1.f / snrm2_(n, &vl[i__ * vl_dim1 + 1], &c__1);
  861. sscal_(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1);
  862. } else if (wi[i__] > 0.f) {
  863. r__1 = snrm2_(n, &vl[i__ * vl_dim1 + 1], &c__1);
  864. r__2 = snrm2_(n, &vl[(i__ + 1) * vl_dim1 + 1], &c__1);
  865. scl = 1.f / slapy2_(&r__1, &r__2);
  866. sscal_(n, &scl, &vl[i__ * vl_dim1 + 1], &c__1);
  867. sscal_(n, &scl, &vl[(i__ + 1) * vl_dim1 + 1], &c__1);
  868. i__2 = *n;
  869. for (k = 1; k <= i__2; ++k) {
  870. /* Computing 2nd power */
  871. r__1 = vl[k + i__ * vl_dim1];
  872. /* Computing 2nd power */
  873. r__2 = vl[k + (i__ + 1) * vl_dim1];
  874. work[k] = r__1 * r__1 + r__2 * r__2;
  875. /* L10: */
  876. }
  877. k = isamax_(n, &work[1], &c__1);
  878. slartg_(&vl[k + i__ * vl_dim1], &vl[k + (i__ + 1) * vl_dim1],
  879. &cs, &sn, &r__);
  880. srot_(n, &vl[i__ * vl_dim1 + 1], &c__1, &vl[(i__ + 1) *
  881. vl_dim1 + 1], &c__1, &cs, &sn);
  882. vl[k + (i__ + 1) * vl_dim1] = 0.f;
  883. }
  884. /* L20: */
  885. }
  886. }
  887. if (wantvr) {
  888. /* Undo balancing of right eigenvectors */
  889. sgebak_(balanc, "R", n, ilo, ihi, &scale[1], n, &vr[vr_offset], ldvr,
  890. &ierr);
  891. /* Normalize right eigenvectors and make largest component real */
  892. i__1 = *n;
  893. for (i__ = 1; i__ <= i__1; ++i__) {
  894. if (wi[i__] == 0.f) {
  895. scl = 1.f / snrm2_(n, &vr[i__ * vr_dim1 + 1], &c__1);
  896. sscal_(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1);
  897. } else if (wi[i__] > 0.f) {
  898. r__1 = snrm2_(n, &vr[i__ * vr_dim1 + 1], &c__1);
  899. r__2 = snrm2_(n, &vr[(i__ + 1) * vr_dim1 + 1], &c__1);
  900. scl = 1.f / slapy2_(&r__1, &r__2);
  901. sscal_(n, &scl, &vr[i__ * vr_dim1 + 1], &c__1);
  902. sscal_(n, &scl, &vr[(i__ + 1) * vr_dim1 + 1], &c__1);
  903. i__2 = *n;
  904. for (k = 1; k <= i__2; ++k) {
  905. /* Computing 2nd power */
  906. r__1 = vr[k + i__ * vr_dim1];
  907. /* Computing 2nd power */
  908. r__2 = vr[k + (i__ + 1) * vr_dim1];
  909. work[k] = r__1 * r__1 + r__2 * r__2;
  910. /* L30: */
  911. }
  912. k = isamax_(n, &work[1], &c__1);
  913. slartg_(&vr[k + i__ * vr_dim1], &vr[k + (i__ + 1) * vr_dim1],
  914. &cs, &sn, &r__);
  915. srot_(n, &vr[i__ * vr_dim1 + 1], &c__1, &vr[(i__ + 1) *
  916. vr_dim1 + 1], &c__1, &cs, &sn);
  917. vr[k + (i__ + 1) * vr_dim1] = 0.f;
  918. }
  919. /* L40: */
  920. }
  921. }
  922. /* Undo scaling if necessary */
  923. L50:
  924. if (scalea) {
  925. i__1 = *n - *info;
  926. /* Computing MAX */
  927. i__3 = *n - *info;
  928. i__2 = f2cmax(i__3,1);
  929. slascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[*info +
  930. 1], &i__2, &ierr);
  931. i__1 = *n - *info;
  932. /* Computing MAX */
  933. i__3 = *n - *info;
  934. i__2 = f2cmax(i__3,1);
  935. slascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[*info +
  936. 1], &i__2, &ierr);
  937. if (*info == 0) {
  938. if ((wntsnv || wntsnb) && icond == 0) {
  939. slascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &rcondv[
  940. 1], n, &ierr);
  941. }
  942. } else {
  943. i__1 = *ilo - 1;
  944. slascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wr[1],
  945. n, &ierr);
  946. i__1 = *ilo - 1;
  947. slascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[1],
  948. n, &ierr);
  949. }
  950. }
  951. work[1] = (real) maxwrk;
  952. return;
  953. /* End of SGEEVX */
  954. } /* sgeevx_ */