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.

sgghd3.c 47 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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 integer c__1 = 1;
  487. static integer c_n1 = -1;
  488. static real c_b14 = 0.f;
  489. static real c_b15 = 1.f;
  490. static integer c__2 = 2;
  491. static integer c__3 = 3;
  492. static integer c__16 = 16;
  493. /* > \brief \b SGGHD3 */
  494. /* =========== DOCUMENTATION =========== */
  495. /* Online html documentation available at */
  496. /* http://www.netlib.org/lapack/explore-html/ */
  497. /* > \htmlonly */
  498. /* > Download SGGHRD + dependencies */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgghd3.
  500. f"> */
  501. /* > [TGZ]</a> */
  502. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgghd3.
  503. f"> */
  504. /* > [ZIP]</a> */
  505. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgghd3.
  506. f"> */
  507. /* > [TXT]</a> */
  508. /* > \endhtmlonly */
  509. /* Definition: */
  510. /* =========== */
  511. /* SUBROUTINE SGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, */
  512. /* LDQ, Z, LDZ, WORK, LWORK, INFO ) */
  513. /* CHARACTER COMPQ, COMPZ */
  514. /* INTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N, LWORK */
  515. /* REAL A( LDA, * ), B( LDB, * ), Q( LDQ, * ), */
  516. /* $ Z( LDZ, * ), WORK( * ) */
  517. /* > \par Purpose: */
  518. /* ============= */
  519. /* > */
  520. /* > \verbatim */
  521. /* > */
  522. /* > SGGHD3 reduces a pair of real matrices (A,B) to generalized upper */
  523. /* > Hessenberg form using orthogonal transformations, where A is a */
  524. /* > general matrix and B is upper triangular. The form of the */
  525. /* > generalized eigenvalue problem is */
  526. /* > A*x = lambda*B*x, */
  527. /* > and B is typically made upper triangular by computing its QR */
  528. /* > factorization and moving the orthogonal matrix Q to the left side */
  529. /* > of the equation. */
  530. /* > */
  531. /* > This subroutine simultaneously reduces A to a Hessenberg matrix H: */
  532. /* > Q**T*A*Z = H */
  533. /* > and transforms B to another upper triangular matrix T: */
  534. /* > Q**T*B*Z = T */
  535. /* > in order to reduce the problem to its standard form */
  536. /* > H*y = lambda*T*y */
  537. /* > where y = Z**T*x. */
  538. /* > */
  539. /* > The orthogonal matrices Q and Z are determined as products of Givens */
  540. /* > rotations. They may either be formed explicitly, or they may be */
  541. /* > postmultiplied into input matrices Q1 and Z1, so that */
  542. /* > */
  543. /* > Q1 * A * Z1**T = (Q1*Q) * H * (Z1*Z)**T */
  544. /* > */
  545. /* > Q1 * B * Z1**T = (Q1*Q) * T * (Z1*Z)**T */
  546. /* > */
  547. /* > If Q1 is the orthogonal matrix from the QR factorization of B in the */
  548. /* > original equation A*x = lambda*B*x, then SGGHD3 reduces the original */
  549. /* > problem to generalized Hessenberg form. */
  550. /* > */
  551. /* > This is a blocked variant of SGGHRD, using matrix-matrix */
  552. /* > multiplications for parts of the computation to enhance performance. */
  553. /* > \endverbatim */
  554. /* Arguments: */
  555. /* ========== */
  556. /* > \param[in] COMPQ */
  557. /* > \verbatim */
  558. /* > COMPQ is CHARACTER*1 */
  559. /* > = 'N': do not compute Q; */
  560. /* > = 'I': Q is initialized to the unit matrix, and the */
  561. /* > orthogonal matrix Q is returned; */
  562. /* > = 'V': Q must contain an orthogonal matrix Q1 on entry, */
  563. /* > and the product Q1*Q is returned. */
  564. /* > \endverbatim */
  565. /* > */
  566. /* > \param[in] COMPZ */
  567. /* > \verbatim */
  568. /* > COMPZ is CHARACTER*1 */
  569. /* > = 'N': do not compute Z; */
  570. /* > = 'I': Z is initialized to the unit matrix, and the */
  571. /* > orthogonal matrix Z is returned; */
  572. /* > = 'V': Z must contain an orthogonal matrix Z1 on entry, */
  573. /* > and the product Z1*Z is returned. */
  574. /* > \endverbatim */
  575. /* > */
  576. /* > \param[in] N */
  577. /* > \verbatim */
  578. /* > N is INTEGER */
  579. /* > The order of the matrices A and B. N >= 0. */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[in] ILO */
  583. /* > \verbatim */
  584. /* > ILO is INTEGER */
  585. /* > \endverbatim */
  586. /* > */
  587. /* > \param[in] IHI */
  588. /* > \verbatim */
  589. /* > IHI is INTEGER */
  590. /* > */
  591. /* > ILO and IHI mark the rows and columns of A which are to be */
  592. /* > reduced. It is assumed that A is already upper triangular */
  593. /* > in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are */
  594. /* > normally set by a previous call to SGGBAL; otherwise they */
  595. /* > should be set to 1 and N respectively. */
  596. /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
  597. /* > \endverbatim */
  598. /* > */
  599. /* > \param[in,out] A */
  600. /* > \verbatim */
  601. /* > A is REAL array, dimension (LDA, N) */
  602. /* > On entry, the N-by-N general matrix to be reduced. */
  603. /* > On exit, the upper triangle and the first subdiagonal of A */
  604. /* > are overwritten with the upper Hessenberg matrix H, and the */
  605. /* > rest is set to zero. */
  606. /* > \endverbatim */
  607. /* > */
  608. /* > \param[in] LDA */
  609. /* > \verbatim */
  610. /* > LDA is INTEGER */
  611. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  612. /* > \endverbatim */
  613. /* > */
  614. /* > \param[in,out] B */
  615. /* > \verbatim */
  616. /* > B is REAL array, dimension (LDB, N) */
  617. /* > On entry, the N-by-N upper triangular matrix B. */
  618. /* > On exit, the upper triangular matrix T = Q**T B Z. The */
  619. /* > elements below the diagonal are set to zero. */
  620. /* > \endverbatim */
  621. /* > */
  622. /* > \param[in] LDB */
  623. /* > \verbatim */
  624. /* > LDB is INTEGER */
  625. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  626. /* > \endverbatim */
  627. /* > */
  628. /* > \param[in,out] Q */
  629. /* > \verbatim */
  630. /* > Q is REAL array, dimension (LDQ, N) */
  631. /* > On entry, if COMPQ = 'V', the orthogonal matrix Q1, */
  632. /* > typically from the QR factorization of B. */
  633. /* > On exit, if COMPQ='I', the orthogonal matrix Q, and if */
  634. /* > COMPQ = 'V', the product Q1*Q. */
  635. /* > Not referenced if COMPQ='N'. */
  636. /* > \endverbatim */
  637. /* > */
  638. /* > \param[in] LDQ */
  639. /* > \verbatim */
  640. /* > LDQ is INTEGER */
  641. /* > The leading dimension of the array Q. */
  642. /* > LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise. */
  643. /* > \endverbatim */
  644. /* > */
  645. /* > \param[in,out] Z */
  646. /* > \verbatim */
  647. /* > Z is REAL array, dimension (LDZ, N) */
  648. /* > On entry, if COMPZ = 'V', the orthogonal matrix Z1. */
  649. /* > On exit, if COMPZ='I', the orthogonal matrix Z, and if */
  650. /* > COMPZ = 'V', the product Z1*Z. */
  651. /* > Not referenced if COMPZ='N'. */
  652. /* > \endverbatim */
  653. /* > */
  654. /* > \param[in] LDZ */
  655. /* > \verbatim */
  656. /* > LDZ is INTEGER */
  657. /* > The leading dimension of the array Z. */
  658. /* > LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise. */
  659. /* > \endverbatim */
  660. /* > */
  661. /* > \param[out] WORK */
  662. /* > \verbatim */
  663. /* > WORK is REAL array, dimension (LWORK) */
  664. /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  665. /* > \endverbatim */
  666. /* > */
  667. /* > \param[in] LWORK */
  668. /* > \verbatim */
  669. /* > LWORK is INTEGER */
  670. /* > The length of the array WORK. LWORK >= 1. */
  671. /* > For optimum performance LWORK >= 6*N*NB, where NB is the */
  672. /* > optimal blocksize. */
  673. /* > */
  674. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  675. /* > only calculates the optimal size of the WORK array, returns */
  676. /* > this value as the first entry of the WORK array, and no error */
  677. /* > message related to LWORK is issued by XERBLA. */
  678. /* > \endverbatim */
  679. /* > */
  680. /* > \param[out] INFO */
  681. /* > \verbatim */
  682. /* > INFO is INTEGER */
  683. /* > = 0: successful exit. */
  684. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  685. /* > \endverbatim */
  686. /* Authors: */
  687. /* ======== */
  688. /* > \author Univ. of Tennessee */
  689. /* > \author Univ. of California Berkeley */
  690. /* > \author Univ. of Colorado Denver */
  691. /* > \author NAG Ltd. */
  692. /* > \date January 2015 */
  693. /* > \ingroup realOTHERcomputational */
  694. /* > \par Further Details: */
  695. /* ===================== */
  696. /* > */
  697. /* > \verbatim */
  698. /* > */
  699. /* > This routine reduces A to Hessenberg form and maintains B in */
  700. /* > using a blocked variant of Moler and Stewart's original algorithm, */
  701. /* > as described by Kagstrom, Kressner, Quintana-Orti, and Quintana-Orti */
  702. /* > (BIT 2008). */
  703. /* > \endverbatim */
  704. /* > */
  705. /* ===================================================================== */
  706. /* Subroutine */ void sgghd3_(char *compq, char *compz, integer *n, integer *
  707. ilo, integer *ihi, real *a, integer *lda, real *b, integer *ldb, real
  708. *q, integer *ldq, real *z__, integer *ldz, real *work, integer *lwork,
  709. integer *info)
  710. {
  711. /* System generated locals */
  712. integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, z_dim1,
  713. z_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7, i__8;
  714. real r__1;
  715. /* Local variables */
  716. logical blk22;
  717. integer cola, jcol, ierr;
  718. real temp;
  719. integer jrow, topq, ppwo;
  720. extern /* Subroutine */ void srot_(integer *, real *, integer *, real *,
  721. integer *, real *, real *);
  722. real temp1, temp2, temp3, c__;
  723. integer kacc22, i__, j, k;
  724. real s;
  725. extern logical lsame_(char *, char *);
  726. integer nbmin;
  727. extern /* Subroutine */ void sgemm_(char *, char *, integer *, integer *,
  728. integer *, real *, real *, integer *, real *, integer *, real *,
  729. real *, integer *), sgemv_(char *, integer *,
  730. integer *, real *, real *, integer *, real *, integer *, real *,
  731. real *, integer *);
  732. integer nblst;
  733. logical initq;
  734. real c1, c2;
  735. extern /* Subroutine */ void sorm22_(char *, char *, integer *, integer *,
  736. integer *, integer *, real *, integer *, real *, integer *, real *
  737. , integer *, integer *);
  738. logical wantq;
  739. integer j0;
  740. logical initz, wantz;
  741. real s1, s2;
  742. extern /* Subroutine */ void strmv_(char *, char *, char *, integer *,
  743. real *, integer *, real *, integer *);
  744. char compq2[1], compz2[1];
  745. integer nb, jj, nh, nx, pw;
  746. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  747. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  748. integer *, integer *, ftnlen, ftnlen);
  749. extern /* Subroutine */ void sgghrd_(char *, char *, integer *, integer *,
  750. integer *, real *, integer *, real *, integer *, real *, integer *
  751. , real *, integer *, integer *), slaset_(char *,
  752. integer *, integer *, real *, real *, real *, integer *),
  753. slartg_(real *, real *, real *, real *, real *), slacpy_(char *,
  754. integer *, integer *, real *, integer *, real *, integer *);
  755. integer lwkopt;
  756. logical lquery;
  757. integer nnb, len, top, ppw, n2nb;
  758. /* -- LAPACK computational routine (version 3.8.0) -- */
  759. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  760. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  761. /* January 2015 */
  762. /* ===================================================================== */
  763. /* Decode and test the input parameters. */
  764. /* Parameter adjustments */
  765. a_dim1 = *lda;
  766. a_offset = 1 + a_dim1 * 1;
  767. a -= a_offset;
  768. b_dim1 = *ldb;
  769. b_offset = 1 + b_dim1 * 1;
  770. b -= b_offset;
  771. q_dim1 = *ldq;
  772. q_offset = 1 + q_dim1 * 1;
  773. q -= q_offset;
  774. z_dim1 = *ldz;
  775. z_offset = 1 + z_dim1 * 1;
  776. z__ -= z_offset;
  777. --work;
  778. /* Function Body */
  779. *info = 0;
  780. nb = ilaenv_(&c__1, "SGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (ftnlen)
  781. 1);
  782. /* Computing MAX */
  783. i__1 = *n * 6 * nb;
  784. lwkopt = f2cmax(i__1,1);
  785. work[1] = (real) lwkopt;
  786. initq = lsame_(compq, "I");
  787. wantq = initq || lsame_(compq, "V");
  788. initz = lsame_(compz, "I");
  789. wantz = initz || lsame_(compz, "V");
  790. lquery = *lwork == -1;
  791. if (! lsame_(compq, "N") && ! wantq) {
  792. *info = -1;
  793. } else if (! lsame_(compz, "N") && ! wantz) {
  794. *info = -2;
  795. } else if (*n < 0) {
  796. *info = -3;
  797. } else if (*ilo < 1) {
  798. *info = -4;
  799. } else if (*ihi > *n || *ihi < *ilo - 1) {
  800. *info = -5;
  801. } else if (*lda < f2cmax(1,*n)) {
  802. *info = -7;
  803. } else if (*ldb < f2cmax(1,*n)) {
  804. *info = -9;
  805. } else if (wantq && *ldq < *n || *ldq < 1) {
  806. *info = -11;
  807. } else if (wantz && *ldz < *n || *ldz < 1) {
  808. *info = -13;
  809. } else if (*lwork < 1 && ! lquery) {
  810. *info = -15;
  811. }
  812. if (*info != 0) {
  813. i__1 = -(*info);
  814. xerbla_("SGGHD3", &i__1, (ftnlen)6);
  815. return;
  816. } else if (lquery) {
  817. return;
  818. }
  819. /* Initialize Q and Z if desired. */
  820. if (initq) {
  821. slaset_("All", n, n, &c_b14, &c_b15, &q[q_offset], ldq);
  822. }
  823. if (initz) {
  824. slaset_("All", n, n, &c_b14, &c_b15, &z__[z_offset], ldz);
  825. }
  826. /* Zero out lower triangle of B. */
  827. if (*n > 1) {
  828. i__1 = *n - 1;
  829. i__2 = *n - 1;
  830. slaset_("Lower", &i__1, &i__2, &c_b14, &c_b14, &b[b_dim1 + 2], ldb);
  831. }
  832. /* Quick return if possible */
  833. nh = *ihi - *ilo + 1;
  834. if (nh <= 1) {
  835. work[1] = 1.f;
  836. return;
  837. }
  838. /* Determine the blocksize. */
  839. nbmin = ilaenv_(&c__2, "SGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (
  840. ftnlen)1);
  841. if (nb > 1 && nb < nh) {
  842. /* Determine when to use unblocked instead of blocked code. */
  843. /* Computing MAX */
  844. i__1 = nb, i__2 = ilaenv_(&c__3, "SGGHD3", " ", n, ilo, ihi, &c_n1, (
  845. ftnlen)6, (ftnlen)1);
  846. nx = f2cmax(i__1,i__2);
  847. if (nx < nh) {
  848. /* Determine if workspace is large enough for blocked code. */
  849. if (*lwork < lwkopt) {
  850. /* Not enough workspace to use optimal NB: determine the */
  851. /* minimum value of NB, and reduce NB or force use of */
  852. /* unblocked code. */
  853. /* Computing MAX */
  854. i__1 = 2, i__2 = ilaenv_(&c__2, "SGGHD3", " ", n, ilo, ihi, &
  855. c_n1, (ftnlen)6, (ftnlen)1);
  856. nbmin = f2cmax(i__1,i__2);
  857. if (*lwork >= *n * 6 * nbmin) {
  858. nb = *lwork / (*n * 6);
  859. } else {
  860. nb = 1;
  861. }
  862. }
  863. }
  864. }
  865. if (nb < nbmin || nb >= nh) {
  866. /* Use unblocked code below */
  867. jcol = *ilo;
  868. } else {
  869. /* Use blocked code */
  870. kacc22 = ilaenv_(&c__16, "SGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6,
  871. (ftnlen)1);
  872. blk22 = kacc22 == 2;
  873. i__1 = *ihi - 2;
  874. i__2 = nb;
  875. for (jcol = *ilo; i__2 < 0 ? jcol >= i__1 : jcol <= i__1; jcol +=
  876. i__2) {
  877. /* Computing MIN */
  878. i__3 = nb, i__4 = *ihi - jcol - 1;
  879. nnb = f2cmin(i__3,i__4);
  880. /* Initialize small orthogonal factors that will hold the */
  881. /* accumulated Givens rotations in workspace. */
  882. /* N2NB denotes the number of 2*NNB-by-2*NNB factors */
  883. /* NBLST denotes the (possibly smaller) order of the last */
  884. /* factor. */
  885. n2nb = (*ihi - jcol - 1) / nnb - 1;
  886. nblst = *ihi - jcol - n2nb * nnb;
  887. slaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &nblst);
  888. pw = nblst * nblst + 1;
  889. i__3 = n2nb;
  890. for (i__ = 1; i__ <= i__3; ++i__) {
  891. i__4 = nnb << 1;
  892. i__5 = nnb << 1;
  893. i__6 = nnb << 1;
  894. slaset_("All", &i__4, &i__5, &c_b14, &c_b15, &work[pw], &i__6);
  895. pw += (nnb << 2) * nnb;
  896. }
  897. /* Reduce columns JCOL:JCOL+NNB-1 of A to Hessenberg form. */
  898. i__3 = jcol + nnb - 1;
  899. for (j = jcol; j <= i__3; ++j) {
  900. /* Reduce Jth column of A. Store cosines and sines in Jth */
  901. /* column of A and B, respectively. */
  902. i__4 = j + 2;
  903. for (i__ = *ihi; i__ >= i__4; --i__) {
  904. temp = a[i__ - 1 + j * a_dim1];
  905. slartg_(&temp, &a[i__ + j * a_dim1], &c__, &s, &a[i__ - 1
  906. + j * a_dim1]);
  907. a[i__ + j * a_dim1] = c__;
  908. b[i__ + j * b_dim1] = s;
  909. }
  910. /* Accumulate Givens rotations into workspace array. */
  911. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  912. len = j + 2 - jcol;
  913. jrow = j + n2nb * nnb + 2;
  914. i__4 = jrow;
  915. for (i__ = *ihi; i__ >= i__4; --i__) {
  916. c__ = a[i__ + j * a_dim1];
  917. s = b[i__ + j * b_dim1];
  918. i__5 = ppw + len - 1;
  919. for (jj = ppw; jj <= i__5; ++jj) {
  920. temp = work[jj + nblst];
  921. work[jj + nblst] = c__ * temp - s * work[jj];
  922. work[jj] = s * temp + c__ * work[jj];
  923. }
  924. ++len;
  925. ppw = ppw - nblst - 1;
  926. }
  927. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb + nnb;
  928. j0 = jrow - nnb;
  929. i__4 = j + 2;
  930. i__5 = -nnb;
  931. for (jrow = j0; i__5 < 0 ? jrow >= i__4 : jrow <= i__4; jrow
  932. += i__5) {
  933. ppw = ppwo;
  934. len = j + 2 - jcol;
  935. i__6 = jrow;
  936. for (i__ = jrow + nnb - 1; i__ >= i__6; --i__) {
  937. c__ = a[i__ + j * a_dim1];
  938. s = b[i__ + j * b_dim1];
  939. i__7 = ppw + len - 1;
  940. for (jj = ppw; jj <= i__7; ++jj) {
  941. temp = work[jj + (nnb << 1)];
  942. work[jj + (nnb << 1)] = c__ * temp - s * work[jj];
  943. work[jj] = s * temp + c__ * work[jj];
  944. }
  945. ++len;
  946. ppw = ppw - (nnb << 1) - 1;
  947. }
  948. ppwo += (nnb << 2) * nnb;
  949. }
  950. /* TOP denotes the number of top rows in A and B that will */
  951. /* not be updated during the next steps. */
  952. if (jcol <= 2) {
  953. top = 0;
  954. } else {
  955. top = jcol;
  956. }
  957. /* Propagate transformations through B and replace stored */
  958. /* left sines/cosines by right sines/cosines. */
  959. i__5 = j + 1;
  960. for (jj = *n; jj >= i__5; --jj) {
  961. /* Update JJth column of B. */
  962. /* Computing MIN */
  963. i__4 = jj + 1;
  964. i__6 = j + 2;
  965. for (i__ = f2cmin(i__4,*ihi); i__ >= i__6; --i__) {
  966. c__ = a[i__ + j * a_dim1];
  967. s = b[i__ + j * b_dim1];
  968. temp = b[i__ + jj * b_dim1];
  969. b[i__ + jj * b_dim1] = c__ * temp - s * b[i__ - 1 +
  970. jj * b_dim1];
  971. b[i__ - 1 + jj * b_dim1] = s * temp + c__ * b[i__ - 1
  972. + jj * b_dim1];
  973. }
  974. /* Annihilate B( JJ+1, JJ ). */
  975. if (jj < *ihi) {
  976. temp = b[jj + 1 + (jj + 1) * b_dim1];
  977. slartg_(&temp, &b[jj + 1 + jj * b_dim1], &c__, &s, &b[
  978. jj + 1 + (jj + 1) * b_dim1]);
  979. b[jj + 1 + jj * b_dim1] = 0.f;
  980. i__6 = jj - top;
  981. srot_(&i__6, &b[top + 1 + (jj + 1) * b_dim1], &c__1, &
  982. b[top + 1 + jj * b_dim1], &c__1, &c__, &s);
  983. a[jj + 1 + j * a_dim1] = c__;
  984. b[jj + 1 + j * b_dim1] = -s;
  985. }
  986. }
  987. /* Update A by transformations from right. */
  988. /* Explicit loop unrolling provides better performance */
  989. /* compared to SLASR. */
  990. /* CALL SLASR( 'Right', 'Variable', 'Backward', IHI-TOP, */
  991. /* $ IHI-J, A( J+2, J ), B( J+2, J ), */
  992. /* $ A( TOP+1, J+1 ), LDA ) */
  993. jj = (*ihi - j - 1) % 3;
  994. i__5 = jj + 1;
  995. for (i__ = *ihi - j - 3; i__ >= i__5; i__ += -3) {
  996. c__ = a[j + 1 + i__ + j * a_dim1];
  997. s = -b[j + 1 + i__ + j * b_dim1];
  998. c1 = a[j + 2 + i__ + j * a_dim1];
  999. s1 = -b[j + 2 + i__ + j * b_dim1];
  1000. c2 = a[j + 3 + i__ + j * a_dim1];
  1001. s2 = -b[j + 3 + i__ + j * b_dim1];
  1002. i__6 = *ihi;
  1003. for (k = top + 1; k <= i__6; ++k) {
  1004. temp = a[k + (j + i__) * a_dim1];
  1005. temp1 = a[k + (j + i__ + 1) * a_dim1];
  1006. temp2 = a[k + (j + i__ + 2) * a_dim1];
  1007. temp3 = a[k + (j + i__ + 3) * a_dim1];
  1008. a[k + (j + i__ + 3) * a_dim1] = c2 * temp3 + s2 *
  1009. temp2;
  1010. temp2 = -s2 * temp3 + c2 * temp2;
  1011. a[k + (j + i__ + 2) * a_dim1] = c1 * temp2 + s1 *
  1012. temp1;
  1013. temp1 = -s1 * temp2 + c1 * temp1;
  1014. a[k + (j + i__ + 1) * a_dim1] = c__ * temp1 + s *
  1015. temp;
  1016. a[k + (j + i__) * a_dim1] = -s * temp1 + c__ * temp;
  1017. }
  1018. }
  1019. if (jj > 0) {
  1020. for (i__ = jj; i__ >= 1; --i__) {
  1021. i__5 = *ihi - top;
  1022. r__1 = -b[j + 1 + i__ + j * b_dim1];
  1023. srot_(&i__5, &a[top + 1 + (j + i__ + 1) * a_dim1], &
  1024. c__1, &a[top + 1 + (j + i__) * a_dim1], &c__1,
  1025. &a[j + 1 + i__ + j * a_dim1], &r__1);
  1026. }
  1027. }
  1028. /* Update (J+1)th column of A by transformations from left. */
  1029. if (j < jcol + nnb - 1) {
  1030. len = j + 1 - jcol;
  1031. /* Multiply with the trailing accumulated orthogonal */
  1032. /* matrix, which takes the form */
  1033. /* [ U11 U12 ] */
  1034. /* U = [ ], */
  1035. /* [ U21 U22 ] */
  1036. /* where U21 is a LEN-by-LEN matrix and U12 is lower */
  1037. /* triangular. */
  1038. jrow = *ihi - nblst + 1;
  1039. sgemv_("Transpose", &nblst, &len, &c_b15, &work[1], &
  1040. nblst, &a[jrow + (j + 1) * a_dim1], &c__1, &c_b14,
  1041. &work[pw], &c__1);
  1042. ppw = pw + len;
  1043. i__5 = jrow + nblst - len - 1;
  1044. for (i__ = jrow; i__ <= i__5; ++i__) {
  1045. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1046. ++ppw;
  1047. }
  1048. i__5 = nblst - len;
  1049. strmv_("Lower", "Transpose", "Non-unit", &i__5, &work[len
  1050. * nblst + 1], &nblst, &work[pw + len], &c__1);
  1051. i__5 = nblst - len;
  1052. sgemv_("Transpose", &len, &i__5, &c_b15, &work[(len + 1) *
  1053. nblst - len + 1], &nblst, &a[jrow + nblst - len
  1054. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw +
  1055. len], &c__1);
  1056. ppw = pw;
  1057. i__5 = jrow + nblst - 1;
  1058. for (i__ = jrow; i__ <= i__5; ++i__) {
  1059. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1060. ++ppw;
  1061. }
  1062. /* Multiply with the other accumulated orthogonal */
  1063. /* matrices, which take the form */
  1064. /* [ U11 U12 0 ] */
  1065. /* [ ] */
  1066. /* U = [ U21 U22 0 ], */
  1067. /* [ ] */
  1068. /* [ 0 0 I ] */
  1069. /* where I denotes the (NNB-LEN)-by-(NNB-LEN) identity */
  1070. /* matrix, U21 is a LEN-by-LEN upper triangular matrix */
  1071. /* and U12 is an NNB-by-NNB lower triangular matrix. */
  1072. ppwo = nblst * nblst + 1;
  1073. j0 = jrow - nnb;
  1074. i__5 = jcol + 1;
  1075. i__6 = -nnb;
  1076. for (jrow = j0; i__6 < 0 ? jrow >= i__5 : jrow <= i__5;
  1077. jrow += i__6) {
  1078. ppw = pw + len;
  1079. i__4 = jrow + nnb - 1;
  1080. for (i__ = jrow; i__ <= i__4; ++i__) {
  1081. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1082. ++ppw;
  1083. }
  1084. ppw = pw;
  1085. i__4 = jrow + nnb + len - 1;
  1086. for (i__ = jrow + nnb; i__ <= i__4; ++i__) {
  1087. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1088. ++ppw;
  1089. }
  1090. i__4 = nnb << 1;
  1091. strmv_("Upper", "Transpose", "Non-unit", &len, &work[
  1092. ppwo + nnb], &i__4, &work[pw], &c__1);
  1093. i__4 = nnb << 1;
  1094. strmv_("Lower", "Transpose", "Non-unit", &nnb, &work[
  1095. ppwo + (len << 1) * nnb], &i__4, &work[pw +
  1096. len], &c__1);
  1097. i__4 = nnb << 1;
  1098. sgemv_("Transpose", &nnb, &len, &c_b15, &work[ppwo], &
  1099. i__4, &a[jrow + (j + 1) * a_dim1], &c__1, &
  1100. c_b15, &work[pw], &c__1);
  1101. i__4 = nnb << 1;
  1102. sgemv_("Transpose", &len, &nnb, &c_b15, &work[ppwo + (
  1103. len << 1) * nnb + nnb], &i__4, &a[jrow + nnb
  1104. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw
  1105. + len], &c__1);
  1106. ppw = pw;
  1107. i__4 = jrow + len + nnb - 1;
  1108. for (i__ = jrow; i__ <= i__4; ++i__) {
  1109. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1110. ++ppw;
  1111. }
  1112. ppwo += (nnb << 2) * nnb;
  1113. }
  1114. }
  1115. }
  1116. /* Apply accumulated orthogonal matrices to A. */
  1117. cola = *n - jcol - nnb + 1;
  1118. j = *ihi - nblst + 1;
  1119. sgemm_("Transpose", "No Transpose", &nblst, &cola, &nblst, &c_b15,
  1120. &work[1], &nblst, &a[j + (jcol + nnb) * a_dim1], lda, &
  1121. c_b14, &work[pw], &nblst);
  1122. slacpy_("All", &nblst, &cola, &work[pw], &nblst, &a[j + (jcol +
  1123. nnb) * a_dim1], lda);
  1124. ppwo = nblst * nblst + 1;
  1125. j0 = j - nnb;
  1126. i__3 = jcol + 1;
  1127. i__6 = -nnb;
  1128. for (j = j0; i__6 < 0 ? j >= i__3 : j <= i__3; j += i__6) {
  1129. if (blk22) {
  1130. /* Exploit the structure of */
  1131. /* [ U11 U12 ] */
  1132. /* U = [ ] */
  1133. /* [ U21 U22 ], */
  1134. /* where all blocks are NNB-by-NNB, U21 is upper */
  1135. /* triangular and U12 is lower triangular. */
  1136. i__5 = nnb << 1;
  1137. i__4 = nnb << 1;
  1138. i__7 = *lwork - pw + 1;
  1139. sorm22_("Left", "Transpose", &i__5, &cola, &nnb, &nnb, &
  1140. work[ppwo], &i__4, &a[j + (jcol + nnb) * a_dim1],
  1141. lda, &work[pw], &i__7, &ierr);
  1142. } else {
  1143. /* Ignore the structure of U. */
  1144. i__5 = nnb << 1;
  1145. i__4 = nnb << 1;
  1146. i__7 = nnb << 1;
  1147. i__8 = nnb << 1;
  1148. sgemm_("Transpose", "No Transpose", &i__5, &cola, &i__4, &
  1149. c_b15, &work[ppwo], &i__7, &a[j + (jcol + nnb) *
  1150. a_dim1], lda, &c_b14, &work[pw], &i__8);
  1151. i__5 = nnb << 1;
  1152. i__4 = nnb << 1;
  1153. slacpy_("All", &i__5, &cola, &work[pw], &i__4, &a[j + (
  1154. jcol + nnb) * a_dim1], lda);
  1155. }
  1156. ppwo += (nnb << 2) * nnb;
  1157. }
  1158. /* Apply accumulated orthogonal matrices to Q. */
  1159. if (wantq) {
  1160. j = *ihi - nblst + 1;
  1161. if (initq) {
  1162. /* Computing MAX */
  1163. i__6 = 2, i__3 = j - jcol + 1;
  1164. topq = f2cmax(i__6,i__3);
  1165. nh = *ihi - topq + 1;
  1166. } else {
  1167. topq = 1;
  1168. nh = *n;
  1169. }
  1170. sgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1171. c_b15, &q[topq + j * q_dim1], ldq, &work[1], &nblst, &
  1172. c_b14, &work[pw], &nh);
  1173. slacpy_("All", &nh, &nblst, &work[pw], &nh, &q[topq + j *
  1174. q_dim1], ldq);
  1175. ppwo = nblst * nblst + 1;
  1176. j0 = j - nnb;
  1177. i__6 = jcol + 1;
  1178. i__3 = -nnb;
  1179. for (j = j0; i__3 < 0 ? j >= i__6 : j <= i__6; j += i__3) {
  1180. if (initq) {
  1181. /* Computing MAX */
  1182. i__5 = 2, i__4 = j - jcol + 1;
  1183. topq = f2cmax(i__5,i__4);
  1184. nh = *ihi - topq + 1;
  1185. }
  1186. if (blk22) {
  1187. /* Exploit the structure of U. */
  1188. i__5 = nnb << 1;
  1189. i__4 = nnb << 1;
  1190. i__7 = *lwork - pw + 1;
  1191. sorm22_("Right", "No Transpose", &nh, &i__5, &nnb, &
  1192. nnb, &work[ppwo], &i__4, &q[topq + j * q_dim1]
  1193. , ldq, &work[pw], &i__7, &ierr);
  1194. } else {
  1195. /* Ignore the structure of U. */
  1196. i__5 = nnb << 1;
  1197. i__4 = nnb << 1;
  1198. i__7 = nnb << 1;
  1199. sgemm_("No Transpose", "No Transpose", &nh, &i__5, &
  1200. i__4, &c_b15, &q[topq + j * q_dim1], ldq, &
  1201. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1202. i__5 = nnb << 1;
  1203. slacpy_("All", &nh, &i__5, &work[pw], &nh, &q[topq +
  1204. j * q_dim1], ldq);
  1205. }
  1206. ppwo += (nnb << 2) * nnb;
  1207. }
  1208. }
  1209. /* Accumulate right Givens rotations if required. */
  1210. if (wantz || top > 0) {
  1211. /* Initialize small orthogonal factors that will hold the */
  1212. /* accumulated Givens rotations in workspace. */
  1213. slaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &
  1214. nblst);
  1215. pw = nblst * nblst + 1;
  1216. i__3 = n2nb;
  1217. for (i__ = 1; i__ <= i__3; ++i__) {
  1218. i__6 = nnb << 1;
  1219. i__5 = nnb << 1;
  1220. i__4 = nnb << 1;
  1221. slaset_("All", &i__6, &i__5, &c_b14, &c_b15, &work[pw], &
  1222. i__4);
  1223. pw += (nnb << 2) * nnb;
  1224. }
  1225. /* Accumulate Givens rotations into workspace array. */
  1226. i__3 = jcol + nnb - 1;
  1227. for (j = jcol; j <= i__3; ++j) {
  1228. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  1229. len = j + 2 - jcol;
  1230. jrow = j + n2nb * nnb + 2;
  1231. i__6 = jrow;
  1232. for (i__ = *ihi; i__ >= i__6; --i__) {
  1233. c__ = a[i__ + j * a_dim1];
  1234. a[i__ + j * a_dim1] = 0.f;
  1235. s = b[i__ + j * b_dim1];
  1236. b[i__ + j * b_dim1] = 0.f;
  1237. i__5 = ppw + len - 1;
  1238. for (jj = ppw; jj <= i__5; ++jj) {
  1239. temp = work[jj + nblst];
  1240. work[jj + nblst] = c__ * temp - s * work[jj];
  1241. work[jj] = s * temp + c__ * work[jj];
  1242. }
  1243. ++len;
  1244. ppw = ppw - nblst - 1;
  1245. }
  1246. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb +
  1247. nnb;
  1248. j0 = jrow - nnb;
  1249. i__6 = j + 2;
  1250. i__5 = -nnb;
  1251. for (jrow = j0; i__5 < 0 ? jrow >= i__6 : jrow <= i__6;
  1252. jrow += i__5) {
  1253. ppw = ppwo;
  1254. len = j + 2 - jcol;
  1255. i__4 = jrow;
  1256. for (i__ = jrow + nnb - 1; i__ >= i__4; --i__) {
  1257. c__ = a[i__ + j * a_dim1];
  1258. a[i__ + j * a_dim1] = 0.f;
  1259. s = b[i__ + j * b_dim1];
  1260. b[i__ + j * b_dim1] = 0.f;
  1261. i__7 = ppw + len - 1;
  1262. for (jj = ppw; jj <= i__7; ++jj) {
  1263. temp = work[jj + (nnb << 1)];
  1264. work[jj + (nnb << 1)] = c__ * temp - s * work[
  1265. jj];
  1266. work[jj] = s * temp + c__ * work[jj];
  1267. }
  1268. ++len;
  1269. ppw = ppw - (nnb << 1) - 1;
  1270. }
  1271. ppwo += (nnb << 2) * nnb;
  1272. }
  1273. }
  1274. } else {
  1275. i__3 = *ihi - jcol - 1;
  1276. slaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &a[jcol + 2 +
  1277. jcol * a_dim1], lda);
  1278. i__3 = *ihi - jcol - 1;
  1279. slaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &b[jcol + 2 +
  1280. jcol * b_dim1], ldb);
  1281. }
  1282. /* Apply accumulated orthogonal matrices to A and B. */
  1283. if (top > 0) {
  1284. j = *ihi - nblst + 1;
  1285. sgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1286. c_b15, &a[j * a_dim1 + 1], lda, &work[1], &nblst, &
  1287. c_b14, &work[pw], &top);
  1288. slacpy_("All", &top, &nblst, &work[pw], &top, &a[j * a_dim1 +
  1289. 1], lda);
  1290. ppwo = nblst * nblst + 1;
  1291. j0 = j - nnb;
  1292. i__3 = jcol + 1;
  1293. i__5 = -nnb;
  1294. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1295. if (blk22) {
  1296. /* Exploit the structure of U. */
  1297. i__6 = nnb << 1;
  1298. i__4 = nnb << 1;
  1299. i__7 = *lwork - pw + 1;
  1300. sorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1301. nnb, &work[ppwo], &i__4, &a[j * a_dim1 + 1],
  1302. lda, &work[pw], &i__7, &ierr);
  1303. } else {
  1304. /* Ignore the structure of U. */
  1305. i__6 = nnb << 1;
  1306. i__4 = nnb << 1;
  1307. i__7 = nnb << 1;
  1308. sgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1309. i__4, &c_b15, &a[j * a_dim1 + 1], lda, &work[
  1310. ppwo], &i__7, &c_b14, &work[pw], &top);
  1311. i__6 = nnb << 1;
  1312. slacpy_("All", &top, &i__6, &work[pw], &top, &a[j *
  1313. a_dim1 + 1], lda);
  1314. }
  1315. ppwo += (nnb << 2) * nnb;
  1316. }
  1317. j = *ihi - nblst + 1;
  1318. sgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1319. c_b15, &b[j * b_dim1 + 1], ldb, &work[1], &nblst, &
  1320. c_b14, &work[pw], &top);
  1321. slacpy_("All", &top, &nblst, &work[pw], &top, &b[j * b_dim1 +
  1322. 1], ldb);
  1323. ppwo = nblst * nblst + 1;
  1324. j0 = j - nnb;
  1325. i__5 = jcol + 1;
  1326. i__3 = -nnb;
  1327. for (j = j0; i__3 < 0 ? j >= i__5 : j <= i__5; j += i__3) {
  1328. if (blk22) {
  1329. /* Exploit the structure of U. */
  1330. i__6 = nnb << 1;
  1331. i__4 = nnb << 1;
  1332. i__7 = *lwork - pw + 1;
  1333. sorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1334. nnb, &work[ppwo], &i__4, &b[j * b_dim1 + 1],
  1335. ldb, &work[pw], &i__7, &ierr);
  1336. } else {
  1337. /* Ignore the structure of U. */
  1338. i__6 = nnb << 1;
  1339. i__4 = nnb << 1;
  1340. i__7 = nnb << 1;
  1341. sgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1342. i__4, &c_b15, &b[j * b_dim1 + 1], ldb, &work[
  1343. ppwo], &i__7, &c_b14, &work[pw], &top);
  1344. i__6 = nnb << 1;
  1345. slacpy_("All", &top, &i__6, &work[pw], &top, &b[j *
  1346. b_dim1 + 1], ldb);
  1347. }
  1348. ppwo += (nnb << 2) * nnb;
  1349. }
  1350. }
  1351. /* Apply accumulated orthogonal matrices to Z. */
  1352. if (wantz) {
  1353. j = *ihi - nblst + 1;
  1354. if (initq) {
  1355. /* Computing MAX */
  1356. i__3 = 2, i__5 = j - jcol + 1;
  1357. topq = f2cmax(i__3,i__5);
  1358. nh = *ihi - topq + 1;
  1359. } else {
  1360. topq = 1;
  1361. nh = *n;
  1362. }
  1363. sgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1364. c_b15, &z__[topq + j * z_dim1], ldz, &work[1], &nblst,
  1365. &c_b14, &work[pw], &nh);
  1366. slacpy_("All", &nh, &nblst, &work[pw], &nh, &z__[topq + j *
  1367. z_dim1], ldz);
  1368. ppwo = nblst * nblst + 1;
  1369. j0 = j - nnb;
  1370. i__3 = jcol + 1;
  1371. i__5 = -nnb;
  1372. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1373. if (initq) {
  1374. /* Computing MAX */
  1375. i__6 = 2, i__4 = j - jcol + 1;
  1376. topq = f2cmax(i__6,i__4);
  1377. nh = *ihi - topq + 1;
  1378. }
  1379. if (blk22) {
  1380. /* Exploit the structure of U. */
  1381. i__6 = nnb << 1;
  1382. i__4 = nnb << 1;
  1383. i__7 = *lwork - pw + 1;
  1384. sorm22_("Right", "No Transpose", &nh, &i__6, &nnb, &
  1385. nnb, &work[ppwo], &i__4, &z__[topq + j *
  1386. z_dim1], ldz, &work[pw], &i__7, &ierr);
  1387. } else {
  1388. /* Ignore the structure of U. */
  1389. i__6 = nnb << 1;
  1390. i__4 = nnb << 1;
  1391. i__7 = nnb << 1;
  1392. sgemm_("No Transpose", "No Transpose", &nh, &i__6, &
  1393. i__4, &c_b15, &z__[topq + j * z_dim1], ldz, &
  1394. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1395. i__6 = nnb << 1;
  1396. slacpy_("All", &nh, &i__6, &work[pw], &nh, &z__[topq
  1397. + j * z_dim1], ldz);
  1398. }
  1399. ppwo += (nnb << 2) * nnb;
  1400. }
  1401. }
  1402. }
  1403. }
  1404. /* Use unblocked code to reduce the rest of the matrix */
  1405. /* Avoid re-initialization of modified Q and Z. */
  1406. *(unsigned char *)compq2 = *(unsigned char *)compq;
  1407. *(unsigned char *)compz2 = *(unsigned char *)compz;
  1408. if (jcol != *ilo) {
  1409. if (wantq) {
  1410. *(unsigned char *)compq2 = 'V';
  1411. }
  1412. if (wantz) {
  1413. *(unsigned char *)compz2 = 'V';
  1414. }
  1415. }
  1416. if (jcol < *ihi) {
  1417. sgghrd_(compq2, compz2, n, &jcol, ihi, &a[a_offset], lda, &b[b_offset]
  1418. , ldb, &q[q_offset], ldq, &z__[z_offset], ldz, &ierr);
  1419. }
  1420. work[1] = (real) lwkopt;
  1421. return;
  1422. /* End of SGGHD3 */
  1423. } /* sgghd3_ */