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.

cgges.c 33 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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 complex c_b1 = {0.f,0.f};
  381. static complex c_b2 = {1.f,0.f};
  382. static integer c__1 = 1;
  383. static integer c__0 = 0;
  384. static integer c_n1 = -1;
  385. /* > \brief <b> CGGES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors f
  386. or GE matrices</b> */
  387. /* =========== DOCUMENTATION =========== */
  388. /* Online html documentation available at */
  389. /* http://www.netlib.org/lapack/explore-html/ */
  390. /* > \htmlonly */
  391. /* > Download CGGES + dependencies */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgges.f
  393. "> */
  394. /* > [TGZ]</a> */
  395. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgges.f
  396. "> */
  397. /* > [ZIP]</a> */
  398. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgges.f
  399. "> */
  400. /* > [TXT]</a> */
  401. /* > \endhtmlonly */
  402. /* Definition: */
  403. /* =========== */
  404. /* SUBROUTINE CGGES( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB, */
  405. /* SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK, */
  406. /* LWORK, RWORK, BWORK, INFO ) */
  407. /* CHARACTER JOBVSL, JOBVSR, SORT */
  408. /* INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM */
  409. /* LOGICAL BWORK( * ) */
  410. /* REAL RWORK( * ) */
  411. /* COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ), */
  412. /* $ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ), */
  413. /* $ WORK( * ) */
  414. /* LOGICAL SELCTG */
  415. /* EXTERNAL SELCTG */
  416. /* > \par Purpose: */
  417. /* ============= */
  418. /* > */
  419. /* > \verbatim */
  420. /* > */
  421. /* > CGGES computes for a pair of N-by-N complex nonsymmetric matrices */
  422. /* > (A,B), the generalized eigenvalues, the generalized complex Schur */
  423. /* > form (S, T), and optionally left and/or right Schur vectors (VSL */
  424. /* > and VSR). This gives the generalized Schur factorization */
  425. /* > */
  426. /* > (A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H ) */
  427. /* > */
  428. /* > where (VSR)**H is the conjugate-transpose of VSR. */
  429. /* > */
  430. /* > Optionally, it also orders the eigenvalues so that a selected cluster */
  431. /* > of eigenvalues appears in the leading diagonal blocks of the upper */
  432. /* > triangular matrix S and the upper triangular matrix T. The leading */
  433. /* > columns of VSL and VSR then form an unitary basis for the */
  434. /* > corresponding left and right eigenspaces (deflating subspaces). */
  435. /* > */
  436. /* > (If only the generalized eigenvalues are needed, use the driver */
  437. /* > CGGEV instead, which is faster.) */
  438. /* > */
  439. /* > A generalized eigenvalue for a pair of matrices (A,B) is a scalar w */
  440. /* > or a ratio alpha/beta = w, such that A - w*B is singular. It is */
  441. /* > usually represented as the pair (alpha,beta), as there is a */
  442. /* > reasonable interpretation for beta=0, and even for both being zero. */
  443. /* > */
  444. /* > A pair of matrices (S,T) is in generalized complex Schur form if S */
  445. /* > and T are upper triangular and, in addition, the diagonal elements */
  446. /* > of T are non-negative real numbers. */
  447. /* > \endverbatim */
  448. /* Arguments: */
  449. /* ========== */
  450. /* > \param[in] JOBVSL */
  451. /* > \verbatim */
  452. /* > JOBVSL is CHARACTER*1 */
  453. /* > = 'N': do not compute the left Schur vectors; */
  454. /* > = 'V': compute the left Schur vectors. */
  455. /* > \endverbatim */
  456. /* > */
  457. /* > \param[in] JOBVSR */
  458. /* > \verbatim */
  459. /* > JOBVSR is CHARACTER*1 */
  460. /* > = 'N': do not compute the right Schur vectors; */
  461. /* > = 'V': compute the right Schur vectors. */
  462. /* > \endverbatim */
  463. /* > */
  464. /* > \param[in] SORT */
  465. /* > \verbatim */
  466. /* > SORT is CHARACTER*1 */
  467. /* > Specifies whether or not to order the eigenvalues on the */
  468. /* > diagonal of the generalized Schur form. */
  469. /* > = 'N': Eigenvalues are not ordered; */
  470. /* > = 'S': Eigenvalues are ordered (see SELCTG). */
  471. /* > \endverbatim */
  472. /* > */
  473. /* > \param[in] SELCTG */
  474. /* > \verbatim */
  475. /* > SELCTG is a LOGICAL FUNCTION of two COMPLEX arguments */
  476. /* > SELCTG must be declared EXTERNAL in the calling subroutine. */
  477. /* > If SORT = 'N', SELCTG is not referenced. */
  478. /* > If SORT = 'S', SELCTG is used to select eigenvalues to sort */
  479. /* > to the top left of the Schur form. */
  480. /* > An eigenvalue ALPHA(j)/BETA(j) is selected if */
  481. /* > SELCTG(ALPHA(j),BETA(j)) is true. */
  482. /* > */
  483. /* > Note that a selected complex eigenvalue may no longer satisfy */
  484. /* > SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since */
  485. /* > ordering may change the value of complex eigenvalues */
  486. /* > (especially if the eigenvalue is ill-conditioned), in this */
  487. /* > case INFO is set to N+2 (See INFO below). */
  488. /* > \endverbatim */
  489. /* > */
  490. /* > \param[in] N */
  491. /* > \verbatim */
  492. /* > N is INTEGER */
  493. /* > The order of the matrices A, B, VSL, and VSR. N >= 0. */
  494. /* > \endverbatim */
  495. /* > */
  496. /* > \param[in,out] A */
  497. /* > \verbatim */
  498. /* > A is COMPLEX array, dimension (LDA, N) */
  499. /* > On entry, the first of the pair of matrices. */
  500. /* > On exit, A has been overwritten by its generalized Schur */
  501. /* > form S. */
  502. /* > \endverbatim */
  503. /* > */
  504. /* > \param[in] LDA */
  505. /* > \verbatim */
  506. /* > LDA is INTEGER */
  507. /* > The leading dimension of A. LDA >= f2cmax(1,N). */
  508. /* > \endverbatim */
  509. /* > */
  510. /* > \param[in,out] B */
  511. /* > \verbatim */
  512. /* > B is COMPLEX array, dimension (LDB, N) */
  513. /* > On entry, the second of the pair of matrices. */
  514. /* > On exit, B has been overwritten by its generalized Schur */
  515. /* > form T. */
  516. /* > \endverbatim */
  517. /* > */
  518. /* > \param[in] LDB */
  519. /* > \verbatim */
  520. /* > LDB is INTEGER */
  521. /* > The leading dimension of B. LDB >= f2cmax(1,N). */
  522. /* > \endverbatim */
  523. /* > */
  524. /* > \param[out] SDIM */
  525. /* > \verbatim */
  526. /* > SDIM is INTEGER */
  527. /* > If SORT = 'N', SDIM = 0. */
  528. /* > If SORT = 'S', SDIM = number of eigenvalues (after sorting) */
  529. /* > for which SELCTG is true. */
  530. /* > \endverbatim */
  531. /* > */
  532. /* > \param[out] ALPHA */
  533. /* > \verbatim */
  534. /* > ALPHA is COMPLEX array, dimension (N) */
  535. /* > \endverbatim */
  536. /* > */
  537. /* > \param[out] BETA */
  538. /* > \verbatim */
  539. /* > BETA is COMPLEX array, dimension (N) */
  540. /* > On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the */
  541. /* > generalized eigenvalues. ALPHA(j), j=1,...,N and BETA(j), */
  542. /* > j=1,...,N are the diagonals of the complex Schur form (A,B) */
  543. /* > output by CGGES. The BETA(j) will be non-negative real. */
  544. /* > */
  545. /* > Note: the quotients ALPHA(j)/BETA(j) may easily over- or */
  546. /* > underflow, and BETA(j) may even be zero. Thus, the user */
  547. /* > should avoid naively computing the ratio alpha/beta. */
  548. /* > However, ALPHA will be always less than and usually */
  549. /* > comparable with norm(A) in magnitude, and BETA always less */
  550. /* > than and usually comparable with norm(B). */
  551. /* > \endverbatim */
  552. /* > */
  553. /* > \param[out] VSL */
  554. /* > \verbatim */
  555. /* > VSL is COMPLEX array, dimension (LDVSL,N) */
  556. /* > If JOBVSL = 'V', VSL will contain the left Schur vectors. */
  557. /* > Not referenced if JOBVSL = 'N'. */
  558. /* > \endverbatim */
  559. /* > */
  560. /* > \param[in] LDVSL */
  561. /* > \verbatim */
  562. /* > LDVSL is INTEGER */
  563. /* > The leading dimension of the matrix VSL. LDVSL >= 1, and */
  564. /* > if JOBVSL = 'V', LDVSL >= N. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[out] VSR */
  568. /* > \verbatim */
  569. /* > VSR is COMPLEX array, dimension (LDVSR,N) */
  570. /* > If JOBVSR = 'V', VSR will contain the right Schur vectors. */
  571. /* > Not referenced if JOBVSR = 'N'. */
  572. /* > \endverbatim */
  573. /* > */
  574. /* > \param[in] LDVSR */
  575. /* > \verbatim */
  576. /* > LDVSR is INTEGER */
  577. /* > The leading dimension of the matrix VSR. LDVSR >= 1, and */
  578. /* > if JOBVSR = 'V', LDVSR >= N. */
  579. /* > \endverbatim */
  580. /* > */
  581. /* > \param[out] WORK */
  582. /* > \verbatim */
  583. /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */
  584. /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  585. /* > \endverbatim */
  586. /* > */
  587. /* > \param[in] LWORK */
  588. /* > \verbatim */
  589. /* > LWORK is INTEGER */
  590. /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */
  591. /* > For good performance, LWORK must generally be larger. */
  592. /* > */
  593. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  594. /* > only calculates the optimal size of the WORK array, returns */
  595. /* > this value as the first entry of the WORK array, and no error */
  596. /* > message related to LWORK is issued by XERBLA. */
  597. /* > \endverbatim */
  598. /* > */
  599. /* > \param[out] RWORK */
  600. /* > \verbatim */
  601. /* > RWORK is REAL array, dimension (8*N) */
  602. /* > \endverbatim */
  603. /* > */
  604. /* > \param[out] BWORK */
  605. /* > \verbatim */
  606. /* > BWORK is LOGICAL array, dimension (N) */
  607. /* > Not referenced if SORT = 'N'. */
  608. /* > \endverbatim */
  609. /* > */
  610. /* > \param[out] INFO */
  611. /* > \verbatim */
  612. /* > INFO is INTEGER */
  613. /* > = 0: successful exit */
  614. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  615. /* > =1,...,N: */
  616. /* > The QZ iteration failed. (A,B) are not in Schur */
  617. /* > form, but ALPHA(j) and BETA(j) should be correct for */
  618. /* > j=INFO+1,...,N. */
  619. /* > > N: =N+1: other than QZ iteration failed in CHGEQZ */
  620. /* > =N+2: after reordering, roundoff changed values of */
  621. /* > some complex eigenvalues so that leading */
  622. /* > eigenvalues in the Generalized Schur form no */
  623. /* > longer satisfy SELCTG=.TRUE. This could also */
  624. /* > be caused due to scaling. */
  625. /* > =N+3: reordering failed in CTGSEN. */
  626. /* > \endverbatim */
  627. /* Authors: */
  628. /* ======== */
  629. /* > \author Univ. of Tennessee */
  630. /* > \author Univ. of California Berkeley */
  631. /* > \author Univ. of Colorado Denver */
  632. /* > \author NAG Ltd. */
  633. /* > \date December 2016 */
  634. /* > \ingroup complexGEeigen */
  635. /* ===================================================================== */
  636. /* Subroutine */ int cgges_(char *jobvsl, char *jobvsr, char *sort, L_fp
  637. selctg, integer *n, complex *a, integer *lda, complex *b, integer *
  638. ldb, integer *sdim, complex *alpha, complex *beta, complex *vsl,
  639. integer *ldvsl, complex *vsr, integer *ldvsr, complex *work, integer *
  640. lwork, real *rwork, logical *bwork, integer *info)
  641. {
  642. /* System generated locals */
  643. integer a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset,
  644. vsr_dim1, vsr_offset, i__1, i__2;
  645. /* Local variables */
  646. real anrm, bnrm;
  647. integer idum[1], ierr, itau, iwrk;
  648. real pvsl, pvsr;
  649. integer i__;
  650. extern logical lsame_(char *, char *);
  651. integer ileft, icols;
  652. logical cursl, ilvsl, ilvsr;
  653. integer irwrk, irows;
  654. extern /* Subroutine */ int cggbak_(char *, char *, integer *, integer *,
  655. integer *, real *, real *, integer *, complex *, integer *,
  656. integer *), cggbal_(char *, integer *, complex *,
  657. integer *, complex *, integer *, integer *, integer *, real *,
  658. real *, real *, integer *), slabad_(real *, real *);
  659. extern real clange_(char *, integer *, integer *, complex *, integer *,
  660. real *);
  661. extern /* Subroutine */ int cgghrd_(char *, char *, integer *, integer *,
  662. integer *, complex *, integer *, complex *, integer *, complex *,
  663. integer *, complex *, integer *, integer *),
  664. clascl_(char *, integer *, integer *, real *, real *, integer *,
  665. integer *, complex *, integer *, integer *);
  666. logical ilascl, ilbscl;
  667. extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *,
  668. integer *, complex *, complex *, integer *, integer *);
  669. extern real slamch_(char *);
  670. extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex
  671. *, integer *, complex *, integer *), claset_(char *,
  672. integer *, integer *, complex *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen);
  673. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  674. integer *, integer *, ftnlen, ftnlen);
  675. real bignum;
  676. extern /* Subroutine */ int chgeqz_(char *, char *, char *, integer *,
  677. integer *, integer *, complex *, integer *, complex *, integer *,
  678. complex *, complex *, complex *, integer *, complex *, integer *,
  679. complex *, integer *, real *, integer *),
  680. ctgsen_(integer *, logical *, logical *, logical *, integer *,
  681. complex *, integer *, complex *, integer *, complex *, complex *,
  682. complex *, integer *, complex *, integer *, integer *, real *,
  683. real *, real *, complex *, integer *, integer *, integer *,
  684. integer *);
  685. integer ijobvl, iright, ijobvr;
  686. real anrmto;
  687. integer lwkmin;
  688. logical lastsl;
  689. real bnrmto;
  690. extern /* Subroutine */ int cungqr_(integer *, integer *, integer *,
  691. complex *, integer *, complex *, complex *, integer *, integer *),
  692. cunmqr_(char *, char *, integer *, integer *, integer *, complex
  693. *, integer *, complex *, complex *, integer *, complex *, integer
  694. *, integer *);
  695. real smlnum;
  696. logical wantst, lquery;
  697. integer lwkopt;
  698. real dif[2];
  699. integer ihi, ilo;
  700. real eps;
  701. /* -- LAPACK driver routine (version 3.7.0) -- */
  702. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  703. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  704. /* December 2016 */
  705. /* ===================================================================== */
  706. /* Decode the input arguments */
  707. /* Parameter adjustments */
  708. a_dim1 = *lda;
  709. a_offset = 1 + a_dim1 * 1;
  710. a -= a_offset;
  711. b_dim1 = *ldb;
  712. b_offset = 1 + b_dim1 * 1;
  713. b -= b_offset;
  714. --alpha;
  715. --beta;
  716. vsl_dim1 = *ldvsl;
  717. vsl_offset = 1 + vsl_dim1 * 1;
  718. vsl -= vsl_offset;
  719. vsr_dim1 = *ldvsr;
  720. vsr_offset = 1 + vsr_dim1 * 1;
  721. vsr -= vsr_offset;
  722. --work;
  723. --rwork;
  724. --bwork;
  725. /* Function Body */
  726. if (lsame_(jobvsl, "N")) {
  727. ijobvl = 1;
  728. ilvsl = FALSE_;
  729. } else if (lsame_(jobvsl, "V")) {
  730. ijobvl = 2;
  731. ilvsl = TRUE_;
  732. } else {
  733. ijobvl = -1;
  734. ilvsl = FALSE_;
  735. }
  736. if (lsame_(jobvsr, "N")) {
  737. ijobvr = 1;
  738. ilvsr = FALSE_;
  739. } else if (lsame_(jobvsr, "V")) {
  740. ijobvr = 2;
  741. ilvsr = TRUE_;
  742. } else {
  743. ijobvr = -1;
  744. ilvsr = FALSE_;
  745. }
  746. wantst = lsame_(sort, "S");
  747. /* Test the input arguments */
  748. *info = 0;
  749. lquery = *lwork == -1;
  750. if (ijobvl <= 0) {
  751. *info = -1;
  752. } else if (ijobvr <= 0) {
  753. *info = -2;
  754. } else if (! wantst && ! lsame_(sort, "N")) {
  755. *info = -3;
  756. } else if (*n < 0) {
  757. *info = -5;
  758. } else if (*lda < f2cmax(1,*n)) {
  759. *info = -7;
  760. } else if (*ldb < f2cmax(1,*n)) {
  761. *info = -9;
  762. } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) {
  763. *info = -14;
  764. } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) {
  765. *info = -16;
  766. }
  767. /* Compute workspace */
  768. /* (Note: Comments in the code beginning "Workspace:" describe the */
  769. /* minimal amount of workspace needed at that point in the code, */
  770. /* as well as the preferred amount for good performance. */
  771. /* NB refers to the optimal block size for the immediately */
  772. /* following subroutine, as returned by ILAENV.) */
  773. if (*info == 0) {
  774. /* Computing MAX */
  775. i__1 = 1, i__2 = *n << 1;
  776. lwkmin = f2cmax(i__1,i__2);
  777. /* Computing MAX */
  778. i__1 = 1, i__2 = *n + *n * ilaenv_(&c__1, "CGEQRF", " ", n, &c__1, n,
  779. &c__0, (ftnlen)6, (ftnlen)1);
  780. lwkopt = f2cmax(i__1,i__2);
  781. /* Computing MAX */
  782. i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "CUNMQR", " ", n, &
  783. c__1, n, &c_n1, (ftnlen)6, (ftnlen)1);
  784. lwkopt = f2cmax(i__1,i__2);
  785. if (ilvsl) {
  786. /* Computing MAX */
  787. i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "CUNGQR", " ", n, &
  788. c__1, n, &c_n1, (ftnlen)6, (ftnlen)1);
  789. lwkopt = f2cmax(i__1,i__2);
  790. }
  791. work[1].r = (real) lwkopt, work[1].i = 0.f;
  792. if (*lwork < lwkmin && ! lquery) {
  793. *info = -18;
  794. }
  795. }
  796. if (*info != 0) {
  797. i__1 = -(*info);
  798. xerbla_("CGGES ", &i__1, (ftnlen)6);
  799. return 0;
  800. } else if (lquery) {
  801. return 0;
  802. }
  803. /* Quick return if possible */
  804. if (*n == 0) {
  805. *sdim = 0;
  806. return 0;
  807. }
  808. /* Get machine constants */
  809. eps = slamch_("P");
  810. smlnum = slamch_("S");
  811. bignum = 1.f / smlnum;
  812. slabad_(&smlnum, &bignum);
  813. smlnum = sqrt(smlnum) / eps;
  814. bignum = 1.f / smlnum;
  815. /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */
  816. anrm = clange_("M", n, n, &a[a_offset], lda, &rwork[1]);
  817. ilascl = FALSE_;
  818. if (anrm > 0.f && anrm < smlnum) {
  819. anrmto = smlnum;
  820. ilascl = TRUE_;
  821. } else if (anrm > bignum) {
  822. anrmto = bignum;
  823. ilascl = TRUE_;
  824. }
  825. if (ilascl) {
  826. clascl_("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, &
  827. ierr);
  828. }
  829. /* Scale B if f2cmax element outside range [SMLNUM,BIGNUM] */
  830. bnrm = clange_("M", n, n, &b[b_offset], ldb, &rwork[1]);
  831. ilbscl = FALSE_;
  832. if (bnrm > 0.f && bnrm < smlnum) {
  833. bnrmto = smlnum;
  834. ilbscl = TRUE_;
  835. } else if (bnrm > bignum) {
  836. bnrmto = bignum;
  837. ilbscl = TRUE_;
  838. }
  839. if (ilbscl) {
  840. clascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, &
  841. ierr);
  842. }
  843. /* Permute the matrix to make it more nearly triangular */
  844. /* (Real Workspace: need 6*N) */
  845. ileft = 1;
  846. iright = *n + 1;
  847. irwrk = iright + *n;
  848. cggbal_("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &rwork[
  849. ileft], &rwork[iright], &rwork[irwrk], &ierr);
  850. /* Reduce B to triangular form (QR decomposition of B) */
  851. /* (Complex Workspace: need N, prefer N*NB) */
  852. irows = ihi + 1 - ilo;
  853. icols = *n + 1 - ilo;
  854. itau = 1;
  855. iwrk = itau + irows;
  856. i__1 = *lwork + 1 - iwrk;
  857. cgeqrf_(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[
  858. iwrk], &i__1, &ierr);
  859. /* Apply the orthogonal transformation to matrix A */
  860. /* (Complex Workspace: need N, prefer N*NB) */
  861. i__1 = *lwork + 1 - iwrk;
  862. cunmqr_("L", "C", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, &
  863. work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, &
  864. ierr);
  865. /* Initialize VSL */
  866. /* (Complex Workspace: need N, prefer N*NB) */
  867. if (ilvsl) {
  868. claset_("Full", n, n, &c_b1, &c_b2, &vsl[vsl_offset], ldvsl);
  869. if (irows > 1) {
  870. i__1 = irows - 1;
  871. i__2 = irows - 1;
  872. clacpy_("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[
  873. ilo + 1 + ilo * vsl_dim1], ldvsl);
  874. }
  875. i__1 = *lwork + 1 - iwrk;
  876. cungqr_(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, &
  877. work[itau], &work[iwrk], &i__1, &ierr);
  878. }
  879. /* Initialize VSR */
  880. if (ilvsr) {
  881. claset_("Full", n, n, &c_b1, &c_b2, &vsr[vsr_offset], ldvsr);
  882. }
  883. /* Reduce to generalized Hessenberg form */
  884. /* (Workspace: none needed) */
  885. cgghrd_(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset],
  886. ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &ierr);
  887. *sdim = 0;
  888. /* Perform QZ algorithm, computing Schur vectors if desired */
  889. /* (Complex Workspace: need N) */
  890. /* (Real Workspace: need N) */
  891. iwrk = itau;
  892. i__1 = *lwork + 1 - iwrk;
  893. chgeqz_("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[
  894. b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl, &
  895. vsr[vsr_offset], ldvsr, &work[iwrk], &i__1, &rwork[irwrk], &ierr);
  896. if (ierr != 0) {
  897. if (ierr > 0 && ierr <= *n) {
  898. *info = ierr;
  899. } else if (ierr > *n && ierr <= *n << 1) {
  900. *info = ierr - *n;
  901. } else {
  902. *info = *n + 1;
  903. }
  904. goto L30;
  905. }
  906. /* Sort eigenvalues ALPHA/BETA if desired */
  907. /* (Workspace: none needed) */
  908. if (wantst) {
  909. /* Undo scaling on eigenvalues before selecting */
  910. if (ilascl) {
  911. clascl_("G", &c__0, &c__0, &anrm, &anrmto, n, &c__1, &alpha[1], n,
  912. &ierr);
  913. }
  914. if (ilbscl) {
  915. clascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, &c__1, &beta[1], n,
  916. &ierr);
  917. }
  918. /* Select eigenvalues */
  919. i__1 = *n;
  920. for (i__ = 1; i__ <= i__1; ++i__) {
  921. bwork[i__] = (*selctg)(&alpha[i__], &beta[i__]);
  922. /* L10: */
  923. }
  924. i__1 = *lwork - iwrk + 1;
  925. ctgsen_(&c__0, &ilvsl, &ilvsr, &bwork[1], n, &a[a_offset], lda, &b[
  926. b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl,
  927. &vsr[vsr_offset], ldvsr, sdim, &pvsl, &pvsr, dif, &work[iwrk],
  928. &i__1, idum, &c__1, &ierr);
  929. if (ierr == 1) {
  930. *info = *n + 3;
  931. }
  932. }
  933. /* Apply back-permutation to VSL and VSR */
  934. /* (Workspace: none needed) */
  935. if (ilvsl) {
  936. cggbak_("P", "L", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, &
  937. vsl[vsl_offset], ldvsl, &ierr);
  938. }
  939. if (ilvsr) {
  940. cggbak_("P", "R", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, &
  941. vsr[vsr_offset], ldvsr, &ierr);
  942. }
  943. /* Undo scaling */
  944. if (ilascl) {
  945. clascl_("U", &c__0, &c__0, &anrmto, &anrm, n, n, &a[a_offset], lda, &
  946. ierr);
  947. clascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alpha[1], n, &
  948. ierr);
  949. }
  950. if (ilbscl) {
  951. clascl_("U", &c__0, &c__0, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, &
  952. ierr);
  953. clascl_("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, &
  954. ierr);
  955. }
  956. if (wantst) {
  957. /* Check if reordering is correct */
  958. lastsl = TRUE_;
  959. *sdim = 0;
  960. i__1 = *n;
  961. for (i__ = 1; i__ <= i__1; ++i__) {
  962. cursl = (*selctg)(&alpha[i__], &beta[i__]);
  963. if (cursl) {
  964. ++(*sdim);
  965. }
  966. if (cursl && ! lastsl) {
  967. *info = *n + 2;
  968. }
  969. lastsl = cursl;
  970. /* L20: */
  971. }
  972. }
  973. L30:
  974. work[1].r = (real) lwkopt, work[1].i = 0.f;
  975. return 0;
  976. /* End of CGGES */
  977. } /* cgges_ */