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.

dgghd3.c 47 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  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 doublereal c_b14 = 0.;
  489. static doublereal c_b15 = 1.;
  490. static integer c__2 = 2;
  491. static integer c__3 = 3;
  492. static integer c__16 = 16;
  493. /* > \brief \b DGGHD3 */
  494. /* =========== DOCUMENTATION =========== */
  495. /* Online html documentation available at */
  496. /* http://www.netlib.org/lapack/explore-html/ */
  497. /* > \htmlonly */
  498. /* > Download DGGHD3 + dependencies */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgghd3.
  500. f"> */
  501. /* > [TGZ]</a> */
  502. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgghd3.
  503. f"> */
  504. /* > [ZIP]</a> */
  505. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgghd3.
  506. f"> */
  507. /* > [TXT]</a> */
  508. /* > \endhtmlonly */
  509. /* Definition: */
  510. /* =========== */
  511. /* SUBROUTINE DGGHD3( 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. /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), Q( LDQ, * ), */
  516. /* $ Z( LDZ, * ), WORK( * ) */
  517. /* > \par Purpose: */
  518. /* ============= */
  519. /* > */
  520. /* > \verbatim */
  521. /* > */
  522. /* > DGGHD3 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 DGGHD3 reduces the original */
  549. /* > problem to generalized Hessenberg form. */
  550. /* > */
  551. /* > This is a blocked variant of DGGHRD, 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 DGGBAL; 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 doubleOTHERcomputational */
  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 */ int dgghd3_(char *compq, char *compz, integer *n, integer *
  707. ilo, integer *ihi, doublereal *a, integer *lda, doublereal *b,
  708. integer *ldb, doublereal *q, integer *ldq, doublereal *z__, integer *
  709. ldz, doublereal *work, integer *lwork, 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. doublereal d__1;
  715. /* Local variables */
  716. logical blk22;
  717. integer cola, jcol, ierr;
  718. doublereal temp;
  719. extern /* Subroutine */ int drot_(integer *, doublereal *, integer *,
  720. doublereal *, integer *, doublereal *, doublereal *);
  721. integer jrow, topq, ppwo;
  722. doublereal temp1, temp2, temp3, c__;
  723. integer kacc22, i__, j, k;
  724. doublereal s;
  725. extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
  726. integer *, doublereal *, doublereal *, integer *, doublereal *,
  727. integer *, doublereal *, doublereal *, integer *);
  728. extern logical lsame_(char *, char *);
  729. extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
  730. doublereal *, doublereal *, integer *, doublereal *, integer *,
  731. doublereal *, doublereal *, integer *);
  732. integer nbmin;
  733. extern /* Subroutine */ int dorm22_(char *, char *, integer *, integer *,
  734. integer *, integer *, doublereal *, integer *, doublereal *,
  735. integer *, doublereal *, integer *, integer *);
  736. integer nblst;
  737. logical initq;
  738. doublereal c1, c2;
  739. logical wantq;
  740. integer j0;
  741. extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *,
  742. doublereal *, integer *, doublereal *, integer *);
  743. logical initz, wantz;
  744. doublereal s1, s2;
  745. char compq2[1], compz2[1];
  746. integer nb, jj, nh;
  747. extern /* Subroutine */ int dgghrd_(char *, char *, integer *, integer *,
  748. integer *, doublereal *, integer *, doublereal *, integer *,
  749. doublereal *, integer *, doublereal *, integer *, integer *);
  750. integer nx, pw;
  751. extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
  752. doublereal *, doublereal *, doublereal *, integer *),
  753. dlartg_(doublereal *, doublereal *, doublereal *, doublereal *,
  754. doublereal *);
  755. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  756. integer *, integer *, ftnlen, ftnlen);
  757. extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
  758. doublereal *, integer *, doublereal *, integer *),
  759. xerbla_(char *, integer *, ftnlen);
  760. integer lwkopt;
  761. logical lquery;
  762. integer nnb, len, top, ppw, n2nb;
  763. /* -- LAPACK computational routine (version 3.8.0) -- */
  764. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  765. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  766. /* January 2015 */
  767. /* ===================================================================== */
  768. /* Decode and test the input parameters. */
  769. /* Parameter adjustments */
  770. a_dim1 = *lda;
  771. a_offset = 1 + a_dim1 * 1;
  772. a -= a_offset;
  773. b_dim1 = *ldb;
  774. b_offset = 1 + b_dim1 * 1;
  775. b -= b_offset;
  776. q_dim1 = *ldq;
  777. q_offset = 1 + q_dim1 * 1;
  778. q -= q_offset;
  779. z_dim1 = *ldz;
  780. z_offset = 1 + z_dim1 * 1;
  781. z__ -= z_offset;
  782. --work;
  783. /* Function Body */
  784. *info = 0;
  785. nb = ilaenv_(&c__1, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (ftnlen)
  786. 1);
  787. /* Computing MAX */
  788. i__1 = *n * 6 * nb;
  789. lwkopt = f2cmax(i__1,1);
  790. work[1] = (doublereal) lwkopt;
  791. initq = lsame_(compq, "I");
  792. wantq = initq || lsame_(compq, "V");
  793. initz = lsame_(compz, "I");
  794. wantz = initz || lsame_(compz, "V");
  795. lquery = *lwork == -1;
  796. if (! lsame_(compq, "N") && ! wantq) {
  797. *info = -1;
  798. } else if (! lsame_(compz, "N") && ! wantz) {
  799. *info = -2;
  800. } else if (*n < 0) {
  801. *info = -3;
  802. } else if (*ilo < 1) {
  803. *info = -4;
  804. } else if (*ihi > *n || *ihi < *ilo - 1) {
  805. *info = -5;
  806. } else if (*lda < f2cmax(1,*n)) {
  807. *info = -7;
  808. } else if (*ldb < f2cmax(1,*n)) {
  809. *info = -9;
  810. } else if (wantq && *ldq < *n || *ldq < 1) {
  811. *info = -11;
  812. } else if (wantz && *ldz < *n || *ldz < 1) {
  813. *info = -13;
  814. } else if (*lwork < 1 && ! lquery) {
  815. *info = -15;
  816. }
  817. if (*info != 0) {
  818. i__1 = -(*info);
  819. xerbla_("DGGHD3", &i__1, (ftnlen)6);
  820. return 0;
  821. } else if (lquery) {
  822. return 0;
  823. }
  824. /* Initialize Q and Z if desired. */
  825. if (initq) {
  826. dlaset_("All", n, n, &c_b14, &c_b15, &q[q_offset], ldq);
  827. }
  828. if (initz) {
  829. dlaset_("All", n, n, &c_b14, &c_b15, &z__[z_offset], ldz);
  830. }
  831. /* Zero out lower triangle of B. */
  832. if (*n > 1) {
  833. i__1 = *n - 1;
  834. i__2 = *n - 1;
  835. dlaset_("Lower", &i__1, &i__2, &c_b14, &c_b14, &b[b_dim1 + 2], ldb);
  836. }
  837. /* Quick return if possible */
  838. nh = *ihi - *ilo + 1;
  839. if (nh <= 1) {
  840. work[1] = 1.;
  841. return 0;
  842. }
  843. /* Determine the blocksize. */
  844. nbmin = ilaenv_(&c__2, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (
  845. ftnlen)1);
  846. if (nb > 1 && nb < nh) {
  847. /* Determine when to use unblocked instead of blocked code. */
  848. /* Computing MAX */
  849. i__1 = nb, i__2 = ilaenv_(&c__3, "DGGHD3", " ", n, ilo, ihi, &c_n1, (
  850. ftnlen)6, (ftnlen)1);
  851. nx = f2cmax(i__1,i__2);
  852. if (nx < nh) {
  853. /* Determine if workspace is large enough for blocked code. */
  854. if (*lwork < lwkopt) {
  855. /* Not enough workspace to use optimal NB: determine the */
  856. /* minimum value of NB, and reduce NB or force use of */
  857. /* unblocked code. */
  858. /* Computing MAX */
  859. i__1 = 2, i__2 = ilaenv_(&c__2, "DGGHD3", " ", n, ilo, ihi, &
  860. c_n1, (ftnlen)6, (ftnlen)1);
  861. nbmin = f2cmax(i__1,i__2);
  862. if (*lwork >= *n * 6 * nbmin) {
  863. nb = *lwork / (*n * 6);
  864. } else {
  865. nb = 1;
  866. }
  867. }
  868. }
  869. }
  870. if (nb < nbmin || nb >= nh) {
  871. /* Use unblocked code below */
  872. jcol = *ilo;
  873. } else {
  874. /* Use blocked code */
  875. kacc22 = ilaenv_(&c__16, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6,
  876. (ftnlen)1);
  877. blk22 = kacc22 == 2;
  878. i__1 = *ihi - 2;
  879. i__2 = nb;
  880. for (jcol = *ilo; i__2 < 0 ? jcol >= i__1 : jcol <= i__1; jcol +=
  881. i__2) {
  882. /* Computing MIN */
  883. i__3 = nb, i__4 = *ihi - jcol - 1;
  884. nnb = f2cmin(i__3,i__4);
  885. /* Initialize small orthogonal factors that will hold the */
  886. /* accumulated Givens rotations in workspace. */
  887. /* N2NB denotes the number of 2*NNB-by-2*NNB factors */
  888. /* NBLST denotes the (possibly smaller) order of the last */
  889. /* factor. */
  890. n2nb = (*ihi - jcol - 1) / nnb - 1;
  891. nblst = *ihi - jcol - n2nb * nnb;
  892. dlaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &nblst);
  893. pw = nblst * nblst + 1;
  894. i__3 = n2nb;
  895. for (i__ = 1; i__ <= i__3; ++i__) {
  896. i__4 = nnb << 1;
  897. i__5 = nnb << 1;
  898. i__6 = nnb << 1;
  899. dlaset_("All", &i__4, &i__5, &c_b14, &c_b15, &work[pw], &i__6);
  900. pw += (nnb << 2) * nnb;
  901. }
  902. /* Reduce columns JCOL:JCOL+NNB-1 of A to Hessenberg form. */
  903. i__3 = jcol + nnb - 1;
  904. for (j = jcol; j <= i__3; ++j) {
  905. /* Reduce Jth column of A. Store cosines and sines in Jth */
  906. /* column of A and B, respectively. */
  907. i__4 = j + 2;
  908. for (i__ = *ihi; i__ >= i__4; --i__) {
  909. temp = a[i__ - 1 + j * a_dim1];
  910. dlartg_(&temp, &a[i__ + j * a_dim1], &c__, &s, &a[i__ - 1
  911. + j * a_dim1]);
  912. a[i__ + j * a_dim1] = c__;
  913. b[i__ + j * b_dim1] = s;
  914. }
  915. /* Accumulate Givens rotations into workspace array. */
  916. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  917. len = j + 2 - jcol;
  918. jrow = j + n2nb * nnb + 2;
  919. i__4 = jrow;
  920. for (i__ = *ihi; i__ >= i__4; --i__) {
  921. c__ = a[i__ + j * a_dim1];
  922. s = b[i__ + j * b_dim1];
  923. i__5 = ppw + len - 1;
  924. for (jj = ppw; jj <= i__5; ++jj) {
  925. temp = work[jj + nblst];
  926. work[jj + nblst] = c__ * temp - s * work[jj];
  927. work[jj] = s * temp + c__ * work[jj];
  928. }
  929. ++len;
  930. ppw = ppw - nblst - 1;
  931. }
  932. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb + nnb;
  933. j0 = jrow - nnb;
  934. i__4 = j + 2;
  935. i__5 = -nnb;
  936. for (jrow = j0; i__5 < 0 ? jrow >= i__4 : jrow <= i__4; jrow
  937. += i__5) {
  938. ppw = ppwo;
  939. len = j + 2 - jcol;
  940. i__6 = jrow;
  941. for (i__ = jrow + nnb - 1; i__ >= i__6; --i__) {
  942. c__ = a[i__ + j * a_dim1];
  943. s = b[i__ + j * b_dim1];
  944. i__7 = ppw + len - 1;
  945. for (jj = ppw; jj <= i__7; ++jj) {
  946. temp = work[jj + (nnb << 1)];
  947. work[jj + (nnb << 1)] = c__ * temp - s * work[jj];
  948. work[jj] = s * temp + c__ * work[jj];
  949. }
  950. ++len;
  951. ppw = ppw - (nnb << 1) - 1;
  952. }
  953. ppwo += (nnb << 2) * nnb;
  954. }
  955. /* TOP denotes the number of top rows in A and B that will */
  956. /* not be updated during the next steps. */
  957. if (jcol <= 2) {
  958. top = 0;
  959. } else {
  960. top = jcol;
  961. }
  962. /* Propagate transformations through B and replace stored */
  963. /* left sines/cosines by right sines/cosines. */
  964. i__5 = j + 1;
  965. for (jj = *n; jj >= i__5; --jj) {
  966. /* Update JJth column of B. */
  967. /* Computing MIN */
  968. i__4 = jj + 1;
  969. i__6 = j + 2;
  970. for (i__ = f2cmin(i__4,*ihi); i__ >= i__6; --i__) {
  971. c__ = a[i__ + j * a_dim1];
  972. s = b[i__ + j * b_dim1];
  973. temp = b[i__ + jj * b_dim1];
  974. b[i__ + jj * b_dim1] = c__ * temp - s * b[i__ - 1 +
  975. jj * b_dim1];
  976. b[i__ - 1 + jj * b_dim1] = s * temp + c__ * b[i__ - 1
  977. + jj * b_dim1];
  978. }
  979. /* Annihilate B( JJ+1, JJ ). */
  980. if (jj < *ihi) {
  981. temp = b[jj + 1 + (jj + 1) * b_dim1];
  982. dlartg_(&temp, &b[jj + 1 + jj * b_dim1], &c__, &s, &b[
  983. jj + 1 + (jj + 1) * b_dim1]);
  984. b[jj + 1 + jj * b_dim1] = 0.;
  985. i__6 = jj - top;
  986. drot_(&i__6, &b[top + 1 + (jj + 1) * b_dim1], &c__1, &
  987. b[top + 1 + jj * b_dim1], &c__1, &c__, &s);
  988. a[jj + 1 + j * a_dim1] = c__;
  989. b[jj + 1 + j * b_dim1] = -s;
  990. }
  991. }
  992. /* Update A by transformations from right. */
  993. /* Explicit loop unrolling provides better performance */
  994. /* compared to DLASR. */
  995. /* CALL DLASR( 'Right', 'Variable', 'Backward', IHI-TOP, */
  996. /* $ IHI-J, A( J+2, J ), B( J+2, J ), */
  997. /* $ A( TOP+1, J+1 ), LDA ) */
  998. jj = (*ihi - j - 1) % 3;
  999. i__5 = jj + 1;
  1000. for (i__ = *ihi - j - 3; i__ >= i__5; i__ += -3) {
  1001. c__ = a[j + 1 + i__ + j * a_dim1];
  1002. s = -b[j + 1 + i__ + j * b_dim1];
  1003. c1 = a[j + 2 + i__ + j * a_dim1];
  1004. s1 = -b[j + 2 + i__ + j * b_dim1];
  1005. c2 = a[j + 3 + i__ + j * a_dim1];
  1006. s2 = -b[j + 3 + i__ + j * b_dim1];
  1007. i__6 = *ihi;
  1008. for (k = top + 1; k <= i__6; ++k) {
  1009. temp = a[k + (j + i__) * a_dim1];
  1010. temp1 = a[k + (j + i__ + 1) * a_dim1];
  1011. temp2 = a[k + (j + i__ + 2) * a_dim1];
  1012. temp3 = a[k + (j + i__ + 3) * a_dim1];
  1013. a[k + (j + i__ + 3) * a_dim1] = c2 * temp3 + s2 *
  1014. temp2;
  1015. temp2 = -s2 * temp3 + c2 * temp2;
  1016. a[k + (j + i__ + 2) * a_dim1] = c1 * temp2 + s1 *
  1017. temp1;
  1018. temp1 = -s1 * temp2 + c1 * temp1;
  1019. a[k + (j + i__ + 1) * a_dim1] = c__ * temp1 + s *
  1020. temp;
  1021. a[k + (j + i__) * a_dim1] = -s * temp1 + c__ * temp;
  1022. }
  1023. }
  1024. if (jj > 0) {
  1025. for (i__ = jj; i__ >= 1; --i__) {
  1026. i__5 = *ihi - top;
  1027. d__1 = -b[j + 1 + i__ + j * b_dim1];
  1028. drot_(&i__5, &a[top + 1 + (j + i__ + 1) * a_dim1], &
  1029. c__1, &a[top + 1 + (j + i__) * a_dim1], &c__1,
  1030. &a[j + 1 + i__ + j * a_dim1], &d__1);
  1031. }
  1032. }
  1033. /* Update (J+1)th column of A by transformations from left. */
  1034. if (j < jcol + nnb - 1) {
  1035. len = j + 1 - jcol;
  1036. /* Multiply with the trailing accumulated orthogonal */
  1037. /* matrix, which takes the form */
  1038. /* [ U11 U12 ] */
  1039. /* U = [ ], */
  1040. /* [ U21 U22 ] */
  1041. /* where U21 is a LEN-by-LEN matrix and U12 is lower */
  1042. /* triangular. */
  1043. jrow = *ihi - nblst + 1;
  1044. dgemv_("Transpose", &nblst, &len, &c_b15, &work[1], &
  1045. nblst, &a[jrow + (j + 1) * a_dim1], &c__1, &c_b14,
  1046. &work[pw], &c__1);
  1047. ppw = pw + len;
  1048. i__5 = jrow + nblst - len - 1;
  1049. for (i__ = jrow; i__ <= i__5; ++i__) {
  1050. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1051. ++ppw;
  1052. }
  1053. i__5 = nblst - len;
  1054. dtrmv_("Lower", "Transpose", "Non-unit", &i__5, &work[len
  1055. * nblst + 1], &nblst, &work[pw + len], &c__1);
  1056. i__5 = nblst - len;
  1057. dgemv_("Transpose", &len, &i__5, &c_b15, &work[(len + 1) *
  1058. nblst - len + 1], &nblst, &a[jrow + nblst - len
  1059. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw +
  1060. len], &c__1);
  1061. ppw = pw;
  1062. i__5 = jrow + nblst - 1;
  1063. for (i__ = jrow; i__ <= i__5; ++i__) {
  1064. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1065. ++ppw;
  1066. }
  1067. /* Multiply with the other accumulated orthogonal */
  1068. /* matrices, which take the form */
  1069. /* [ U11 U12 0 ] */
  1070. /* [ ] */
  1071. /* U = [ U21 U22 0 ], */
  1072. /* [ ] */
  1073. /* [ 0 0 I ] */
  1074. /* where I denotes the (NNB-LEN)-by-(NNB-LEN) identity */
  1075. /* matrix, U21 is a LEN-by-LEN upper triangular matrix */
  1076. /* and U12 is an NNB-by-NNB lower triangular matrix. */
  1077. ppwo = nblst * nblst + 1;
  1078. j0 = jrow - nnb;
  1079. i__5 = jcol + 1;
  1080. i__6 = -nnb;
  1081. for (jrow = j0; i__6 < 0 ? jrow >= i__5 : jrow <= i__5;
  1082. jrow += i__6) {
  1083. ppw = pw + len;
  1084. i__4 = jrow + nnb - 1;
  1085. for (i__ = jrow; i__ <= i__4; ++i__) {
  1086. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1087. ++ppw;
  1088. }
  1089. ppw = pw;
  1090. i__4 = jrow + nnb + len - 1;
  1091. for (i__ = jrow + nnb; i__ <= i__4; ++i__) {
  1092. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1093. ++ppw;
  1094. }
  1095. i__4 = nnb << 1;
  1096. dtrmv_("Upper", "Transpose", "Non-unit", &len, &work[
  1097. ppwo + nnb], &i__4, &work[pw], &c__1);
  1098. i__4 = nnb << 1;
  1099. dtrmv_("Lower", "Transpose", "Non-unit", &nnb, &work[
  1100. ppwo + (len << 1) * nnb], &i__4, &work[pw +
  1101. len], &c__1);
  1102. i__4 = nnb << 1;
  1103. dgemv_("Transpose", &nnb, &len, &c_b15, &work[ppwo], &
  1104. i__4, &a[jrow + (j + 1) * a_dim1], &c__1, &
  1105. c_b15, &work[pw], &c__1);
  1106. i__4 = nnb << 1;
  1107. dgemv_("Transpose", &len, &nnb, &c_b15, &work[ppwo + (
  1108. len << 1) * nnb + nnb], &i__4, &a[jrow + nnb
  1109. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw
  1110. + len], &c__1);
  1111. ppw = pw;
  1112. i__4 = jrow + len + nnb - 1;
  1113. for (i__ = jrow; i__ <= i__4; ++i__) {
  1114. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1115. ++ppw;
  1116. }
  1117. ppwo += (nnb << 2) * nnb;
  1118. }
  1119. }
  1120. }
  1121. /* Apply accumulated orthogonal matrices to A. */
  1122. cola = *n - jcol - nnb + 1;
  1123. j = *ihi - nblst + 1;
  1124. dgemm_("Transpose", "No Transpose", &nblst, &cola, &nblst, &c_b15,
  1125. &work[1], &nblst, &a[j + (jcol + nnb) * a_dim1], lda, &
  1126. c_b14, &work[pw], &nblst);
  1127. dlacpy_("All", &nblst, &cola, &work[pw], &nblst, &a[j + (jcol +
  1128. nnb) * a_dim1], lda);
  1129. ppwo = nblst * nblst + 1;
  1130. j0 = j - nnb;
  1131. i__3 = jcol + 1;
  1132. i__6 = -nnb;
  1133. for (j = j0; i__6 < 0 ? j >= i__3 : j <= i__3; j += i__6) {
  1134. if (blk22) {
  1135. /* Exploit the structure of */
  1136. /* [ U11 U12 ] */
  1137. /* U = [ ] */
  1138. /* [ U21 U22 ], */
  1139. /* where all blocks are NNB-by-NNB, U21 is upper */
  1140. /* triangular and U12 is lower triangular. */
  1141. i__5 = nnb << 1;
  1142. i__4 = nnb << 1;
  1143. i__7 = *lwork - pw + 1;
  1144. dorm22_("Left", "Transpose", &i__5, &cola, &nnb, &nnb, &
  1145. work[ppwo], &i__4, &a[j + (jcol + nnb) * a_dim1],
  1146. lda, &work[pw], &i__7, &ierr);
  1147. } else {
  1148. /* Ignore the structure of U. */
  1149. i__5 = nnb << 1;
  1150. i__4 = nnb << 1;
  1151. i__7 = nnb << 1;
  1152. i__8 = nnb << 1;
  1153. dgemm_("Transpose", "No Transpose", &i__5, &cola, &i__4, &
  1154. c_b15, &work[ppwo], &i__7, &a[j + (jcol + nnb) *
  1155. a_dim1], lda, &c_b14, &work[pw], &i__8);
  1156. i__5 = nnb << 1;
  1157. i__4 = nnb << 1;
  1158. dlacpy_("All", &i__5, &cola, &work[pw], &i__4, &a[j + (
  1159. jcol + nnb) * a_dim1], lda);
  1160. }
  1161. ppwo += (nnb << 2) * nnb;
  1162. }
  1163. /* Apply accumulated orthogonal matrices to Q. */
  1164. if (wantq) {
  1165. j = *ihi - nblst + 1;
  1166. if (initq) {
  1167. /* Computing MAX */
  1168. i__6 = 2, i__3 = j - jcol + 1;
  1169. topq = f2cmax(i__6,i__3);
  1170. nh = *ihi - topq + 1;
  1171. } else {
  1172. topq = 1;
  1173. nh = *n;
  1174. }
  1175. dgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1176. c_b15, &q[topq + j * q_dim1], ldq, &work[1], &nblst, &
  1177. c_b14, &work[pw], &nh);
  1178. dlacpy_("All", &nh, &nblst, &work[pw], &nh, &q[topq + j *
  1179. q_dim1], ldq);
  1180. ppwo = nblst * nblst + 1;
  1181. j0 = j - nnb;
  1182. i__6 = jcol + 1;
  1183. i__3 = -nnb;
  1184. for (j = j0; i__3 < 0 ? j >= i__6 : j <= i__6; j += i__3) {
  1185. if (initq) {
  1186. /* Computing MAX */
  1187. i__5 = 2, i__4 = j - jcol + 1;
  1188. topq = f2cmax(i__5,i__4);
  1189. nh = *ihi - topq + 1;
  1190. }
  1191. if (blk22) {
  1192. /* Exploit the structure of U. */
  1193. i__5 = nnb << 1;
  1194. i__4 = nnb << 1;
  1195. i__7 = *lwork - pw + 1;
  1196. dorm22_("Right", "No Transpose", &nh, &i__5, &nnb, &
  1197. nnb, &work[ppwo], &i__4, &q[topq + j * q_dim1]
  1198. , ldq, &work[pw], &i__7, &ierr);
  1199. } else {
  1200. /* Ignore the structure of U. */
  1201. i__5 = nnb << 1;
  1202. i__4 = nnb << 1;
  1203. i__7 = nnb << 1;
  1204. dgemm_("No Transpose", "No Transpose", &nh, &i__5, &
  1205. i__4, &c_b15, &q[topq + j * q_dim1], ldq, &
  1206. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1207. i__5 = nnb << 1;
  1208. dlacpy_("All", &nh, &i__5, &work[pw], &nh, &q[topq +
  1209. j * q_dim1], ldq);
  1210. }
  1211. ppwo += (nnb << 2) * nnb;
  1212. }
  1213. }
  1214. /* Accumulate right Givens rotations if required. */
  1215. if (wantz || top > 0) {
  1216. /* Initialize small orthogonal factors that will hold the */
  1217. /* accumulated Givens rotations in workspace. */
  1218. dlaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &
  1219. nblst);
  1220. pw = nblst * nblst + 1;
  1221. i__3 = n2nb;
  1222. for (i__ = 1; i__ <= i__3; ++i__) {
  1223. i__6 = nnb << 1;
  1224. i__5 = nnb << 1;
  1225. i__4 = nnb << 1;
  1226. dlaset_("All", &i__6, &i__5, &c_b14, &c_b15, &work[pw], &
  1227. i__4);
  1228. pw += (nnb << 2) * nnb;
  1229. }
  1230. /* Accumulate Givens rotations into workspace array. */
  1231. i__3 = jcol + nnb - 1;
  1232. for (j = jcol; j <= i__3; ++j) {
  1233. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  1234. len = j + 2 - jcol;
  1235. jrow = j + n2nb * nnb + 2;
  1236. i__6 = jrow;
  1237. for (i__ = *ihi; i__ >= i__6; --i__) {
  1238. c__ = a[i__ + j * a_dim1];
  1239. a[i__ + j * a_dim1] = 0.;
  1240. s = b[i__ + j * b_dim1];
  1241. b[i__ + j * b_dim1] = 0.;
  1242. i__5 = ppw + len - 1;
  1243. for (jj = ppw; jj <= i__5; ++jj) {
  1244. temp = work[jj + nblst];
  1245. work[jj + nblst] = c__ * temp - s * work[jj];
  1246. work[jj] = s * temp + c__ * work[jj];
  1247. }
  1248. ++len;
  1249. ppw = ppw - nblst - 1;
  1250. }
  1251. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb +
  1252. nnb;
  1253. j0 = jrow - nnb;
  1254. i__6 = j + 2;
  1255. i__5 = -nnb;
  1256. for (jrow = j0; i__5 < 0 ? jrow >= i__6 : jrow <= i__6;
  1257. jrow += i__5) {
  1258. ppw = ppwo;
  1259. len = j + 2 - jcol;
  1260. i__4 = jrow;
  1261. for (i__ = jrow + nnb - 1; i__ >= i__4; --i__) {
  1262. c__ = a[i__ + j * a_dim1];
  1263. a[i__ + j * a_dim1] = 0.;
  1264. s = b[i__ + j * b_dim1];
  1265. b[i__ + j * b_dim1] = 0.;
  1266. i__7 = ppw + len - 1;
  1267. for (jj = ppw; jj <= i__7; ++jj) {
  1268. temp = work[jj + (nnb << 1)];
  1269. work[jj + (nnb << 1)] = c__ * temp - s * work[
  1270. jj];
  1271. work[jj] = s * temp + c__ * work[jj];
  1272. }
  1273. ++len;
  1274. ppw = ppw - (nnb << 1) - 1;
  1275. }
  1276. ppwo += (nnb << 2) * nnb;
  1277. }
  1278. }
  1279. } else {
  1280. i__3 = *ihi - jcol - 1;
  1281. dlaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &a[jcol + 2 +
  1282. jcol * a_dim1], lda);
  1283. i__3 = *ihi - jcol - 1;
  1284. dlaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &b[jcol + 2 +
  1285. jcol * b_dim1], ldb);
  1286. }
  1287. /* Apply accumulated orthogonal matrices to A and B. */
  1288. if (top > 0) {
  1289. j = *ihi - nblst + 1;
  1290. dgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1291. c_b15, &a[j * a_dim1 + 1], lda, &work[1], &nblst, &
  1292. c_b14, &work[pw], &top);
  1293. dlacpy_("All", &top, &nblst, &work[pw], &top, &a[j * a_dim1 +
  1294. 1], lda);
  1295. ppwo = nblst * nblst + 1;
  1296. j0 = j - nnb;
  1297. i__3 = jcol + 1;
  1298. i__5 = -nnb;
  1299. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1300. if (blk22) {
  1301. /* Exploit the structure of U. */
  1302. i__6 = nnb << 1;
  1303. i__4 = nnb << 1;
  1304. i__7 = *lwork - pw + 1;
  1305. dorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1306. nnb, &work[ppwo], &i__4, &a[j * a_dim1 + 1],
  1307. lda, &work[pw], &i__7, &ierr);
  1308. } else {
  1309. /* Ignore the structure of U. */
  1310. i__6 = nnb << 1;
  1311. i__4 = nnb << 1;
  1312. i__7 = nnb << 1;
  1313. dgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1314. i__4, &c_b15, &a[j * a_dim1 + 1], lda, &work[
  1315. ppwo], &i__7, &c_b14, &work[pw], &top);
  1316. i__6 = nnb << 1;
  1317. dlacpy_("All", &top, &i__6, &work[pw], &top, &a[j *
  1318. a_dim1 + 1], lda);
  1319. }
  1320. ppwo += (nnb << 2) * nnb;
  1321. }
  1322. j = *ihi - nblst + 1;
  1323. dgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1324. c_b15, &b[j * b_dim1 + 1], ldb, &work[1], &nblst, &
  1325. c_b14, &work[pw], &top);
  1326. dlacpy_("All", &top, &nblst, &work[pw], &top, &b[j * b_dim1 +
  1327. 1], ldb);
  1328. ppwo = nblst * nblst + 1;
  1329. j0 = j - nnb;
  1330. i__5 = jcol + 1;
  1331. i__3 = -nnb;
  1332. for (j = j0; i__3 < 0 ? j >= i__5 : j <= i__5; j += i__3) {
  1333. if (blk22) {
  1334. /* Exploit the structure of U. */
  1335. i__6 = nnb << 1;
  1336. i__4 = nnb << 1;
  1337. i__7 = *lwork - pw + 1;
  1338. dorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1339. nnb, &work[ppwo], &i__4, &b[j * b_dim1 + 1],
  1340. ldb, &work[pw], &i__7, &ierr);
  1341. } else {
  1342. /* Ignore the structure of U. */
  1343. i__6 = nnb << 1;
  1344. i__4 = nnb << 1;
  1345. i__7 = nnb << 1;
  1346. dgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1347. i__4, &c_b15, &b[j * b_dim1 + 1], ldb, &work[
  1348. ppwo], &i__7, &c_b14, &work[pw], &top);
  1349. i__6 = nnb << 1;
  1350. dlacpy_("All", &top, &i__6, &work[pw], &top, &b[j *
  1351. b_dim1 + 1], ldb);
  1352. }
  1353. ppwo += (nnb << 2) * nnb;
  1354. }
  1355. }
  1356. /* Apply accumulated orthogonal matrices to Z. */
  1357. if (wantz) {
  1358. j = *ihi - nblst + 1;
  1359. if (initq) {
  1360. /* Computing MAX */
  1361. i__3 = 2, i__5 = j - jcol + 1;
  1362. topq = f2cmax(i__3,i__5);
  1363. nh = *ihi - topq + 1;
  1364. } else {
  1365. topq = 1;
  1366. nh = *n;
  1367. }
  1368. dgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1369. c_b15, &z__[topq + j * z_dim1], ldz, &work[1], &nblst,
  1370. &c_b14, &work[pw], &nh);
  1371. dlacpy_("All", &nh, &nblst, &work[pw], &nh, &z__[topq + j *
  1372. z_dim1], ldz);
  1373. ppwo = nblst * nblst + 1;
  1374. j0 = j - nnb;
  1375. i__3 = jcol + 1;
  1376. i__5 = -nnb;
  1377. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1378. if (initq) {
  1379. /* Computing MAX */
  1380. i__6 = 2, i__4 = j - jcol + 1;
  1381. topq = f2cmax(i__6,i__4);
  1382. nh = *ihi - topq + 1;
  1383. }
  1384. if (blk22) {
  1385. /* Exploit the structure of U. */
  1386. i__6 = nnb << 1;
  1387. i__4 = nnb << 1;
  1388. i__7 = *lwork - pw + 1;
  1389. dorm22_("Right", "No Transpose", &nh, &i__6, &nnb, &
  1390. nnb, &work[ppwo], &i__4, &z__[topq + j *
  1391. z_dim1], ldz, &work[pw], &i__7, &ierr);
  1392. } else {
  1393. /* Ignore the structure of U. */
  1394. i__6 = nnb << 1;
  1395. i__4 = nnb << 1;
  1396. i__7 = nnb << 1;
  1397. dgemm_("No Transpose", "No Transpose", &nh, &i__6, &
  1398. i__4, &c_b15, &z__[topq + j * z_dim1], ldz, &
  1399. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1400. i__6 = nnb << 1;
  1401. dlacpy_("All", &nh, &i__6, &work[pw], &nh, &z__[topq
  1402. + j * z_dim1], ldz);
  1403. }
  1404. ppwo += (nnb << 2) * nnb;
  1405. }
  1406. }
  1407. }
  1408. }
  1409. /* Use unblocked code to reduce the rest of the matrix */
  1410. /* Avoid re-initialization of modified Q and Z. */
  1411. *(unsigned char *)compq2 = *(unsigned char *)compq;
  1412. *(unsigned char *)compz2 = *(unsigned char *)compz;
  1413. if (jcol != *ilo) {
  1414. if (wantq) {
  1415. *(unsigned char *)compq2 = 'V';
  1416. }
  1417. if (wantz) {
  1418. *(unsigned char *)compz2 = 'V';
  1419. }
  1420. }
  1421. if (jcol < *ihi) {
  1422. dgghrd_(compq2, compz2, n, &jcol, ihi, &a[a_offset], lda, &b[b_offset]
  1423. , ldb, &q[q_offset], ldq, &z__[z_offset], ldz, &ierr);
  1424. }
  1425. work[1] = (doublereal) lwkopt;
  1426. return 0;
  1427. /* End of DGGHD3 */
  1428. } /* dgghd3_ */