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.

shgeqz.c 60 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100
  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 int logical;
  52. typedef short int shortlogical;
  53. typedef char logical1;
  54. typedef char integer1;
  55. #define TRUE_ (1)
  56. #define FALSE_ (0)
  57. /* Extern is for use with -E */
  58. #ifndef Extern
  59. #define Extern extern
  60. #endif
  61. /* I/O stuff */
  62. typedef int flag;
  63. typedef int ftnlen;
  64. typedef int ftnint;
  65. /*external read, write*/
  66. typedef struct
  67. { flag cierr;
  68. ftnint ciunit;
  69. flag ciend;
  70. char *cifmt;
  71. ftnint cirec;
  72. } cilist;
  73. /*internal read, write*/
  74. typedef struct
  75. { flag icierr;
  76. char *iciunit;
  77. flag iciend;
  78. char *icifmt;
  79. ftnint icirlen;
  80. ftnint icirnum;
  81. } icilist;
  82. /*open*/
  83. typedef struct
  84. { flag oerr;
  85. ftnint ounit;
  86. char *ofnm;
  87. ftnlen ofnmlen;
  88. char *osta;
  89. char *oacc;
  90. char *ofm;
  91. ftnint orl;
  92. char *oblnk;
  93. } olist;
  94. /*close*/
  95. typedef struct
  96. { flag cerr;
  97. ftnint cunit;
  98. char *csta;
  99. } cllist;
  100. /*rewind, backspace, endfile*/
  101. typedef struct
  102. { flag aerr;
  103. ftnint aunit;
  104. } alist;
  105. /* inquire */
  106. typedef struct
  107. { flag inerr;
  108. ftnint inunit;
  109. char *infile;
  110. ftnlen infilen;
  111. ftnint *inex; /*parameters in standard's order*/
  112. ftnint *inopen;
  113. ftnint *innum;
  114. ftnint *innamed;
  115. char *inname;
  116. ftnlen innamlen;
  117. char *inacc;
  118. ftnlen inacclen;
  119. char *inseq;
  120. ftnlen inseqlen;
  121. char *indir;
  122. ftnlen indirlen;
  123. char *infmt;
  124. ftnlen infmtlen;
  125. char *inform;
  126. ftnint informlen;
  127. char *inunf;
  128. ftnlen inunflen;
  129. ftnint *inrecl;
  130. ftnint *innrec;
  131. char *inblank;
  132. ftnlen inblanklen;
  133. } inlist;
  134. #define VOID void
  135. union Multitype { /* for multiple entry points */
  136. integer1 g;
  137. shortint h;
  138. integer i;
  139. /* longint j; */
  140. real r;
  141. doublereal d;
  142. complex c;
  143. doublecomplex z;
  144. };
  145. typedef union Multitype Multitype;
  146. struct Vardesc { /* for Namelist */
  147. char *name;
  148. char *addr;
  149. ftnlen *dims;
  150. int type;
  151. };
  152. typedef struct Vardesc Vardesc;
  153. struct Namelist {
  154. char *name;
  155. Vardesc **vars;
  156. int nvars;
  157. };
  158. typedef struct Namelist Namelist;
  159. #define abs(x) ((x) >= 0 ? (x) : -(x))
  160. #define dabs(x) (fabs(x))
  161. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  162. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  163. #define dmin(a,b) (f2cmin(a,b))
  164. #define dmax(a,b) (f2cmax(a,b))
  165. #define bit_test(a,b) ((a) >> (b) & 1)
  166. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  167. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  168. #define abort_() { sig_die("Fortran abort routine called", 1); }
  169. #define c_abs(z) (cabsf(Cf(z)))
  170. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  171. #ifdef _MSC_VER
  172. #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]);}
  173. #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]);}
  174. #else
  175. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  176. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  177. #endif
  178. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  179. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  180. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  181. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  182. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  183. #define d_abs(x) (fabs(*(x)))
  184. #define d_acos(x) (acos(*(x)))
  185. #define d_asin(x) (asin(*(x)))
  186. #define d_atan(x) (atan(*(x)))
  187. #define d_atn2(x, y) (atan2(*(x),*(y)))
  188. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  189. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  190. #define d_cos(x) (cos(*(x)))
  191. #define d_cosh(x) (cosh(*(x)))
  192. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  193. #define d_exp(x) (exp(*(x)))
  194. #define d_imag(z) (cimag(Cd(z)))
  195. #define r_imag(z) (cimagf(Cf(z)))
  196. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  198. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  200. #define d_log(x) (log(*(x)))
  201. #define d_mod(x, y) (fmod(*(x), *(y)))
  202. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  203. #define d_nint(x) u_nint(*(x))
  204. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  205. #define d_sign(a,b) u_sign(*(a),*(b))
  206. #define r_sign(a,b) u_sign(*(a),*(b))
  207. #define d_sin(x) (sin(*(x)))
  208. #define d_sinh(x) (sinh(*(x)))
  209. #define d_sqrt(x) (sqrt(*(x)))
  210. #define d_tan(x) (tan(*(x)))
  211. #define d_tanh(x) (tanh(*(x)))
  212. #define i_abs(x) abs(*(x))
  213. #define i_dnnt(x) ((integer)u_nint(*(x)))
  214. #define i_len(s, n) (n)
  215. #define i_nint(x) ((integer)u_nint(*(x)))
  216. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  217. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  218. #define pow_si(B,E) spow_ui(*(B),*(E))
  219. #define pow_ri(B,E) spow_ui(*(B),*(E))
  220. #define pow_di(B,E) dpow_ui(*(B),*(E))
  221. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  222. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  223. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  224. #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++ = ' '; }
  225. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  226. #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]; }
  227. #define sig_die(s, kill) { exit(1); }
  228. #define s_stop(s, n) {exit(0);}
  229. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  230. #define z_abs(z) (cabs(Cd(z)))
  231. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  232. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  233. #define myexit_() break;
  234. #define mycycle() continue;
  235. #define myceiling(w) {ceil(w)}
  236. #define myhuge(w) {HUGE_VAL}
  237. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  238. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  239. /* procedure parameter types for -A and -C++ */
  240. #define F2C_proc_par_types 1
  241. #ifdef __cplusplus
  242. typedef logical (*L_fp)(...);
  243. #else
  244. typedef logical (*L_fp)();
  245. #endif
  246. static float spow_ui(float x, integer n) {
  247. float pow=1.0; unsigned long int u;
  248. if(n != 0) {
  249. if(n < 0) n = -n, x = 1/x;
  250. for(u = n; ; ) {
  251. if(u & 01) pow *= x;
  252. if(u >>= 1) x *= x;
  253. else break;
  254. }
  255. }
  256. return pow;
  257. }
  258. static double dpow_ui(double x, integer n) {
  259. double pow=1.0; unsigned long int u;
  260. if(n != 0) {
  261. if(n < 0) n = -n, x = 1/x;
  262. for(u = n; ; ) {
  263. if(u & 01) pow *= x;
  264. if(u >>= 1) x *= x;
  265. else break;
  266. }
  267. }
  268. return pow;
  269. }
  270. #ifdef _MSC_VER
  271. static _Fcomplex cpow_ui(complex x, integer n) {
  272. complex pow={1.0,0.0}; unsigned long int u;
  273. if(n != 0) {
  274. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  275. for(u = n; ; ) {
  276. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  277. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  278. else break;
  279. }
  280. }
  281. _Fcomplex p={pow.r, pow.i};
  282. return p;
  283. }
  284. #else
  285. static _Complex float cpow_ui(_Complex float x, integer n) {
  286. _Complex float pow=1.0; unsigned long int u;
  287. if(n != 0) {
  288. if(n < 0) n = -n, x = 1/x;
  289. for(u = n; ; ) {
  290. if(u & 01) pow *= x;
  291. if(u >>= 1) x *= x;
  292. else break;
  293. }
  294. }
  295. return pow;
  296. }
  297. #endif
  298. #ifdef _MSC_VER
  299. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  300. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  301. if(n != 0) {
  302. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  303. for(u = n; ; ) {
  304. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  305. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  306. else break;
  307. }
  308. }
  309. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  310. return p;
  311. }
  312. #else
  313. static _Complex double zpow_ui(_Complex double x, integer n) {
  314. _Complex double pow=1.0; unsigned long int u;
  315. if(n != 0) {
  316. if(n < 0) n = -n, x = 1/x;
  317. for(u = n; ; ) {
  318. if(u & 01) pow *= x;
  319. if(u >>= 1) x *= x;
  320. else break;
  321. }
  322. }
  323. return pow;
  324. }
  325. #endif
  326. static integer pow_ii(integer x, integer n) {
  327. integer pow; unsigned long int u;
  328. if (n <= 0) {
  329. if (n == 0 || x == 1) pow = 1;
  330. else if (x != -1) pow = x == 0 ? 1/x : 0;
  331. else n = -n;
  332. }
  333. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  334. u = n;
  335. for(pow = 1; ; ) {
  336. if(u & 01) pow *= x;
  337. if(u >>= 1) x *= x;
  338. else break;
  339. }
  340. }
  341. return pow;
  342. }
  343. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  344. {
  345. double m; integer i, mi;
  346. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  347. if (w[i-1]>m) mi=i ,m=w[i-1];
  348. return mi-s+1;
  349. }
  350. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  351. {
  352. float m; integer i, mi;
  353. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  354. if (w[i-1]>m) mi=i ,m=w[i-1];
  355. return mi-s+1;
  356. }
  357. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  358. integer n = *n_, incx = *incx_, incy = *incy_, i;
  359. #ifdef _MSC_VER
  360. _Fcomplex zdotc = {0.0, 0.0};
  361. if (incx == 1 && incy == 1) {
  362. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  363. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  364. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  365. }
  366. } else {
  367. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  368. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  369. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  370. }
  371. }
  372. pCf(z) = zdotc;
  373. }
  374. #else
  375. _Complex float zdotc = 0.0;
  376. if (incx == 1 && incy == 1) {
  377. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  378. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  379. }
  380. } else {
  381. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  382. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  383. }
  384. }
  385. pCf(z) = zdotc;
  386. }
  387. #endif
  388. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  389. integer n = *n_, incx = *incx_, incy = *incy_, i;
  390. #ifdef _MSC_VER
  391. _Dcomplex zdotc = {0.0, 0.0};
  392. if (incx == 1 && incy == 1) {
  393. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  394. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  395. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  396. }
  397. } else {
  398. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  399. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  400. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  401. }
  402. }
  403. pCd(z) = zdotc;
  404. }
  405. #else
  406. _Complex double zdotc = 0.0;
  407. if (incx == 1 && incy == 1) {
  408. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  409. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  410. }
  411. } else {
  412. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  413. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  414. }
  415. }
  416. pCd(z) = zdotc;
  417. }
  418. #endif
  419. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  420. integer n = *n_, incx = *incx_, incy = *incy_, i;
  421. #ifdef _MSC_VER
  422. _Fcomplex zdotc = {0.0, 0.0};
  423. if (incx == 1 && incy == 1) {
  424. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  425. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  426. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  427. }
  428. } else {
  429. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  430. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  431. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  432. }
  433. }
  434. pCf(z) = zdotc;
  435. }
  436. #else
  437. _Complex float zdotc = 0.0;
  438. if (incx == 1 && incy == 1) {
  439. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  440. zdotc += Cf(&x[i]) * Cf(&y[i]);
  441. }
  442. } else {
  443. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  444. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  445. }
  446. }
  447. pCf(z) = zdotc;
  448. }
  449. #endif
  450. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  451. integer n = *n_, incx = *incx_, incy = *incy_, i;
  452. #ifdef _MSC_VER
  453. _Dcomplex zdotc = {0.0, 0.0};
  454. if (incx == 1 && incy == 1) {
  455. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  456. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  457. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  458. }
  459. } else {
  460. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  461. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  462. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  463. }
  464. }
  465. pCd(z) = zdotc;
  466. }
  467. #else
  468. _Complex double zdotc = 0.0;
  469. if (incx == 1 && incy == 1) {
  470. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  471. zdotc += Cd(&x[i]) * Cd(&y[i]);
  472. }
  473. } else {
  474. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  475. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  476. }
  477. }
  478. pCd(z) = zdotc;
  479. }
  480. #endif
  481. /* -- translated by f2c (version 20000121).
  482. You must link the resulting object file with the libraries:
  483. -lf2c -lm (in that order)
  484. */
  485. /* Table of constant values */
  486. static real c_b12 = 0.f;
  487. static real c_b13 = 1.f;
  488. static integer c__1 = 1;
  489. static integer c__3 = 3;
  490. /* > \brief \b SHGEQZ */
  491. /* =========== DOCUMENTATION =========== */
  492. /* Online html documentation available at */
  493. /* http://www.netlib.org/lapack/explore-html/ */
  494. /* > \htmlonly */
  495. /* > Download SHGEQZ + dependencies */
  496. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/shgeqz.
  497. f"> */
  498. /* > [TGZ]</a> */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/shgeqz.
  500. f"> */
  501. /* > [ZIP]</a> */
  502. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/shgeqz.
  503. f"> */
  504. /* > [TXT]</a> */
  505. /* > \endhtmlonly */
  506. /* Definition: */
  507. /* =========== */
  508. /* SUBROUTINE SHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, */
  509. /* ALPHAR, ALPHAI, BETA, Q, LDQ, Z, LDZ, WORK, */
  510. /* LWORK, INFO ) */
  511. /* CHARACTER COMPQ, COMPZ, JOB */
  512. /* INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N */
  513. /* REAL ALPHAI( * ), ALPHAR( * ), BETA( * ), */
  514. /* $ H( LDH, * ), Q( LDQ, * ), T( LDT, * ), */
  515. /* $ WORK( * ), Z( LDZ, * ) */
  516. /* > \par Purpose: */
  517. /* ============= */
  518. /* > */
  519. /* > \verbatim */
  520. /* > */
  521. /* > SHGEQZ computes the eigenvalues of a real matrix pair (H,T), */
  522. /* > where H is an upper Hessenberg matrix and T is upper triangular, */
  523. /* > using the double-shift QZ method. */
  524. /* > Matrix pairs of this type are produced by the reduction to */
  525. /* > generalized upper Hessenberg form of a real matrix pair (A,B): */
  526. /* > */
  527. /* > A = Q1*H*Z1**T, B = Q1*T*Z1**T, */
  528. /* > */
  529. /* > as computed by SGGHRD. */
  530. /* > */
  531. /* > If JOB='S', then the Hessenberg-triangular pair (H,T) is */
  532. /* > also reduced to generalized Schur form, */
  533. /* > */
  534. /* > H = Q*S*Z**T, T = Q*P*Z**T, */
  535. /* > */
  536. /* > where Q and Z are orthogonal matrices, P is an upper triangular */
  537. /* > matrix, and S is a quasi-triangular matrix with 1-by-1 and 2-by-2 */
  538. /* > diagonal blocks. */
  539. /* > */
  540. /* > The 1-by-1 blocks correspond to real eigenvalues of the matrix pair */
  541. /* > (H,T) and the 2-by-2 blocks correspond to complex conjugate pairs of */
  542. /* > eigenvalues. */
  543. /* > */
  544. /* > Additionally, the 2-by-2 upper triangular diagonal blocks of P */
  545. /* > corresponding to 2-by-2 blocks of S are reduced to positive diagonal */
  546. /* > form, i.e., if S(j+1,j) is non-zero, then P(j+1,j) = P(j,j+1) = 0, */
  547. /* > P(j,j) > 0, and P(j+1,j+1) > 0. */
  548. /* > */
  549. /* > Optionally, the orthogonal matrix Q from the generalized Schur */
  550. /* > factorization may be postmultiplied into an input matrix Q1, and the */
  551. /* > orthogonal matrix Z may be postmultiplied into an input matrix Z1. */
  552. /* > If Q1 and Z1 are the orthogonal matrices from SGGHRD that reduced */
  553. /* > the matrix pair (A,B) to generalized upper Hessenberg form, then the */
  554. /* > output matrices Q1*Q and Z1*Z are the orthogonal factors from the */
  555. /* > generalized Schur factorization of (A,B): */
  556. /* > */
  557. /* > A = (Q1*Q)*S*(Z1*Z)**T, B = (Q1*Q)*P*(Z1*Z)**T. */
  558. /* > */
  559. /* > To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently, */
  560. /* > of (A,B)) are computed as a pair of values (alpha,beta), where alpha is */
  561. /* > complex and beta real. */
  562. /* > If beta is nonzero, lambda = alpha / beta is an eigenvalue of the */
  563. /* > generalized nonsymmetric eigenvalue problem (GNEP) */
  564. /* > A*x = lambda*B*x */
  565. /* > and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the */
  566. /* > alternate form of the GNEP */
  567. /* > mu*A*y = B*y. */
  568. /* > Real eigenvalues can be read directly from the generalized Schur */
  569. /* > form: */
  570. /* > alpha = S(i,i), beta = P(i,i). */
  571. /* > */
  572. /* > Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix */
  573. /* > Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973), */
  574. /* > pp. 241--256. */
  575. /* > \endverbatim */
  576. /* Arguments: */
  577. /* ========== */
  578. /* > \param[in] JOB */
  579. /* > \verbatim */
  580. /* > JOB is CHARACTER*1 */
  581. /* > = 'E': Compute eigenvalues only; */
  582. /* > = 'S': Compute eigenvalues and the Schur form. */
  583. /* > \endverbatim */
  584. /* > */
  585. /* > \param[in] COMPQ */
  586. /* > \verbatim */
  587. /* > COMPQ is CHARACTER*1 */
  588. /* > = 'N': Left Schur vectors (Q) are not computed; */
  589. /* > = 'I': Q is initialized to the unit matrix and the matrix Q */
  590. /* > of left Schur vectors of (H,T) is returned; */
  591. /* > = 'V': Q must contain an orthogonal matrix Q1 on entry and */
  592. /* > the product Q1*Q is returned. */
  593. /* > \endverbatim */
  594. /* > */
  595. /* > \param[in] COMPZ */
  596. /* > \verbatim */
  597. /* > COMPZ is CHARACTER*1 */
  598. /* > = 'N': Right Schur vectors (Z) are not computed; */
  599. /* > = 'I': Z is initialized to the unit matrix and the matrix Z */
  600. /* > of right Schur vectors of (H,T) is returned; */
  601. /* > = 'V': Z must contain an orthogonal matrix Z1 on entry and */
  602. /* > the product Z1*Z is returned. */
  603. /* > \endverbatim */
  604. /* > */
  605. /* > \param[in] N */
  606. /* > \verbatim */
  607. /* > N is INTEGER */
  608. /* > The order of the matrices H, T, Q, and Z. N >= 0. */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[in] ILO */
  612. /* > \verbatim */
  613. /* > ILO is INTEGER */
  614. /* > \endverbatim */
  615. /* > */
  616. /* > \param[in] IHI */
  617. /* > \verbatim */
  618. /* > IHI is INTEGER */
  619. /* > ILO and IHI mark the rows and columns of H which are in */
  620. /* > Hessenberg form. It is assumed that A is already upper */
  621. /* > triangular in rows and columns 1:ILO-1 and IHI+1:N. */
  622. /* > If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0. */
  623. /* > \endverbatim */
  624. /* > */
  625. /* > \param[in,out] H */
  626. /* > \verbatim */
  627. /* > H is REAL array, dimension (LDH, N) */
  628. /* > On entry, the N-by-N upper Hessenberg matrix H. */
  629. /* > On exit, if JOB = 'S', H contains the upper quasi-triangular */
  630. /* > matrix S from the generalized Schur factorization. */
  631. /* > If JOB = 'E', the diagonal blocks of H match those of S, but */
  632. /* > the rest of H is unspecified. */
  633. /* > \endverbatim */
  634. /* > */
  635. /* > \param[in] LDH */
  636. /* > \verbatim */
  637. /* > LDH is INTEGER */
  638. /* > The leading dimension of the array H. LDH >= f2cmax( 1, N ). */
  639. /* > \endverbatim */
  640. /* > */
  641. /* > \param[in,out] T */
  642. /* > \verbatim */
  643. /* > T is REAL array, dimension (LDT, N) */
  644. /* > On entry, the N-by-N upper triangular matrix T. */
  645. /* > On exit, if JOB = 'S', T contains the upper triangular */
  646. /* > matrix P from the generalized Schur factorization; */
  647. /* > 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks of S */
  648. /* > are reduced to positive diagonal form, i.e., if H(j+1,j) is */
  649. /* > non-zero, then T(j+1,j) = T(j,j+1) = 0, T(j,j) > 0, and */
  650. /* > T(j+1,j+1) > 0. */
  651. /* > If JOB = 'E', the diagonal blocks of T match those of P, but */
  652. /* > the rest of T is unspecified. */
  653. /* > \endverbatim */
  654. /* > */
  655. /* > \param[in] LDT */
  656. /* > \verbatim */
  657. /* > LDT is INTEGER */
  658. /* > The leading dimension of the array T. LDT >= f2cmax( 1, N ). */
  659. /* > \endverbatim */
  660. /* > */
  661. /* > \param[out] ALPHAR */
  662. /* > \verbatim */
  663. /* > ALPHAR is REAL array, dimension (N) */
  664. /* > The real parts of each scalar alpha defining an eigenvalue */
  665. /* > of GNEP. */
  666. /* > \endverbatim */
  667. /* > */
  668. /* > \param[out] ALPHAI */
  669. /* > \verbatim */
  670. /* > ALPHAI is REAL array, dimension (N) */
  671. /* > The imaginary parts of each scalar alpha defining an */
  672. /* > eigenvalue of GNEP. */
  673. /* > If ALPHAI(j) is zero, then the j-th eigenvalue is real; if */
  674. /* > positive, then the j-th and (j+1)-st eigenvalues are a */
  675. /* > complex conjugate pair, with ALPHAI(j+1) = -ALPHAI(j). */
  676. /* > \endverbatim */
  677. /* > */
  678. /* > \param[out] BETA */
  679. /* > \verbatim */
  680. /* > BETA is REAL array, dimension (N) */
  681. /* > The scalars beta that define the eigenvalues of GNEP. */
  682. /* > Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and */
  683. /* > beta = BETA(j) represent the j-th eigenvalue of the matrix */
  684. /* > pair (A,B), in one of the forms lambda = alpha/beta or */
  685. /* > mu = beta/alpha. Since either lambda or mu may overflow, */
  686. /* > they should not, in general, be computed. */
  687. /* > \endverbatim */
  688. /* > */
  689. /* > \param[in,out] Q */
  690. /* > \verbatim */
  691. /* > Q is REAL array, dimension (LDQ, N) */
  692. /* > On entry, if COMPQ = 'V', the orthogonal matrix Q1 used in */
  693. /* > the reduction of (A,B) to generalized Hessenberg form. */
  694. /* > On exit, if COMPQ = 'I', the orthogonal matrix of left Schur */
  695. /* > vectors of (H,T), and if COMPQ = 'V', the orthogonal matrix */
  696. /* > of left Schur vectors of (A,B). */
  697. /* > Not referenced if COMPQ = 'N'. */
  698. /* > \endverbatim */
  699. /* > */
  700. /* > \param[in] LDQ */
  701. /* > \verbatim */
  702. /* > LDQ is INTEGER */
  703. /* > The leading dimension of the array Q. LDQ >= 1. */
  704. /* > If COMPQ='V' or 'I', then LDQ >= N. */
  705. /* > \endverbatim */
  706. /* > */
  707. /* > \param[in,out] Z */
  708. /* > \verbatim */
  709. /* > Z is REAL array, dimension (LDZ, N) */
  710. /* > On entry, if COMPZ = 'V', the orthogonal matrix Z1 used in */
  711. /* > the reduction of (A,B) to generalized Hessenberg form. */
  712. /* > On exit, if COMPZ = 'I', the orthogonal matrix of */
  713. /* > right Schur vectors of (H,T), and if COMPZ = 'V', the */
  714. /* > orthogonal matrix of right Schur vectors of (A,B). */
  715. /* > Not referenced if COMPZ = 'N'. */
  716. /* > \endverbatim */
  717. /* > */
  718. /* > \param[in] LDZ */
  719. /* > \verbatim */
  720. /* > LDZ is INTEGER */
  721. /* > The leading dimension of the array Z. LDZ >= 1. */
  722. /* > If COMPZ='V' or 'I', then LDZ >= N. */
  723. /* > \endverbatim */
  724. /* > */
  725. /* > \param[out] WORK */
  726. /* > \verbatim */
  727. /* > WORK is REAL array, dimension (MAX(1,LWORK)) */
  728. /* > On exit, if INFO >= 0, WORK(1) returns the optimal LWORK. */
  729. /* > \endverbatim */
  730. /* > */
  731. /* > \param[in] LWORK */
  732. /* > \verbatim */
  733. /* > LWORK is INTEGER */
  734. /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */
  735. /* > */
  736. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  737. /* > only calculates the optimal size of the WORK array, returns */
  738. /* > this value as the first entry of the WORK array, and no error */
  739. /* > message related to LWORK is issued by XERBLA. */
  740. /* > \endverbatim */
  741. /* > */
  742. /* > \param[out] INFO */
  743. /* > \verbatim */
  744. /* > INFO is INTEGER */
  745. /* > = 0: successful exit */
  746. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  747. /* > = 1,...,N: the QZ iteration did not converge. (H,T) is not */
  748. /* > in Schur form, but ALPHAR(i), ALPHAI(i), and */
  749. /* > BETA(i), i=INFO+1,...,N should be correct. */
  750. /* > = N+1,...,2*N: the shift calculation failed. (H,T) is not */
  751. /* > in Schur form, but ALPHAR(i), ALPHAI(i), and */
  752. /* > BETA(i), i=INFO-N+1,...,N should be correct. */
  753. /* > \endverbatim */
  754. /* Authors: */
  755. /* ======== */
  756. /* > \author Univ. of Tennessee */
  757. /* > \author Univ. of California Berkeley */
  758. /* > \author Univ. of Colorado Denver */
  759. /* > \author NAG Ltd. */
  760. /* > \date June 2016 */
  761. /* > \ingroup realGEcomputational */
  762. /* > \par Further Details: */
  763. /* ===================== */
  764. /* > */
  765. /* > \verbatim */
  766. /* > */
  767. /* > Iteration counters: */
  768. /* > */
  769. /* > JITER -- counts iterations. */
  770. /* > IITER -- counts iterations run since ILAST was last */
  771. /* > changed. This is therefore reset only when a 1-by-1 or */
  772. /* > 2-by-2 block deflates off the bottom. */
  773. /* > \endverbatim */
  774. /* > */
  775. /* ===================================================================== */
  776. /* Subroutine */ int shgeqz_(char *job, char *compq, char *compz, integer *n,
  777. integer *ilo, integer *ihi, real *h__, integer *ldh, real *t, integer
  778. *ldt, real *alphar, real *alphai, real *beta, real *q, integer *ldq,
  779. real *z__, integer *ldz, real *work, integer *lwork, integer *info)
  780. {
  781. /* System generated locals */
  782. integer h_dim1, h_offset, q_dim1, q_offset, t_dim1, t_offset, z_dim1,
  783. z_offset, i__1, i__2, i__3, i__4;
  784. real r__1, r__2, r__3, r__4;
  785. /* Local variables */
  786. real ad11l, ad12l, ad21l, ad22l, ad32l, wabs, atol, btol, temp;
  787. extern /* Subroutine */ int srot_(integer *, real *, integer *, real *,
  788. integer *, real *, real *), slag2_(real *, integer *, real *,
  789. integer *, real *, real *, real *, real *, real *, real *);
  790. real temp2, s1inv, c__;
  791. integer j;
  792. real s, v[3], scale;
  793. extern logical lsame_(char *, char *);
  794. integer iiter, ilast, jiter;
  795. real anorm, bnorm;
  796. integer maxit;
  797. real tempi, tempr, s1, s2, t1, u1, u2;
  798. logical ilazr2;
  799. real a11, a12, a21, a22, b11, b22, c12, c21;
  800. extern real slapy2_(real *, real *);
  801. integer jc;
  802. extern real slapy3_(real *, real *, real *);
  803. real an, bn, cl;
  804. extern /* Subroutine */ int slasv2_(real *, real *, real *, real *, real *
  805. , real *, real *, real *, real *);
  806. real cq, cr;
  807. integer in;
  808. real ascale, bscale, u12, w11;
  809. integer jr;
  810. real cz, sl, w12, w21, w22, wi, sr;
  811. extern real slamch_(char *);
  812. real vs, wr, safmin;
  813. extern /* Subroutine */ int slarfg_(integer *, real *, real *, integer *,
  814. real *);
  815. real safmax;
  816. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  817. real eshift;
  818. logical ilschr;
  819. real b1a, b2a;
  820. integer icompq, ilastm;
  821. extern real slanhs_(char *, integer *, real *, integer *, real *);
  822. real a1i;
  823. integer ischur;
  824. real a2i, b1i;
  825. logical ilazro;
  826. integer icompz, ifirst, ifrstm;
  827. real a1r;
  828. integer istart;
  829. logical ilpivt;
  830. real a2r, b1r, b2i, b2r;
  831. extern /* Subroutine */ int slartg_(real *, real *, real *, real *, real *
  832. ), slaset_(char *, integer *, integer *, real *, real *, real *,
  833. integer *);
  834. logical lquery;
  835. real wr2, ad11, ad12, ad21, ad22, c11i, c22i;
  836. integer jch;
  837. real c11r, c22r;
  838. logical ilq;
  839. real u12l, tau, sqi;
  840. logical ilz;
  841. real ulp, sqr, szi, szr;
  842. /* -- LAPACK computational routine (version 3.7.0) -- */
  843. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  844. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  845. /* June 2016 */
  846. /* ===================================================================== */
  847. /* $ SAFETY = 1.0E+0 ) */
  848. /* Decode JOB, COMPQ, COMPZ */
  849. /* Parameter adjustments */
  850. h_dim1 = *ldh;
  851. h_offset = 1 + h_dim1 * 1;
  852. h__ -= h_offset;
  853. t_dim1 = *ldt;
  854. t_offset = 1 + t_dim1 * 1;
  855. t -= t_offset;
  856. --alphar;
  857. --alphai;
  858. --beta;
  859. q_dim1 = *ldq;
  860. q_offset = 1 + q_dim1 * 1;
  861. q -= q_offset;
  862. z_dim1 = *ldz;
  863. z_offset = 1 + z_dim1 * 1;
  864. z__ -= z_offset;
  865. --work;
  866. /* Function Body */
  867. if (lsame_(job, "E")) {
  868. ilschr = FALSE_;
  869. ischur = 1;
  870. } else if (lsame_(job, "S")) {
  871. ilschr = TRUE_;
  872. ischur = 2;
  873. } else {
  874. ischur = 0;
  875. }
  876. if (lsame_(compq, "N")) {
  877. ilq = FALSE_;
  878. icompq = 1;
  879. } else if (lsame_(compq, "V")) {
  880. ilq = TRUE_;
  881. icompq = 2;
  882. } else if (lsame_(compq, "I")) {
  883. ilq = TRUE_;
  884. icompq = 3;
  885. } else {
  886. icompq = 0;
  887. }
  888. if (lsame_(compz, "N")) {
  889. ilz = FALSE_;
  890. icompz = 1;
  891. } else if (lsame_(compz, "V")) {
  892. ilz = TRUE_;
  893. icompz = 2;
  894. } else if (lsame_(compz, "I")) {
  895. ilz = TRUE_;
  896. icompz = 3;
  897. } else {
  898. icompz = 0;
  899. }
  900. /* Check Argument Values */
  901. *info = 0;
  902. work[1] = (real) f2cmax(1,*n);
  903. lquery = *lwork == -1;
  904. if (ischur == 0) {
  905. *info = -1;
  906. } else if (icompq == 0) {
  907. *info = -2;
  908. } else if (icompz == 0) {
  909. *info = -3;
  910. } else if (*n < 0) {
  911. *info = -4;
  912. } else if (*ilo < 1) {
  913. *info = -5;
  914. } else if (*ihi > *n || *ihi < *ilo - 1) {
  915. *info = -6;
  916. } else if (*ldh < *n) {
  917. *info = -8;
  918. } else if (*ldt < *n) {
  919. *info = -10;
  920. } else if (*ldq < 1 || ilq && *ldq < *n) {
  921. *info = -15;
  922. } else if (*ldz < 1 || ilz && *ldz < *n) {
  923. *info = -17;
  924. } else if (*lwork < f2cmax(1,*n) && ! lquery) {
  925. *info = -19;
  926. }
  927. if (*info != 0) {
  928. i__1 = -(*info);
  929. xerbla_("SHGEQZ", &i__1, (ftnlen)6);
  930. return 0;
  931. } else if (lquery) {
  932. return 0;
  933. }
  934. /* Quick return if possible */
  935. if (*n <= 0) {
  936. work[1] = 1.f;
  937. return 0;
  938. }
  939. /* Initialize Q and Z */
  940. if (icompq == 3) {
  941. slaset_("Full", n, n, &c_b12, &c_b13, &q[q_offset], ldq);
  942. }
  943. if (icompz == 3) {
  944. slaset_("Full", n, n, &c_b12, &c_b13, &z__[z_offset], ldz);
  945. }
  946. /* Machine Constants */
  947. in = *ihi + 1 - *ilo;
  948. safmin = slamch_("S");
  949. safmax = 1.f / safmin;
  950. ulp = slamch_("E") * slamch_("B");
  951. anorm = slanhs_("F", &in, &h__[*ilo + *ilo * h_dim1], ldh, &work[1]);
  952. bnorm = slanhs_("F", &in, &t[*ilo + *ilo * t_dim1], ldt, &work[1]);
  953. /* Computing MAX */
  954. r__1 = safmin, r__2 = ulp * anorm;
  955. atol = f2cmax(r__1,r__2);
  956. /* Computing MAX */
  957. r__1 = safmin, r__2 = ulp * bnorm;
  958. btol = f2cmax(r__1,r__2);
  959. ascale = 1.f / f2cmax(safmin,anorm);
  960. bscale = 1.f / f2cmax(safmin,bnorm);
  961. /* Set Eigenvalues IHI+1:N */
  962. i__1 = *n;
  963. for (j = *ihi + 1; j <= i__1; ++j) {
  964. if (t[j + j * t_dim1] < 0.f) {
  965. if (ilschr) {
  966. i__2 = j;
  967. for (jr = 1; jr <= i__2; ++jr) {
  968. h__[jr + j * h_dim1] = -h__[jr + j * h_dim1];
  969. t[jr + j * t_dim1] = -t[jr + j * t_dim1];
  970. /* L10: */
  971. }
  972. } else {
  973. h__[j + j * h_dim1] = -h__[j + j * h_dim1];
  974. t[j + j * t_dim1] = -t[j + j * t_dim1];
  975. }
  976. if (ilz) {
  977. i__2 = *n;
  978. for (jr = 1; jr <= i__2; ++jr) {
  979. z__[jr + j * z_dim1] = -z__[jr + j * z_dim1];
  980. /* L20: */
  981. }
  982. }
  983. }
  984. alphar[j] = h__[j + j * h_dim1];
  985. alphai[j] = 0.f;
  986. beta[j] = t[j + j * t_dim1];
  987. /* L30: */
  988. }
  989. /* If IHI < ILO, skip QZ steps */
  990. if (*ihi < *ilo) {
  991. goto L380;
  992. }
  993. /* MAIN QZ ITERATION LOOP */
  994. /* Initialize dynamic indices */
  995. /* Eigenvalues ILAST+1:N have been found. */
  996. /* Column operations modify rows IFRSTM:whatever. */
  997. /* Row operations modify columns whatever:ILASTM. */
  998. /* If only eigenvalues are being computed, then */
  999. /* IFRSTM is the row of the last splitting row above row ILAST; */
  1000. /* this is always at least ILO. */
  1001. /* IITER counts iterations since the last eigenvalue was found, */
  1002. /* to tell when to use an extraordinary shift. */
  1003. /* MAXIT is the maximum number of QZ sweeps allowed. */
  1004. ilast = *ihi;
  1005. if (ilschr) {
  1006. ifrstm = 1;
  1007. ilastm = *n;
  1008. } else {
  1009. ifrstm = *ilo;
  1010. ilastm = *ihi;
  1011. }
  1012. iiter = 0;
  1013. eshift = 0.f;
  1014. maxit = (*ihi - *ilo + 1) * 30;
  1015. i__1 = maxit;
  1016. for (jiter = 1; jiter <= i__1; ++jiter) {
  1017. /* Split the matrix if possible. */
  1018. /* Two tests: */
  1019. /* 1: H(j,j-1)=0 or j=ILO */
  1020. /* 2: T(j,j)=0 */
  1021. if (ilast == *ilo) {
  1022. /* Special case: j=ILAST */
  1023. goto L80;
  1024. } else {
  1025. if ((r__1 = h__[ilast + (ilast - 1) * h_dim1], abs(r__1)) <= atol)
  1026. {
  1027. h__[ilast + (ilast - 1) * h_dim1] = 0.f;
  1028. goto L80;
  1029. }
  1030. }
  1031. if ((r__1 = t[ilast + ilast * t_dim1], abs(r__1)) <= btol) {
  1032. t[ilast + ilast * t_dim1] = 0.f;
  1033. goto L70;
  1034. }
  1035. /* General case: j<ILAST */
  1036. i__2 = *ilo;
  1037. for (j = ilast - 1; j >= i__2; --j) {
  1038. /* Test 1: for H(j,j-1)=0 or j=ILO */
  1039. if (j == *ilo) {
  1040. ilazro = TRUE_;
  1041. } else {
  1042. if ((r__1 = h__[j + (j - 1) * h_dim1], abs(r__1)) <= atol) {
  1043. h__[j + (j - 1) * h_dim1] = 0.f;
  1044. ilazro = TRUE_;
  1045. } else {
  1046. ilazro = FALSE_;
  1047. }
  1048. }
  1049. /* Test 2: for T(j,j)=0 */
  1050. if ((r__1 = t[j + j * t_dim1], abs(r__1)) < btol) {
  1051. t[j + j * t_dim1] = 0.f;
  1052. /* Test 1a: Check for 2 consecutive small subdiagonals in A */
  1053. ilazr2 = FALSE_;
  1054. if (! ilazro) {
  1055. temp = (r__1 = h__[j + (j - 1) * h_dim1], abs(r__1));
  1056. temp2 = (r__1 = h__[j + j * h_dim1], abs(r__1));
  1057. tempr = f2cmax(temp,temp2);
  1058. if (tempr < 1.f && tempr != 0.f) {
  1059. temp /= tempr;
  1060. temp2 /= tempr;
  1061. }
  1062. if (temp * (ascale * (r__1 = h__[j + 1 + j * h_dim1], abs(
  1063. r__1))) <= temp2 * (ascale * atol)) {
  1064. ilazr2 = TRUE_;
  1065. }
  1066. }
  1067. /* If both tests pass (1 & 2), i.e., the leading diagonal */
  1068. /* element of B in the block is zero, split a 1x1 block off */
  1069. /* at the top. (I.e., at the J-th row/column) The leading */
  1070. /* diagonal element of the remainder can also be zero, so */
  1071. /* this may have to be done repeatedly. */
  1072. if (ilazro || ilazr2) {
  1073. i__3 = ilast - 1;
  1074. for (jch = j; jch <= i__3; ++jch) {
  1075. temp = h__[jch + jch * h_dim1];
  1076. slartg_(&temp, &h__[jch + 1 + jch * h_dim1], &c__, &s,
  1077. &h__[jch + jch * h_dim1]);
  1078. h__[jch + 1 + jch * h_dim1] = 0.f;
  1079. i__4 = ilastm - jch;
  1080. srot_(&i__4, &h__[jch + (jch + 1) * h_dim1], ldh, &
  1081. h__[jch + 1 + (jch + 1) * h_dim1], ldh, &c__,
  1082. &s);
  1083. i__4 = ilastm - jch;
  1084. srot_(&i__4, &t[jch + (jch + 1) * t_dim1], ldt, &t[
  1085. jch + 1 + (jch + 1) * t_dim1], ldt, &c__, &s);
  1086. if (ilq) {
  1087. srot_(n, &q[jch * q_dim1 + 1], &c__1, &q[(jch + 1)
  1088. * q_dim1 + 1], &c__1, &c__, &s);
  1089. }
  1090. if (ilazr2) {
  1091. h__[jch + (jch - 1) * h_dim1] *= c__;
  1092. }
  1093. ilazr2 = FALSE_;
  1094. if ((r__1 = t[jch + 1 + (jch + 1) * t_dim1], abs(r__1)
  1095. ) >= btol) {
  1096. if (jch + 1 >= ilast) {
  1097. goto L80;
  1098. } else {
  1099. ifirst = jch + 1;
  1100. goto L110;
  1101. }
  1102. }
  1103. t[jch + 1 + (jch + 1) * t_dim1] = 0.f;
  1104. /* L40: */
  1105. }
  1106. goto L70;
  1107. } else {
  1108. /* Only test 2 passed -- chase the zero to T(ILAST,ILAST) */
  1109. /* Then process as in the case T(ILAST,ILAST)=0 */
  1110. i__3 = ilast - 1;
  1111. for (jch = j; jch <= i__3; ++jch) {
  1112. temp = t[jch + (jch + 1) * t_dim1];
  1113. slartg_(&temp, &t[jch + 1 + (jch + 1) * t_dim1], &c__,
  1114. &s, &t[jch + (jch + 1) * t_dim1]);
  1115. t[jch + 1 + (jch + 1) * t_dim1] = 0.f;
  1116. if (jch < ilastm - 1) {
  1117. i__4 = ilastm - jch - 1;
  1118. srot_(&i__4, &t[jch + (jch + 2) * t_dim1], ldt, &
  1119. t[jch + 1 + (jch + 2) * t_dim1], ldt, &
  1120. c__, &s);
  1121. }
  1122. i__4 = ilastm - jch + 2;
  1123. srot_(&i__4, &h__[jch + (jch - 1) * h_dim1], ldh, &
  1124. h__[jch + 1 + (jch - 1) * h_dim1], ldh, &c__,
  1125. &s);
  1126. if (ilq) {
  1127. srot_(n, &q[jch * q_dim1 + 1], &c__1, &q[(jch + 1)
  1128. * q_dim1 + 1], &c__1, &c__, &s);
  1129. }
  1130. temp = h__[jch + 1 + jch * h_dim1];
  1131. slartg_(&temp, &h__[jch + 1 + (jch - 1) * h_dim1], &
  1132. c__, &s, &h__[jch + 1 + jch * h_dim1]);
  1133. h__[jch + 1 + (jch - 1) * h_dim1] = 0.f;
  1134. i__4 = jch + 1 - ifrstm;
  1135. srot_(&i__4, &h__[ifrstm + jch * h_dim1], &c__1, &h__[
  1136. ifrstm + (jch - 1) * h_dim1], &c__1, &c__, &s)
  1137. ;
  1138. i__4 = jch - ifrstm;
  1139. srot_(&i__4, &t[ifrstm + jch * t_dim1], &c__1, &t[
  1140. ifrstm + (jch - 1) * t_dim1], &c__1, &c__, &s)
  1141. ;
  1142. if (ilz) {
  1143. srot_(n, &z__[jch * z_dim1 + 1], &c__1, &z__[(jch
  1144. - 1) * z_dim1 + 1], &c__1, &c__, &s);
  1145. }
  1146. /* L50: */
  1147. }
  1148. goto L70;
  1149. }
  1150. } else if (ilazro) {
  1151. /* Only test 1 passed -- work on J:ILAST */
  1152. ifirst = j;
  1153. goto L110;
  1154. }
  1155. /* Neither test passed -- try next J */
  1156. /* L60: */
  1157. }
  1158. /* (Drop-through is "impossible") */
  1159. *info = *n + 1;
  1160. goto L420;
  1161. /* T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a */
  1162. /* 1x1 block. */
  1163. L70:
  1164. temp = h__[ilast + ilast * h_dim1];
  1165. slartg_(&temp, &h__[ilast + (ilast - 1) * h_dim1], &c__, &s, &h__[
  1166. ilast + ilast * h_dim1]);
  1167. h__[ilast + (ilast - 1) * h_dim1] = 0.f;
  1168. i__2 = ilast - ifrstm;
  1169. srot_(&i__2, &h__[ifrstm + ilast * h_dim1], &c__1, &h__[ifrstm + (
  1170. ilast - 1) * h_dim1], &c__1, &c__, &s);
  1171. i__2 = ilast - ifrstm;
  1172. srot_(&i__2, &t[ifrstm + ilast * t_dim1], &c__1, &t[ifrstm + (ilast -
  1173. 1) * t_dim1], &c__1, &c__, &s);
  1174. if (ilz) {
  1175. srot_(n, &z__[ilast * z_dim1 + 1], &c__1, &z__[(ilast - 1) *
  1176. z_dim1 + 1], &c__1, &c__, &s);
  1177. }
  1178. /* H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHAR, ALPHAI, */
  1179. /* and BETA */
  1180. L80:
  1181. if (t[ilast + ilast * t_dim1] < 0.f) {
  1182. if (ilschr) {
  1183. i__2 = ilast;
  1184. for (j = ifrstm; j <= i__2; ++j) {
  1185. h__[j + ilast * h_dim1] = -h__[j + ilast * h_dim1];
  1186. t[j + ilast * t_dim1] = -t[j + ilast * t_dim1];
  1187. /* L90: */
  1188. }
  1189. } else {
  1190. h__[ilast + ilast * h_dim1] = -h__[ilast + ilast * h_dim1];
  1191. t[ilast + ilast * t_dim1] = -t[ilast + ilast * t_dim1];
  1192. }
  1193. if (ilz) {
  1194. i__2 = *n;
  1195. for (j = 1; j <= i__2; ++j) {
  1196. z__[j + ilast * z_dim1] = -z__[j + ilast * z_dim1];
  1197. /* L100: */
  1198. }
  1199. }
  1200. }
  1201. alphar[ilast] = h__[ilast + ilast * h_dim1];
  1202. alphai[ilast] = 0.f;
  1203. beta[ilast] = t[ilast + ilast * t_dim1];
  1204. /* Go to next block -- exit if finished. */
  1205. --ilast;
  1206. if (ilast < *ilo) {
  1207. goto L380;
  1208. }
  1209. /* Reset counters */
  1210. iiter = 0;
  1211. eshift = 0.f;
  1212. if (! ilschr) {
  1213. ilastm = ilast;
  1214. if (ifrstm > ilast) {
  1215. ifrstm = *ilo;
  1216. }
  1217. }
  1218. goto L350;
  1219. /* QZ step */
  1220. /* This iteration only involves rows/columns IFIRST:ILAST. We */
  1221. /* assume IFIRST < ILAST, and that the diagonal of B is non-zero. */
  1222. L110:
  1223. ++iiter;
  1224. if (! ilschr) {
  1225. ifrstm = ifirst;
  1226. }
  1227. /* Compute single shifts. */
  1228. /* At this point, IFIRST < ILAST, and the diagonal elements of */
  1229. /* T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in */
  1230. /* magnitude) */
  1231. if (iiter / 10 * 10 == iiter) {
  1232. /* Exceptional shift. Chosen for no particularly good reason. */
  1233. /* (Single shift only.) */
  1234. if ((real) maxit * safmin * (r__1 = h__[ilast + (ilast - 1) *
  1235. h_dim1], abs(r__1)) < (r__2 = t[ilast - 1 + (ilast - 1) *
  1236. t_dim1], abs(r__2))) {
  1237. eshift = h__[ilast + (ilast - 1) * h_dim1] / t[ilast - 1 + (
  1238. ilast - 1) * t_dim1];
  1239. } else {
  1240. eshift += 1.f / (safmin * (real) maxit);
  1241. }
  1242. s1 = 1.f;
  1243. wr = eshift;
  1244. } else {
  1245. /* Shifts based on the generalized eigenvalues of the */
  1246. /* bottom-right 2x2 block of A and B. The first eigenvalue */
  1247. /* returned by SLAG2 is the Wilkinson shift (AEP p.512), */
  1248. r__1 = safmin * 100.f;
  1249. slag2_(&h__[ilast - 1 + (ilast - 1) * h_dim1], ldh, &t[ilast - 1
  1250. + (ilast - 1) * t_dim1], ldt, &r__1, &s1, &s2, &wr, &wr2,
  1251. &wi);
  1252. if ((r__1 = wr / s1 * t[ilast + ilast * t_dim1] - h__[ilast +
  1253. ilast * h_dim1], abs(r__1)) > (r__2 = wr2 / s2 * t[ilast
  1254. + ilast * t_dim1] - h__[ilast + ilast * h_dim1], abs(r__2)
  1255. )) {
  1256. temp = wr;
  1257. wr = wr2;
  1258. wr2 = temp;
  1259. temp = s1;
  1260. s1 = s2;
  1261. s2 = temp;
  1262. }
  1263. /* Computing MAX */
  1264. /* Computing MAX */
  1265. r__3 = 1.f, r__4 = abs(wr), r__3 = f2cmax(r__3,r__4), r__4 = abs(wi);
  1266. r__1 = s1, r__2 = safmin * f2cmax(r__3,r__4);
  1267. temp = f2cmax(r__1,r__2);
  1268. if (wi != 0.f) {
  1269. goto L200;
  1270. }
  1271. }
  1272. /* Fiddle with shift to avoid overflow */
  1273. temp = f2cmin(ascale,1.f) * (safmax * .5f);
  1274. if (s1 > temp) {
  1275. scale = temp / s1;
  1276. } else {
  1277. scale = 1.f;
  1278. }
  1279. temp = f2cmin(bscale,1.f) * (safmax * .5f);
  1280. if (abs(wr) > temp) {
  1281. /* Computing MIN */
  1282. r__1 = scale, r__2 = temp / abs(wr);
  1283. scale = f2cmin(r__1,r__2);
  1284. }
  1285. s1 = scale * s1;
  1286. wr = scale * wr;
  1287. /* Now check for two consecutive small subdiagonals. */
  1288. i__2 = ifirst + 1;
  1289. for (j = ilast - 1; j >= i__2; --j) {
  1290. istart = j;
  1291. temp = (r__1 = s1 * h__[j + (j - 1) * h_dim1], abs(r__1));
  1292. temp2 = (r__1 = s1 * h__[j + j * h_dim1] - wr * t[j + j * t_dim1],
  1293. abs(r__1));
  1294. tempr = f2cmax(temp,temp2);
  1295. if (tempr < 1.f && tempr != 0.f) {
  1296. temp /= tempr;
  1297. temp2 /= tempr;
  1298. }
  1299. if ((r__1 = ascale * h__[j + 1 + j * h_dim1] * temp, abs(r__1)) <=
  1300. ascale * atol * temp2) {
  1301. goto L130;
  1302. }
  1303. /* L120: */
  1304. }
  1305. istart = ifirst;
  1306. L130:
  1307. /* Do an implicit single-shift QZ sweep. */
  1308. /* Initial Q */
  1309. temp = s1 * h__[istart + istart * h_dim1] - wr * t[istart + istart *
  1310. t_dim1];
  1311. temp2 = s1 * h__[istart + 1 + istart * h_dim1];
  1312. slartg_(&temp, &temp2, &c__, &s, &tempr);
  1313. /* Sweep */
  1314. i__2 = ilast - 1;
  1315. for (j = istart; j <= i__2; ++j) {
  1316. if (j > istart) {
  1317. temp = h__[j + (j - 1) * h_dim1];
  1318. slartg_(&temp, &h__[j + 1 + (j - 1) * h_dim1], &c__, &s, &h__[
  1319. j + (j - 1) * h_dim1]);
  1320. h__[j + 1 + (j - 1) * h_dim1] = 0.f;
  1321. }
  1322. i__3 = ilastm;
  1323. for (jc = j; jc <= i__3; ++jc) {
  1324. temp = c__ * h__[j + jc * h_dim1] + s * h__[j + 1 + jc *
  1325. h_dim1];
  1326. h__[j + 1 + jc * h_dim1] = -s * h__[j + jc * h_dim1] + c__ *
  1327. h__[j + 1 + jc * h_dim1];
  1328. h__[j + jc * h_dim1] = temp;
  1329. temp2 = c__ * t[j + jc * t_dim1] + s * t[j + 1 + jc * t_dim1];
  1330. t[j + 1 + jc * t_dim1] = -s * t[j + jc * t_dim1] + c__ * t[j
  1331. + 1 + jc * t_dim1];
  1332. t[j + jc * t_dim1] = temp2;
  1333. /* L140: */
  1334. }
  1335. if (ilq) {
  1336. i__3 = *n;
  1337. for (jr = 1; jr <= i__3; ++jr) {
  1338. temp = c__ * q[jr + j * q_dim1] + s * q[jr + (j + 1) *
  1339. q_dim1];
  1340. q[jr + (j + 1) * q_dim1] = -s * q[jr + j * q_dim1] + c__ *
  1341. q[jr + (j + 1) * q_dim1];
  1342. q[jr + j * q_dim1] = temp;
  1343. /* L150: */
  1344. }
  1345. }
  1346. temp = t[j + 1 + (j + 1) * t_dim1];
  1347. slartg_(&temp, &t[j + 1 + j * t_dim1], &c__, &s, &t[j + 1 + (j +
  1348. 1) * t_dim1]);
  1349. t[j + 1 + j * t_dim1] = 0.f;
  1350. /* Computing MIN */
  1351. i__4 = j + 2;
  1352. i__3 = f2cmin(i__4,ilast);
  1353. for (jr = ifrstm; jr <= i__3; ++jr) {
  1354. temp = c__ * h__[jr + (j + 1) * h_dim1] + s * h__[jr + j *
  1355. h_dim1];
  1356. h__[jr + j * h_dim1] = -s * h__[jr + (j + 1) * h_dim1] + c__ *
  1357. h__[jr + j * h_dim1];
  1358. h__[jr + (j + 1) * h_dim1] = temp;
  1359. /* L160: */
  1360. }
  1361. i__3 = j;
  1362. for (jr = ifrstm; jr <= i__3; ++jr) {
  1363. temp = c__ * t[jr + (j + 1) * t_dim1] + s * t[jr + j * t_dim1]
  1364. ;
  1365. t[jr + j * t_dim1] = -s * t[jr + (j + 1) * t_dim1] + c__ * t[
  1366. jr + j * t_dim1];
  1367. t[jr + (j + 1) * t_dim1] = temp;
  1368. /* L170: */
  1369. }
  1370. if (ilz) {
  1371. i__3 = *n;
  1372. for (jr = 1; jr <= i__3; ++jr) {
  1373. temp = c__ * z__[jr + (j + 1) * z_dim1] + s * z__[jr + j *
  1374. z_dim1];
  1375. z__[jr + j * z_dim1] = -s * z__[jr + (j + 1) * z_dim1] +
  1376. c__ * z__[jr + j * z_dim1];
  1377. z__[jr + (j + 1) * z_dim1] = temp;
  1378. /* L180: */
  1379. }
  1380. }
  1381. /* L190: */
  1382. }
  1383. goto L350;
  1384. /* Use Francis double-shift */
  1385. /* Note: the Francis double-shift should work with real shifts, */
  1386. /* but only if the block is at least 3x3. */
  1387. /* This code may break if this point is reached with */
  1388. /* a 2x2 block with real eigenvalues. */
  1389. L200:
  1390. if (ifirst + 1 == ilast) {
  1391. /* Special case -- 2x2 block with complex eigenvectors */
  1392. /* Step 1: Standardize, that is, rotate so that */
  1393. /* ( B11 0 ) */
  1394. /* B = ( ) with B11 non-negative. */
  1395. /* ( 0 B22 ) */
  1396. slasv2_(&t[ilast - 1 + (ilast - 1) * t_dim1], &t[ilast - 1 +
  1397. ilast * t_dim1], &t[ilast + ilast * t_dim1], &b22, &b11, &
  1398. sr, &cr, &sl, &cl);
  1399. if (b11 < 0.f) {
  1400. cr = -cr;
  1401. sr = -sr;
  1402. b11 = -b11;
  1403. b22 = -b22;
  1404. }
  1405. i__2 = ilastm + 1 - ifirst;
  1406. srot_(&i__2, &h__[ilast - 1 + (ilast - 1) * h_dim1], ldh, &h__[
  1407. ilast + (ilast - 1) * h_dim1], ldh, &cl, &sl);
  1408. i__2 = ilast + 1 - ifrstm;
  1409. srot_(&i__2, &h__[ifrstm + (ilast - 1) * h_dim1], &c__1, &h__[
  1410. ifrstm + ilast * h_dim1], &c__1, &cr, &sr);
  1411. if (ilast < ilastm) {
  1412. i__2 = ilastm - ilast;
  1413. srot_(&i__2, &t[ilast - 1 + (ilast + 1) * t_dim1], ldt, &t[
  1414. ilast + (ilast + 1) * t_dim1], ldt, &cl, &sl);
  1415. }
  1416. if (ifrstm < ilast - 1) {
  1417. i__2 = ifirst - ifrstm;
  1418. srot_(&i__2, &t[ifrstm + (ilast - 1) * t_dim1], &c__1, &t[
  1419. ifrstm + ilast * t_dim1], &c__1, &cr, &sr);
  1420. }
  1421. if (ilq) {
  1422. srot_(n, &q[(ilast - 1) * q_dim1 + 1], &c__1, &q[ilast *
  1423. q_dim1 + 1], &c__1, &cl, &sl);
  1424. }
  1425. if (ilz) {
  1426. srot_(n, &z__[(ilast - 1) * z_dim1 + 1], &c__1, &z__[ilast *
  1427. z_dim1 + 1], &c__1, &cr, &sr);
  1428. }
  1429. t[ilast - 1 + (ilast - 1) * t_dim1] = b11;
  1430. t[ilast - 1 + ilast * t_dim1] = 0.f;
  1431. t[ilast + (ilast - 1) * t_dim1] = 0.f;
  1432. t[ilast + ilast * t_dim1] = b22;
  1433. /* If B22 is negative, negate column ILAST */
  1434. if (b22 < 0.f) {
  1435. i__2 = ilast;
  1436. for (j = ifrstm; j <= i__2; ++j) {
  1437. h__[j + ilast * h_dim1] = -h__[j + ilast * h_dim1];
  1438. t[j + ilast * t_dim1] = -t[j + ilast * t_dim1];
  1439. /* L210: */
  1440. }
  1441. if (ilz) {
  1442. i__2 = *n;
  1443. for (j = 1; j <= i__2; ++j) {
  1444. z__[j + ilast * z_dim1] = -z__[j + ilast * z_dim1];
  1445. /* L220: */
  1446. }
  1447. }
  1448. b22 = -b22;
  1449. }
  1450. /* Step 2: Compute ALPHAR, ALPHAI, and BETA (see refs.) */
  1451. /* Recompute shift */
  1452. r__1 = safmin * 100.f;
  1453. slag2_(&h__[ilast - 1 + (ilast - 1) * h_dim1], ldh, &t[ilast - 1
  1454. + (ilast - 1) * t_dim1], ldt, &r__1, &s1, &temp, &wr, &
  1455. temp2, &wi);
  1456. /* If standardization has perturbed the shift onto real line, */
  1457. /* do another (real single-shift) QR step. */
  1458. if (wi == 0.f) {
  1459. goto L350;
  1460. }
  1461. s1inv = 1.f / s1;
  1462. /* Do EISPACK (QZVAL) computation of alpha and beta */
  1463. a11 = h__[ilast - 1 + (ilast - 1) * h_dim1];
  1464. a21 = h__[ilast + (ilast - 1) * h_dim1];
  1465. a12 = h__[ilast - 1 + ilast * h_dim1];
  1466. a22 = h__[ilast + ilast * h_dim1];
  1467. /* Compute complex Givens rotation on right */
  1468. /* (Assume some element of C = (sA - wB) > unfl ) */
  1469. /* __ */
  1470. /* (sA - wB) ( CZ -SZ ) */
  1471. /* ( SZ CZ ) */
  1472. c11r = s1 * a11 - wr * b11;
  1473. c11i = -wi * b11;
  1474. c12 = s1 * a12;
  1475. c21 = s1 * a21;
  1476. c22r = s1 * a22 - wr * b22;
  1477. c22i = -wi * b22;
  1478. if (abs(c11r) + abs(c11i) + abs(c12) > abs(c21) + abs(c22r) + abs(
  1479. c22i)) {
  1480. t1 = slapy3_(&c12, &c11r, &c11i);
  1481. cz = c12 / t1;
  1482. szr = -c11r / t1;
  1483. szi = -c11i / t1;
  1484. } else {
  1485. cz = slapy2_(&c22r, &c22i);
  1486. if (cz <= safmin) {
  1487. cz = 0.f;
  1488. szr = 1.f;
  1489. szi = 0.f;
  1490. } else {
  1491. tempr = c22r / cz;
  1492. tempi = c22i / cz;
  1493. t1 = slapy2_(&cz, &c21);
  1494. cz /= t1;
  1495. szr = -c21 * tempr / t1;
  1496. szi = c21 * tempi / t1;
  1497. }
  1498. }
  1499. /* Compute Givens rotation on left */
  1500. /* ( CQ SQ ) */
  1501. /* ( __ ) A or B */
  1502. /* ( -SQ CQ ) */
  1503. an = abs(a11) + abs(a12) + abs(a21) + abs(a22);
  1504. bn = abs(b11) + abs(b22);
  1505. wabs = abs(wr) + abs(wi);
  1506. if (s1 * an > wabs * bn) {
  1507. cq = cz * b11;
  1508. sqr = szr * b22;
  1509. sqi = -szi * b22;
  1510. } else {
  1511. a1r = cz * a11 + szr * a12;
  1512. a1i = szi * a12;
  1513. a2r = cz * a21 + szr * a22;
  1514. a2i = szi * a22;
  1515. cq = slapy2_(&a1r, &a1i);
  1516. if (cq <= safmin) {
  1517. cq = 0.f;
  1518. sqr = 1.f;
  1519. sqi = 0.f;
  1520. } else {
  1521. tempr = a1r / cq;
  1522. tempi = a1i / cq;
  1523. sqr = tempr * a2r + tempi * a2i;
  1524. sqi = tempi * a2r - tempr * a2i;
  1525. }
  1526. }
  1527. t1 = slapy3_(&cq, &sqr, &sqi);
  1528. cq /= t1;
  1529. sqr /= t1;
  1530. sqi /= t1;
  1531. /* Compute diagonal elements of QBZ */
  1532. tempr = sqr * szr - sqi * szi;
  1533. tempi = sqr * szi + sqi * szr;
  1534. b1r = cq * cz * b11 + tempr * b22;
  1535. b1i = tempi * b22;
  1536. b1a = slapy2_(&b1r, &b1i);
  1537. b2r = cq * cz * b22 + tempr * b11;
  1538. b2i = -tempi * b11;
  1539. b2a = slapy2_(&b2r, &b2i);
  1540. /* Normalize so beta > 0, and Im( alpha1 ) > 0 */
  1541. beta[ilast - 1] = b1a;
  1542. beta[ilast] = b2a;
  1543. alphar[ilast - 1] = wr * b1a * s1inv;
  1544. alphai[ilast - 1] = wi * b1a * s1inv;
  1545. alphar[ilast] = wr * b2a * s1inv;
  1546. alphai[ilast] = -(wi * b2a) * s1inv;
  1547. /* Step 3: Go to next block -- exit if finished. */
  1548. ilast = ifirst - 1;
  1549. if (ilast < *ilo) {
  1550. goto L380;
  1551. }
  1552. /* Reset counters */
  1553. iiter = 0;
  1554. eshift = 0.f;
  1555. if (! ilschr) {
  1556. ilastm = ilast;
  1557. if (ifrstm > ilast) {
  1558. ifrstm = *ilo;
  1559. }
  1560. }
  1561. goto L350;
  1562. } else {
  1563. /* Usual case: 3x3 or larger block, using Francis implicit */
  1564. /* double-shift */
  1565. /* 2 */
  1566. /* Eigenvalue equation is w - c w + d = 0, */
  1567. /* -1 2 -1 */
  1568. /* so compute 1st column of (A B ) - c A B + d */
  1569. /* using the formula in QZIT (from EISPACK) */
  1570. /* We assume that the block is at least 3x3 */
  1571. ad11 = ascale * h__[ilast - 1 + (ilast - 1) * h_dim1] / (bscale *
  1572. t[ilast - 1 + (ilast - 1) * t_dim1]);
  1573. ad21 = ascale * h__[ilast + (ilast - 1) * h_dim1] / (bscale * t[
  1574. ilast - 1 + (ilast - 1) * t_dim1]);
  1575. ad12 = ascale * h__[ilast - 1 + ilast * h_dim1] / (bscale * t[
  1576. ilast + ilast * t_dim1]);
  1577. ad22 = ascale * h__[ilast + ilast * h_dim1] / (bscale * t[ilast +
  1578. ilast * t_dim1]);
  1579. u12 = t[ilast - 1 + ilast * t_dim1] / t[ilast + ilast * t_dim1];
  1580. ad11l = ascale * h__[ifirst + ifirst * h_dim1] / (bscale * t[
  1581. ifirst + ifirst * t_dim1]);
  1582. ad21l = ascale * h__[ifirst + 1 + ifirst * h_dim1] / (bscale * t[
  1583. ifirst + ifirst * t_dim1]);
  1584. ad12l = ascale * h__[ifirst + (ifirst + 1) * h_dim1] / (bscale *
  1585. t[ifirst + 1 + (ifirst + 1) * t_dim1]);
  1586. ad22l = ascale * h__[ifirst + 1 + (ifirst + 1) * h_dim1] / (
  1587. bscale * t[ifirst + 1 + (ifirst + 1) * t_dim1]);
  1588. ad32l = ascale * h__[ifirst + 2 + (ifirst + 1) * h_dim1] / (
  1589. bscale * t[ifirst + 1 + (ifirst + 1) * t_dim1]);
  1590. u12l = t[ifirst + (ifirst + 1) * t_dim1] / t[ifirst + 1 + (ifirst
  1591. + 1) * t_dim1];
  1592. v[0] = (ad11 - ad11l) * (ad22 - ad11l) - ad12 * ad21 + ad21 * u12
  1593. * ad11l + (ad12l - ad11l * u12l) * ad21l;
  1594. v[1] = (ad22l - ad11l - ad21l * u12l - (ad11 - ad11l) - (ad22 -
  1595. ad11l) + ad21 * u12) * ad21l;
  1596. v[2] = ad32l * ad21l;
  1597. istart = ifirst;
  1598. slarfg_(&c__3, v, &v[1], &c__1, &tau);
  1599. v[0] = 1.f;
  1600. /* Sweep */
  1601. i__2 = ilast - 2;
  1602. for (j = istart; j <= i__2; ++j) {
  1603. /* All but last elements: use 3x3 Householder transforms. */
  1604. /* Zero (j-1)st column of A */
  1605. if (j > istart) {
  1606. v[0] = h__[j + (j - 1) * h_dim1];
  1607. v[1] = h__[j + 1 + (j - 1) * h_dim1];
  1608. v[2] = h__[j + 2 + (j - 1) * h_dim1];
  1609. slarfg_(&c__3, &h__[j + (j - 1) * h_dim1], &v[1], &c__1, &
  1610. tau);
  1611. v[0] = 1.f;
  1612. h__[j + 1 + (j - 1) * h_dim1] = 0.f;
  1613. h__[j + 2 + (j - 1) * h_dim1] = 0.f;
  1614. }
  1615. i__3 = ilastm;
  1616. for (jc = j; jc <= i__3; ++jc) {
  1617. temp = tau * (h__[j + jc * h_dim1] + v[1] * h__[j + 1 +
  1618. jc * h_dim1] + v[2] * h__[j + 2 + jc * h_dim1]);
  1619. h__[j + jc * h_dim1] -= temp;
  1620. h__[j + 1 + jc * h_dim1] -= temp * v[1];
  1621. h__[j + 2 + jc * h_dim1] -= temp * v[2];
  1622. temp2 = tau * (t[j + jc * t_dim1] + v[1] * t[j + 1 + jc *
  1623. t_dim1] + v[2] * t[j + 2 + jc * t_dim1]);
  1624. t[j + jc * t_dim1] -= temp2;
  1625. t[j + 1 + jc * t_dim1] -= temp2 * v[1];
  1626. t[j + 2 + jc * t_dim1] -= temp2 * v[2];
  1627. /* L230: */
  1628. }
  1629. if (ilq) {
  1630. i__3 = *n;
  1631. for (jr = 1; jr <= i__3; ++jr) {
  1632. temp = tau * (q[jr + j * q_dim1] + v[1] * q[jr + (j +
  1633. 1) * q_dim1] + v[2] * q[jr + (j + 2) * q_dim1]
  1634. );
  1635. q[jr + j * q_dim1] -= temp;
  1636. q[jr + (j + 1) * q_dim1] -= temp * v[1];
  1637. q[jr + (j + 2) * q_dim1] -= temp * v[2];
  1638. /* L240: */
  1639. }
  1640. }
  1641. /* Zero j-th column of B (see SLAGBC for details) */
  1642. /* Swap rows to pivot */
  1643. ilpivt = FALSE_;
  1644. /* Computing MAX */
  1645. r__3 = (r__1 = t[j + 1 + (j + 1) * t_dim1], abs(r__1)), r__4 =
  1646. (r__2 = t[j + 1 + (j + 2) * t_dim1], abs(r__2));
  1647. temp = f2cmax(r__3,r__4);
  1648. /* Computing MAX */
  1649. r__3 = (r__1 = t[j + 2 + (j + 1) * t_dim1], abs(r__1)), r__4 =
  1650. (r__2 = t[j + 2 + (j + 2) * t_dim1], abs(r__2));
  1651. temp2 = f2cmax(r__3,r__4);
  1652. if (f2cmax(temp,temp2) < safmin) {
  1653. scale = 0.f;
  1654. u1 = 1.f;
  1655. u2 = 0.f;
  1656. goto L250;
  1657. } else if (temp >= temp2) {
  1658. w11 = t[j + 1 + (j + 1) * t_dim1];
  1659. w21 = t[j + 2 + (j + 1) * t_dim1];
  1660. w12 = t[j + 1 + (j + 2) * t_dim1];
  1661. w22 = t[j + 2 + (j + 2) * t_dim1];
  1662. u1 = t[j + 1 + j * t_dim1];
  1663. u2 = t[j + 2 + j * t_dim1];
  1664. } else {
  1665. w21 = t[j + 1 + (j + 1) * t_dim1];
  1666. w11 = t[j + 2 + (j + 1) * t_dim1];
  1667. w22 = t[j + 1 + (j + 2) * t_dim1];
  1668. w12 = t[j + 2 + (j + 2) * t_dim1];
  1669. u2 = t[j + 1 + j * t_dim1];
  1670. u1 = t[j + 2 + j * t_dim1];
  1671. }
  1672. /* Swap columns if nec. */
  1673. if (abs(w12) > abs(w11)) {
  1674. ilpivt = TRUE_;
  1675. temp = w12;
  1676. temp2 = w22;
  1677. w12 = w11;
  1678. w22 = w21;
  1679. w11 = temp;
  1680. w21 = temp2;
  1681. }
  1682. /* LU-factor */
  1683. temp = w21 / w11;
  1684. u2 -= temp * u1;
  1685. w22 -= temp * w12;
  1686. w21 = 0.f;
  1687. /* Compute SCALE */
  1688. scale = 1.f;
  1689. if (abs(w22) < safmin) {
  1690. scale = 0.f;
  1691. u2 = 1.f;
  1692. u1 = -w12 / w11;
  1693. goto L250;
  1694. }
  1695. if (abs(w22) < abs(u2)) {
  1696. scale = (r__1 = w22 / u2, abs(r__1));
  1697. }
  1698. if (abs(w11) < abs(u1)) {
  1699. /* Computing MIN */
  1700. r__2 = scale, r__3 = (r__1 = w11 / u1, abs(r__1));
  1701. scale = f2cmin(r__2,r__3);
  1702. }
  1703. /* Solve */
  1704. u2 = scale * u2 / w22;
  1705. u1 = (scale * u1 - w12 * u2) / w11;
  1706. L250:
  1707. if (ilpivt) {
  1708. temp = u2;
  1709. u2 = u1;
  1710. u1 = temp;
  1711. }
  1712. /* Compute Householder Vector */
  1713. /* Computing 2nd power */
  1714. r__1 = scale;
  1715. /* Computing 2nd power */
  1716. r__2 = u1;
  1717. /* Computing 2nd power */
  1718. r__3 = u2;
  1719. t1 = sqrt(r__1 * r__1 + r__2 * r__2 + r__3 * r__3);
  1720. tau = scale / t1 + 1.f;
  1721. vs = -1.f / (scale + t1);
  1722. v[0] = 1.f;
  1723. v[1] = vs * u1;
  1724. v[2] = vs * u2;
  1725. /* Apply transformations from the right. */
  1726. /* Computing MIN */
  1727. i__4 = j + 3;
  1728. i__3 = f2cmin(i__4,ilast);
  1729. for (jr = ifrstm; jr <= i__3; ++jr) {
  1730. temp = tau * (h__[jr + j * h_dim1] + v[1] * h__[jr + (j +
  1731. 1) * h_dim1] + v[2] * h__[jr + (j + 2) * h_dim1]);
  1732. h__[jr + j * h_dim1] -= temp;
  1733. h__[jr + (j + 1) * h_dim1] -= temp * v[1];
  1734. h__[jr + (j + 2) * h_dim1] -= temp * v[2];
  1735. /* L260: */
  1736. }
  1737. i__3 = j + 2;
  1738. for (jr = ifrstm; jr <= i__3; ++jr) {
  1739. temp = tau * (t[jr + j * t_dim1] + v[1] * t[jr + (j + 1) *
  1740. t_dim1] + v[2] * t[jr + (j + 2) * t_dim1]);
  1741. t[jr + j * t_dim1] -= temp;
  1742. t[jr + (j + 1) * t_dim1] -= temp * v[1];
  1743. t[jr + (j + 2) * t_dim1] -= temp * v[2];
  1744. /* L270: */
  1745. }
  1746. if (ilz) {
  1747. i__3 = *n;
  1748. for (jr = 1; jr <= i__3; ++jr) {
  1749. temp = tau * (z__[jr + j * z_dim1] + v[1] * z__[jr + (
  1750. j + 1) * z_dim1] + v[2] * z__[jr + (j + 2) *
  1751. z_dim1]);
  1752. z__[jr + j * z_dim1] -= temp;
  1753. z__[jr + (j + 1) * z_dim1] -= temp * v[1];
  1754. z__[jr + (j + 2) * z_dim1] -= temp * v[2];
  1755. /* L280: */
  1756. }
  1757. }
  1758. t[j + 1 + j * t_dim1] = 0.f;
  1759. t[j + 2 + j * t_dim1] = 0.f;
  1760. /* L290: */
  1761. }
  1762. /* Last elements: Use Givens rotations */
  1763. /* Rotations from the left */
  1764. j = ilast - 1;
  1765. temp = h__[j + (j - 1) * h_dim1];
  1766. slartg_(&temp, &h__[j + 1 + (j - 1) * h_dim1], &c__, &s, &h__[j +
  1767. (j - 1) * h_dim1]);
  1768. h__[j + 1 + (j - 1) * h_dim1] = 0.f;
  1769. i__2 = ilastm;
  1770. for (jc = j; jc <= i__2; ++jc) {
  1771. temp = c__ * h__[j + jc * h_dim1] + s * h__[j + 1 + jc *
  1772. h_dim1];
  1773. h__[j + 1 + jc * h_dim1] = -s * h__[j + jc * h_dim1] + c__ *
  1774. h__[j + 1 + jc * h_dim1];
  1775. h__[j + jc * h_dim1] = temp;
  1776. temp2 = c__ * t[j + jc * t_dim1] + s * t[j + 1 + jc * t_dim1];
  1777. t[j + 1 + jc * t_dim1] = -s * t[j + jc * t_dim1] + c__ * t[j
  1778. + 1 + jc * t_dim1];
  1779. t[j + jc * t_dim1] = temp2;
  1780. /* L300: */
  1781. }
  1782. if (ilq) {
  1783. i__2 = *n;
  1784. for (jr = 1; jr <= i__2; ++jr) {
  1785. temp = c__ * q[jr + j * q_dim1] + s * q[jr + (j + 1) *
  1786. q_dim1];
  1787. q[jr + (j + 1) * q_dim1] = -s * q[jr + j * q_dim1] + c__ *
  1788. q[jr + (j + 1) * q_dim1];
  1789. q[jr + j * q_dim1] = temp;
  1790. /* L310: */
  1791. }
  1792. }
  1793. /* Rotations from the right. */
  1794. temp = t[j + 1 + (j + 1) * t_dim1];
  1795. slartg_(&temp, &t[j + 1 + j * t_dim1], &c__, &s, &t[j + 1 + (j +
  1796. 1) * t_dim1]);
  1797. t[j + 1 + j * t_dim1] = 0.f;
  1798. i__2 = ilast;
  1799. for (jr = ifrstm; jr <= i__2; ++jr) {
  1800. temp = c__ * h__[jr + (j + 1) * h_dim1] + s * h__[jr + j *
  1801. h_dim1];
  1802. h__[jr + j * h_dim1] = -s * h__[jr + (j + 1) * h_dim1] + c__ *
  1803. h__[jr + j * h_dim1];
  1804. h__[jr + (j + 1) * h_dim1] = temp;
  1805. /* L320: */
  1806. }
  1807. i__2 = ilast - 1;
  1808. for (jr = ifrstm; jr <= i__2; ++jr) {
  1809. temp = c__ * t[jr + (j + 1) * t_dim1] + s * t[jr + j * t_dim1]
  1810. ;
  1811. t[jr + j * t_dim1] = -s * t[jr + (j + 1) * t_dim1] + c__ * t[
  1812. jr + j * t_dim1];
  1813. t[jr + (j + 1) * t_dim1] = temp;
  1814. /* L330: */
  1815. }
  1816. if (ilz) {
  1817. i__2 = *n;
  1818. for (jr = 1; jr <= i__2; ++jr) {
  1819. temp = c__ * z__[jr + (j + 1) * z_dim1] + s * z__[jr + j *
  1820. z_dim1];
  1821. z__[jr + j * z_dim1] = -s * z__[jr + (j + 1) * z_dim1] +
  1822. c__ * z__[jr + j * z_dim1];
  1823. z__[jr + (j + 1) * z_dim1] = temp;
  1824. /* L340: */
  1825. }
  1826. }
  1827. /* End of Double-Shift code */
  1828. }
  1829. goto L350;
  1830. /* End of iteration loop */
  1831. L350:
  1832. /* L360: */
  1833. ;
  1834. }
  1835. /* Drop-through = non-convergence */
  1836. *info = ilast;
  1837. goto L420;
  1838. /* Successful completion of all QZ steps */
  1839. L380:
  1840. /* Set Eigenvalues 1:ILO-1 */
  1841. i__1 = *ilo - 1;
  1842. for (j = 1; j <= i__1; ++j) {
  1843. if (t[j + j * t_dim1] < 0.f) {
  1844. if (ilschr) {
  1845. i__2 = j;
  1846. for (jr = 1; jr <= i__2; ++jr) {
  1847. h__[jr + j * h_dim1] = -h__[jr + j * h_dim1];
  1848. t[jr + j * t_dim1] = -t[jr + j * t_dim1];
  1849. /* L390: */
  1850. }
  1851. } else {
  1852. h__[j + j * h_dim1] = -h__[j + j * h_dim1];
  1853. t[j + j * t_dim1] = -t[j + j * t_dim1];
  1854. }
  1855. if (ilz) {
  1856. i__2 = *n;
  1857. for (jr = 1; jr <= i__2; ++jr) {
  1858. z__[jr + j * z_dim1] = -z__[jr + j * z_dim1];
  1859. /* L400: */
  1860. }
  1861. }
  1862. }
  1863. alphar[j] = h__[j + j * h_dim1];
  1864. alphai[j] = 0.f;
  1865. beta[j] = t[j + j * t_dim1];
  1866. /* L410: */
  1867. }
  1868. /* Normal Termination */
  1869. *info = 0;
  1870. /* Exit (other than argument error) -- return optimal workspace size */
  1871. L420:
  1872. work[1] = (real) (*n);
  1873. return 0;
  1874. /* End of SHGEQZ */
  1875. } /* shgeqz_ */