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 blasint logical;
  52. typedef char logical1;
  53. typedef char integer1;
  54. #define TRUE_ (1)
  55. #define FALSE_ (0)
  56. /* Extern is for use with -E */
  57. #ifndef Extern
  58. #define Extern extern
  59. #endif
  60. /* I/O stuff */
  61. typedef int flag;
  62. typedef int ftnlen;
  63. typedef int ftnint;
  64. /*external read, write*/
  65. typedef struct
  66. { flag cierr;
  67. ftnint ciunit;
  68. flag ciend;
  69. char *cifmt;
  70. ftnint cirec;
  71. } cilist;
  72. /*internal read, write*/
  73. typedef struct
  74. { flag icierr;
  75. char *iciunit;
  76. flag iciend;
  77. char *icifmt;
  78. ftnint icirlen;
  79. ftnint icirnum;
  80. } icilist;
  81. /*open*/
  82. typedef struct
  83. { flag oerr;
  84. ftnint ounit;
  85. char *ofnm;
  86. ftnlen ofnmlen;
  87. char *osta;
  88. char *oacc;
  89. char *ofm;
  90. ftnint orl;
  91. char *oblnk;
  92. } olist;
  93. /*close*/
  94. typedef struct
  95. { flag cerr;
  96. ftnint cunit;
  97. char *csta;
  98. } cllist;
  99. /*rewind, backspace, endfile*/
  100. typedef struct
  101. { flag aerr;
  102. ftnint aunit;
  103. } alist;
  104. /* inquire */
  105. typedef struct
  106. { flag inerr;
  107. ftnint inunit;
  108. char *infile;
  109. ftnlen infilen;
  110. ftnint *inex; /*parameters in standard's order*/
  111. ftnint *inopen;
  112. ftnint *innum;
  113. ftnint *innamed;
  114. char *inname;
  115. ftnlen innamlen;
  116. char *inacc;
  117. ftnlen inacclen;
  118. char *inseq;
  119. ftnlen inseqlen;
  120. char *indir;
  121. ftnlen indirlen;
  122. char *infmt;
  123. ftnlen infmtlen;
  124. char *inform;
  125. ftnint informlen;
  126. char *inunf;
  127. ftnlen inunflen;
  128. ftnint *inrecl;
  129. ftnint *innrec;
  130. char *inblank;
  131. ftnlen inblanklen;
  132. } inlist;
  133. #define VOID void
  134. union Multitype { /* for multiple entry points */
  135. integer1 g;
  136. shortint h;
  137. integer i;
  138. /* longint j; */
  139. real r;
  140. doublereal d;
  141. complex c;
  142. doublecomplex z;
  143. };
  144. typedef union Multitype Multitype;
  145. struct Vardesc { /* for Namelist */
  146. char *name;
  147. char *addr;
  148. ftnlen *dims;
  149. int type;
  150. };
  151. typedef struct Vardesc Vardesc;
  152. struct Namelist {
  153. char *name;
  154. Vardesc **vars;
  155. int nvars;
  156. };
  157. typedef struct Namelist Namelist;
  158. #define abs(x) ((x) >= 0 ? (x) : -(x))
  159. #define dabs(x) (fabs(x))
  160. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  161. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  162. #define dmin(a,b) (f2cmin(a,b))
  163. #define dmax(a,b) (f2cmax(a,b))
  164. #define bit_test(a,b) ((a) >> (b) & 1)
  165. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  166. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  167. #define abort_() { sig_die("Fortran abort routine called", 1); }
  168. #define c_abs(z) (cabsf(Cf(z)))
  169. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  170. #ifdef _MSC_VER
  171. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  172. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
  173. #else
  174. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  175. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  176. #endif
  177. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  178. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  179. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  180. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  181. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  182. #define d_abs(x) (fabs(*(x)))
  183. #define d_acos(x) (acos(*(x)))
  184. #define d_asin(x) (asin(*(x)))
  185. #define d_atan(x) (atan(*(x)))
  186. #define d_atn2(x, y) (atan2(*(x),*(y)))
  187. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  188. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  189. #define d_cos(x) (cos(*(x)))
  190. #define d_cosh(x) (cosh(*(x)))
  191. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  192. #define d_exp(x) (exp(*(x)))
  193. #define d_imag(z) (cimag(Cd(z)))
  194. #define r_imag(z) (cimagf(Cf(z)))
  195. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  196. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  198. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define d_log(x) (log(*(x)))
  200. #define d_mod(x, y) (fmod(*(x), *(y)))
  201. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  202. #define d_nint(x) u_nint(*(x))
  203. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  204. #define d_sign(a,b) u_sign(*(a),*(b))
  205. #define r_sign(a,b) u_sign(*(a),*(b))
  206. #define d_sin(x) (sin(*(x)))
  207. #define d_sinh(x) (sinh(*(x)))
  208. #define d_sqrt(x) (sqrt(*(x)))
  209. #define d_tan(x) (tan(*(x)))
  210. #define d_tanh(x) (tanh(*(x)))
  211. #define i_abs(x) abs(*(x))
  212. #define i_dnnt(x) ((integer)u_nint(*(x)))
  213. #define i_len(s, n) (n)
  214. #define i_nint(x) ((integer)u_nint(*(x)))
  215. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  216. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  217. #define pow_si(B,E) spow_ui(*(B),*(E))
  218. #define pow_ri(B,E) spow_ui(*(B),*(E))
  219. #define pow_di(B,E) dpow_ui(*(B),*(E))
  220. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  221. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  222. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  223. #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++ = ' '; }
  224. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  225. #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]; }
  226. #define sig_die(s, kill) { exit(1); }
  227. #define s_stop(s, n) {exit(0);}
  228. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  229. #define z_abs(z) (cabs(Cd(z)))
  230. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  231. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  232. #define myexit_() break;
  233. #define mycycle() continue;
  234. #define myceiling(w) {ceil(w)}
  235. #define myhuge(w) {HUGE_VAL}
  236. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  237. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  238. /* procedure parameter types for -A and -C++ */
  239. #ifdef __cplusplus
  240. typedef logical (*L_fp)(...);
  241. #else
  242. typedef logical (*L_fp)();
  243. #endif
  244. static float spow_ui(float x, integer n) {
  245. float pow=1.0; unsigned long int u;
  246. if(n != 0) {
  247. if(n < 0) n = -n, x = 1/x;
  248. for(u = n; ; ) {
  249. if(u & 01) pow *= x;
  250. if(u >>= 1) x *= x;
  251. else break;
  252. }
  253. }
  254. return pow;
  255. }
  256. static double dpow_ui(double x, integer n) {
  257. double pow=1.0; unsigned long int u;
  258. if(n != 0) {
  259. if(n < 0) n = -n, x = 1/x;
  260. for(u = n; ; ) {
  261. if(u & 01) pow *= x;
  262. if(u >>= 1) x *= x;
  263. else break;
  264. }
  265. }
  266. return pow;
  267. }
  268. #ifdef _MSC_VER
  269. static _Fcomplex cpow_ui(complex x, integer n) {
  270. complex pow={1.0,0.0}; unsigned long int u;
  271. if(n != 0) {
  272. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  273. for(u = n; ; ) {
  274. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  275. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  276. else break;
  277. }
  278. }
  279. _Fcomplex p={pow.r, pow.i};
  280. return p;
  281. }
  282. #else
  283. static _Complex float cpow_ui(_Complex float x, integer n) {
  284. _Complex float pow=1.0; unsigned long int u;
  285. if(n != 0) {
  286. if(n < 0) n = -n, x = 1/x;
  287. for(u = n; ; ) {
  288. if(u & 01) pow *= x;
  289. if(u >>= 1) x *= x;
  290. else break;
  291. }
  292. }
  293. return pow;
  294. }
  295. #endif
  296. #ifdef _MSC_VER
  297. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  298. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  299. if(n != 0) {
  300. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  301. for(u = n; ; ) {
  302. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  303. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  304. else break;
  305. }
  306. }
  307. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  308. return p;
  309. }
  310. #else
  311. static _Complex double zpow_ui(_Complex double x, integer n) {
  312. _Complex double pow=1.0; unsigned long int u;
  313. if(n != 0) {
  314. if(n < 0) n = -n, x = 1/x;
  315. for(u = n; ; ) {
  316. if(u & 01) pow *= x;
  317. if(u >>= 1) x *= x;
  318. else break;
  319. }
  320. }
  321. return pow;
  322. }
  323. #endif
  324. static integer pow_ii(integer x, integer n) {
  325. integer pow; unsigned long int u;
  326. if (n <= 0) {
  327. if (n == 0 || x == 1) pow = 1;
  328. else if (x != -1) pow = x == 0 ? 1/x : 0;
  329. else n = -n;
  330. }
  331. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  332. u = n;
  333. for(pow = 1; ; ) {
  334. if(u & 01) pow *= x;
  335. if(u >>= 1) x *= x;
  336. else break;
  337. }
  338. }
  339. return pow;
  340. }
  341. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  342. {
  343. double m; integer i, mi;
  344. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  345. if (w[i-1]>m) mi=i ,m=w[i-1];
  346. return mi-s+1;
  347. }
  348. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  349. {
  350. float m; integer i, mi;
  351. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  352. if (w[i-1]>m) mi=i ,m=w[i-1];
  353. return mi-s+1;
  354. }
  355. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  356. integer n = *n_, incx = *incx_, incy = *incy_, i;
  357. #ifdef _MSC_VER
  358. _Fcomplex zdotc = {0.0, 0.0};
  359. if (incx == 1 && incy == 1) {
  360. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  361. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  362. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  363. }
  364. } else {
  365. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  366. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  367. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  368. }
  369. }
  370. pCf(z) = zdotc;
  371. }
  372. #else
  373. _Complex float zdotc = 0.0;
  374. if (incx == 1 && incy == 1) {
  375. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  376. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  377. }
  378. } else {
  379. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  380. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  381. }
  382. }
  383. pCf(z) = zdotc;
  384. }
  385. #endif
  386. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  387. integer n = *n_, incx = *incx_, incy = *incy_, i;
  388. #ifdef _MSC_VER
  389. _Dcomplex zdotc = {0.0, 0.0};
  390. if (incx == 1 && incy == 1) {
  391. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  392. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  393. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  394. }
  395. } else {
  396. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  397. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  398. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  399. }
  400. }
  401. pCd(z) = zdotc;
  402. }
  403. #else
  404. _Complex double zdotc = 0.0;
  405. if (incx == 1 && incy == 1) {
  406. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  407. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  408. }
  409. } else {
  410. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  411. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  412. }
  413. }
  414. pCd(z) = zdotc;
  415. }
  416. #endif
  417. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  418. integer n = *n_, incx = *incx_, incy = *incy_, i;
  419. #ifdef _MSC_VER
  420. _Fcomplex zdotc = {0.0, 0.0};
  421. if (incx == 1 && incy == 1) {
  422. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  423. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  424. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  425. }
  426. } else {
  427. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  428. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  429. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  430. }
  431. }
  432. pCf(z) = zdotc;
  433. }
  434. #else
  435. _Complex float zdotc = 0.0;
  436. if (incx == 1 && incy == 1) {
  437. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  438. zdotc += Cf(&x[i]) * Cf(&y[i]);
  439. }
  440. } else {
  441. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  442. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  443. }
  444. }
  445. pCf(z) = zdotc;
  446. }
  447. #endif
  448. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  449. integer n = *n_, incx = *incx_, incy = *incy_, i;
  450. #ifdef _MSC_VER
  451. _Dcomplex zdotc = {0.0, 0.0};
  452. if (incx == 1 && incy == 1) {
  453. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  454. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  455. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  456. }
  457. } else {
  458. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  459. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  460. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  461. }
  462. }
  463. pCd(z) = zdotc;
  464. }
  465. #else
  466. _Complex double zdotc = 0.0;
  467. if (incx == 1 && incy == 1) {
  468. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  469. zdotc += Cd(&x[i]) * Cd(&y[i]);
  470. }
  471. } else {
  472. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  473. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  474. }
  475. }
  476. pCd(z) = zdotc;
  477. }
  478. #endif
  479. /* -- translated by f2c (version 20000121).
  480. You must link the resulting object file with the libraries:
  481. -lf2c -lm (in that order)
  482. */
  483. /* Table of constant values */
  484. static integer c__1 = 1;
  485. static integer c_n1 = -1;
  486. static doublereal c_b14 = 0.;
  487. static doublereal c_b15 = 1.;
  488. static integer c__2 = 2;
  489. static integer c__3 = 3;
  490. static integer c__16 = 16;
  491. /* > \brief \b DGGHD3 */
  492. /* =========== DOCUMENTATION =========== */
  493. /* Online html documentation available at */
  494. /* http://www.netlib.org/lapack/explore-html/ */
  495. /* > \htmlonly */
  496. /* > Download DGGHD3 + dependencies */
  497. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgghd3.
  498. f"> */
  499. /* > [TGZ]</a> */
  500. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgghd3.
  501. f"> */
  502. /* > [ZIP]</a> */
  503. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgghd3.
  504. f"> */
  505. /* > [TXT]</a> */
  506. /* > \endhtmlonly */
  507. /* Definition: */
  508. /* =========== */
  509. /* SUBROUTINE DGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, */
  510. /* LDQ, Z, LDZ, WORK, LWORK, INFO ) */
  511. /* CHARACTER COMPQ, COMPZ */
  512. /* INTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N, LWORK */
  513. /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), Q( LDQ, * ), */
  514. /* $ Z( LDZ, * ), WORK( * ) */
  515. /* > \par Purpose: */
  516. /* ============= */
  517. /* > */
  518. /* > \verbatim */
  519. /* > */
  520. /* > DGGHD3 reduces a pair of real matrices (A,B) to generalized upper */
  521. /* > Hessenberg form using orthogonal transformations, where A is a */
  522. /* > general matrix and B is upper triangular. The form of the */
  523. /* > generalized eigenvalue problem is */
  524. /* > A*x = lambda*B*x, */
  525. /* > and B is typically made upper triangular by computing its QR */
  526. /* > factorization and moving the orthogonal matrix Q to the left side */
  527. /* > of the equation. */
  528. /* > */
  529. /* > This subroutine simultaneously reduces A to a Hessenberg matrix H: */
  530. /* > Q**T*A*Z = H */
  531. /* > and transforms B to another upper triangular matrix T: */
  532. /* > Q**T*B*Z = T */
  533. /* > in order to reduce the problem to its standard form */
  534. /* > H*y = lambda*T*y */
  535. /* > where y = Z**T*x. */
  536. /* > */
  537. /* > The orthogonal matrices Q and Z are determined as products of Givens */
  538. /* > rotations. They may either be formed explicitly, or they may be */
  539. /* > postmultiplied into input matrices Q1 and Z1, so that */
  540. /* > */
  541. /* > Q1 * A * Z1**T = (Q1*Q) * H * (Z1*Z)**T */
  542. /* > */
  543. /* > Q1 * B * Z1**T = (Q1*Q) * T * (Z1*Z)**T */
  544. /* > */
  545. /* > If Q1 is the orthogonal matrix from the QR factorization of B in the */
  546. /* > original equation A*x = lambda*B*x, then DGGHD3 reduces the original */
  547. /* > problem to generalized Hessenberg form. */
  548. /* > */
  549. /* > This is a blocked variant of DGGHRD, using matrix-matrix */
  550. /* > multiplications for parts of the computation to enhance performance. */
  551. /* > \endverbatim */
  552. /* Arguments: */
  553. /* ========== */
  554. /* > \param[in] COMPQ */
  555. /* > \verbatim */
  556. /* > COMPQ is CHARACTER*1 */
  557. /* > = 'N': do not compute Q; */
  558. /* > = 'I': Q is initialized to the unit matrix, and the */
  559. /* > orthogonal matrix Q is returned; */
  560. /* > = 'V': Q must contain an orthogonal matrix Q1 on entry, */
  561. /* > and the product Q1*Q is returned. */
  562. /* > \endverbatim */
  563. /* > */
  564. /* > \param[in] COMPZ */
  565. /* > \verbatim */
  566. /* > COMPZ is CHARACTER*1 */
  567. /* > = 'N': do not compute Z; */
  568. /* > = 'I': Z is initialized to the unit matrix, and the */
  569. /* > orthogonal matrix Z is returned; */
  570. /* > = 'V': Z must contain an orthogonal matrix Z1 on entry, */
  571. /* > and the product Z1*Z is returned. */
  572. /* > \endverbatim */
  573. /* > */
  574. /* > \param[in] N */
  575. /* > \verbatim */
  576. /* > N is INTEGER */
  577. /* > The order of the matrices A and B. N >= 0. */
  578. /* > \endverbatim */
  579. /* > */
  580. /* > \param[in] ILO */
  581. /* > \verbatim */
  582. /* > ILO is INTEGER */
  583. /* > \endverbatim */
  584. /* > */
  585. /* > \param[in] IHI */
  586. /* > \verbatim */
  587. /* > IHI is INTEGER */
  588. /* > */
  589. /* > ILO and IHI mark the rows and columns of A which are to be */
  590. /* > reduced. It is assumed that A is already upper triangular */
  591. /* > in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are */
  592. /* > normally set by a previous call to DGGBAL; otherwise they */
  593. /* > should be set to 1 and N respectively. */
  594. /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
  595. /* > \endverbatim */
  596. /* > */
  597. /* > \param[in,out] A */
  598. /* > \verbatim */
  599. /* > A is DOUBLE PRECISION array, dimension (LDA, N) */
  600. /* > On entry, the N-by-N general matrix to be reduced. */
  601. /* > On exit, the upper triangle and the first subdiagonal of A */
  602. /* > are overwritten with the upper Hessenberg matrix H, and the */
  603. /* > rest is set to zero. */
  604. /* > \endverbatim */
  605. /* > */
  606. /* > \param[in] LDA */
  607. /* > \verbatim */
  608. /* > LDA is INTEGER */
  609. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  610. /* > \endverbatim */
  611. /* > */
  612. /* > \param[in,out] B */
  613. /* > \verbatim */
  614. /* > B is DOUBLE PRECISION array, dimension (LDB, N) */
  615. /* > On entry, the N-by-N upper triangular matrix B. */
  616. /* > On exit, the upper triangular matrix T = Q**T B Z. The */
  617. /* > elements below the diagonal are set to zero. */
  618. /* > \endverbatim */
  619. /* > */
  620. /* > \param[in] LDB */
  621. /* > \verbatim */
  622. /* > LDB is INTEGER */
  623. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  624. /* > \endverbatim */
  625. /* > */
  626. /* > \param[in,out] Q */
  627. /* > \verbatim */
  628. /* > Q is DOUBLE PRECISION array, dimension (LDQ, N) */
  629. /* > On entry, if COMPQ = 'V', the orthogonal matrix Q1, */
  630. /* > typically from the QR factorization of B. */
  631. /* > On exit, if COMPQ='I', the orthogonal matrix Q, and if */
  632. /* > COMPQ = 'V', the product Q1*Q. */
  633. /* > Not referenced if COMPQ='N'. */
  634. /* > \endverbatim */
  635. /* > */
  636. /* > \param[in] LDQ */
  637. /* > \verbatim */
  638. /* > LDQ is INTEGER */
  639. /* > The leading dimension of the array Q. */
  640. /* > LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise. */
  641. /* > \endverbatim */
  642. /* > */
  643. /* > \param[in,out] Z */
  644. /* > \verbatim */
  645. /* > Z is DOUBLE PRECISION array, dimension (LDZ, N) */
  646. /* > On entry, if COMPZ = 'V', the orthogonal matrix Z1. */
  647. /* > On exit, if COMPZ='I', the orthogonal matrix Z, and if */
  648. /* > COMPZ = 'V', the product Z1*Z. */
  649. /* > Not referenced if COMPZ='N'. */
  650. /* > \endverbatim */
  651. /* > */
  652. /* > \param[in] LDZ */
  653. /* > \verbatim */
  654. /* > LDZ is INTEGER */
  655. /* > The leading dimension of the array Z. */
  656. /* > LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise. */
  657. /* > \endverbatim */
  658. /* > */
  659. /* > \param[out] WORK */
  660. /* > \verbatim */
  661. /* > WORK is DOUBLE PRECISION array, dimension (LWORK) */
  662. /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  663. /* > \endverbatim */
  664. /* > */
  665. /* > \param[in] LWORK */
  666. /* > \verbatim */
  667. /* > LWORK is INTEGER */
  668. /* > The length of the array WORK. LWORK >= 1. */
  669. /* > For optimum performance LWORK >= 6*N*NB, where NB is the */
  670. /* > optimal blocksize. */
  671. /* > */
  672. /* > If LWORK = -1, then a workspace query is assumed; the routine */
  673. /* > only calculates the optimal size of the WORK array, returns */
  674. /* > this value as the first entry of the WORK array, and no error */
  675. /* > message related to LWORK is issued by XERBLA. */
  676. /* > \endverbatim */
  677. /* > */
  678. /* > \param[out] INFO */
  679. /* > \verbatim */
  680. /* > INFO is INTEGER */
  681. /* > = 0: successful exit. */
  682. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  683. /* > \endverbatim */
  684. /* Authors: */
  685. /* ======== */
  686. /* > \author Univ. of Tennessee */
  687. /* > \author Univ. of California Berkeley */
  688. /* > \author Univ. of Colorado Denver */
  689. /* > \author NAG Ltd. */
  690. /* > \date January 2015 */
  691. /* > \ingroup doubleOTHERcomputational */
  692. /* > \par Further Details: */
  693. /* ===================== */
  694. /* > */
  695. /* > \verbatim */
  696. /* > */
  697. /* > This routine reduces A to Hessenberg form and maintains B in */
  698. /* > using a blocked variant of Moler and Stewart's original algorithm, */
  699. /* > as described by Kagstrom, Kressner, Quintana-Orti, and Quintana-Orti */
  700. /* > (BIT 2008). */
  701. /* > \endverbatim */
  702. /* > */
  703. /* ===================================================================== */
  704. /* Subroutine */ void dgghd3_(char *compq, char *compz, integer *n, integer *
  705. ilo, integer *ihi, doublereal *a, integer *lda, doublereal *b,
  706. integer *ldb, doublereal *q, integer *ldq, doublereal *z__, integer *
  707. ldz, doublereal *work, integer *lwork, integer *info)
  708. {
  709. /* System generated locals */
  710. integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, z_dim1,
  711. z_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7, i__8;
  712. doublereal d__1;
  713. /* Local variables */
  714. logical blk22;
  715. integer cola, jcol, ierr;
  716. doublereal temp;
  717. extern /* Subroutine */ void drot_(integer *, doublereal *, integer *,
  718. doublereal *, integer *, doublereal *, doublereal *);
  719. integer jrow, topq, ppwo;
  720. doublereal temp1, temp2, temp3, c__;
  721. integer kacc22, i__, j, k;
  722. doublereal s;
  723. extern /* Subroutine */ void dgemm_(char *, char *, integer *, integer *,
  724. integer *, doublereal *, doublereal *, integer *, doublereal *,
  725. integer *, doublereal *, doublereal *, integer *);
  726. extern logical lsame_(char *, char *);
  727. extern /* Subroutine */ void dgemv_(char *, integer *, integer *,
  728. doublereal *, doublereal *, integer *, doublereal *, integer *,
  729. doublereal *, doublereal *, integer *);
  730. integer nbmin;
  731. extern /* Subroutine */ void dorm22_(char *, char *, integer *, integer *,
  732. integer *, integer *, doublereal *, integer *, doublereal *,
  733. integer *, doublereal *, integer *, integer *);
  734. integer nblst;
  735. logical initq;
  736. doublereal c1, c2;
  737. logical wantq;
  738. integer j0;
  739. extern /* Subroutine */ void dtrmv_(char *, char *, char *, integer *,
  740. doublereal *, integer *, doublereal *, integer *);
  741. logical initz, wantz;
  742. doublereal s1, s2;
  743. char compq2[1], compz2[1];
  744. integer nb, jj, nh;
  745. extern /* Subroutine */ void dgghrd_(char *, char *, integer *, integer *,
  746. integer *, doublereal *, integer *, doublereal *, integer *,
  747. doublereal *, integer *, doublereal *, integer *, integer *);
  748. integer nx, pw;
  749. extern /* Subroutine */ void dlaset_(char *, integer *, integer *,
  750. doublereal *, doublereal *, doublereal *, integer *),
  751. dlartg_(doublereal *, doublereal *, doublereal *, doublereal *,
  752. doublereal *);
  753. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  754. integer *, integer *, ftnlen, ftnlen);
  755. extern /* Subroutine */ void dlacpy_(char *, integer *, integer *,
  756. doublereal *, integer *, doublereal *, integer *);
  757. extern int xerbla_(char *, integer *, ftnlen);
  758. integer lwkopt;
  759. logical lquery;
  760. integer nnb, len, top, ppw, n2nb;
  761. /* -- LAPACK computational routine (version 3.8.0) -- */
  762. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  763. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  764. /* January 2015 */
  765. /* ===================================================================== */
  766. /* Decode and test the input parameters. */
  767. /* Parameter adjustments */
  768. a_dim1 = *lda;
  769. a_offset = 1 + a_dim1 * 1;
  770. a -= a_offset;
  771. b_dim1 = *ldb;
  772. b_offset = 1 + b_dim1 * 1;
  773. b -= b_offset;
  774. q_dim1 = *ldq;
  775. q_offset = 1 + q_dim1 * 1;
  776. q -= q_offset;
  777. z_dim1 = *ldz;
  778. z_offset = 1 + z_dim1 * 1;
  779. z__ -= z_offset;
  780. --work;
  781. /* Function Body */
  782. *info = 0;
  783. nb = ilaenv_(&c__1, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (ftnlen)
  784. 1);
  785. /* Computing MAX */
  786. i__1 = *n * 6 * nb;
  787. lwkopt = f2cmax(i__1,1);
  788. work[1] = (doublereal) lwkopt;
  789. initq = lsame_(compq, "I");
  790. wantq = initq || lsame_(compq, "V");
  791. initz = lsame_(compz, "I");
  792. wantz = initz || lsame_(compz, "V");
  793. lquery = *lwork == -1;
  794. if (! lsame_(compq, "N") && ! wantq) {
  795. *info = -1;
  796. } else if (! lsame_(compz, "N") && ! wantz) {
  797. *info = -2;
  798. } else if (*n < 0) {
  799. *info = -3;
  800. } else if (*ilo < 1) {
  801. *info = -4;
  802. } else if (*ihi > *n || *ihi < *ilo - 1) {
  803. *info = -5;
  804. } else if (*lda < f2cmax(1,*n)) {
  805. *info = -7;
  806. } else if (*ldb < f2cmax(1,*n)) {
  807. *info = -9;
  808. } else if (wantq && *ldq < *n || *ldq < 1) {
  809. *info = -11;
  810. } else if (wantz && *ldz < *n || *ldz < 1) {
  811. *info = -13;
  812. } else if (*lwork < 1 && ! lquery) {
  813. *info = -15;
  814. }
  815. if (*info != 0) {
  816. i__1 = -(*info);
  817. xerbla_("DGGHD3", &i__1, (ftnlen)6);
  818. return;
  819. } else if (lquery) {
  820. return;
  821. }
  822. /* Initialize Q and Z if desired. */
  823. if (initq) {
  824. dlaset_("All", n, n, &c_b14, &c_b15, &q[q_offset], ldq);
  825. }
  826. if (initz) {
  827. dlaset_("All", n, n, &c_b14, &c_b15, &z__[z_offset], ldz);
  828. }
  829. /* Zero out lower triangle of B. */
  830. if (*n > 1) {
  831. i__1 = *n - 1;
  832. i__2 = *n - 1;
  833. dlaset_("Lower", &i__1, &i__2, &c_b14, &c_b14, &b[b_dim1 + 2], ldb);
  834. }
  835. /* Quick return if possible */
  836. nh = *ihi - *ilo + 1;
  837. if (nh <= 1) {
  838. work[1] = 1.;
  839. return;
  840. }
  841. /* Determine the blocksize. */
  842. nbmin = ilaenv_(&c__2, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6, (
  843. ftnlen)1);
  844. if (nb > 1 && nb < nh) {
  845. /* Determine when to use unblocked instead of blocked code. */
  846. /* Computing MAX */
  847. i__1 = nb, i__2 = ilaenv_(&c__3, "DGGHD3", " ", n, ilo, ihi, &c_n1, (
  848. ftnlen)6, (ftnlen)1);
  849. nx = f2cmax(i__1,i__2);
  850. if (nx < nh) {
  851. /* Determine if workspace is large enough for blocked code. */
  852. if (*lwork < lwkopt) {
  853. /* Not enough workspace to use optimal NB: determine the */
  854. /* minimum value of NB, and reduce NB or force use of */
  855. /* unblocked code. */
  856. /* Computing MAX */
  857. i__1 = 2, i__2 = ilaenv_(&c__2, "DGGHD3", " ", n, ilo, ihi, &
  858. c_n1, (ftnlen)6, (ftnlen)1);
  859. nbmin = f2cmax(i__1,i__2);
  860. if (*lwork >= *n * 6 * nbmin) {
  861. nb = *lwork / (*n * 6);
  862. } else {
  863. nb = 1;
  864. }
  865. }
  866. }
  867. }
  868. if (nb < nbmin || nb >= nh) {
  869. /* Use unblocked code below */
  870. jcol = *ilo;
  871. } else {
  872. /* Use blocked code */
  873. kacc22 = ilaenv_(&c__16, "DGGHD3", " ", n, ilo, ihi, &c_n1, (ftnlen)6,
  874. (ftnlen)1);
  875. blk22 = kacc22 == 2;
  876. i__1 = *ihi - 2;
  877. i__2 = nb;
  878. for (jcol = *ilo; i__2 < 0 ? jcol >= i__1 : jcol <= i__1; jcol +=
  879. i__2) {
  880. /* Computing MIN */
  881. i__3 = nb, i__4 = *ihi - jcol - 1;
  882. nnb = f2cmin(i__3,i__4);
  883. /* Initialize small orthogonal factors that will hold the */
  884. /* accumulated Givens rotations in workspace. */
  885. /* N2NB denotes the number of 2*NNB-by-2*NNB factors */
  886. /* NBLST denotes the (possibly smaller) order of the last */
  887. /* factor. */
  888. n2nb = (*ihi - jcol - 1) / nnb - 1;
  889. nblst = *ihi - jcol - n2nb * nnb;
  890. dlaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &nblst);
  891. pw = nblst * nblst + 1;
  892. i__3 = n2nb;
  893. for (i__ = 1; i__ <= i__3; ++i__) {
  894. i__4 = nnb << 1;
  895. i__5 = nnb << 1;
  896. i__6 = nnb << 1;
  897. dlaset_("All", &i__4, &i__5, &c_b14, &c_b15, &work[pw], &i__6);
  898. pw += (nnb << 2) * nnb;
  899. }
  900. /* Reduce columns JCOL:JCOL+NNB-1 of A to Hessenberg form. */
  901. i__3 = jcol + nnb - 1;
  902. for (j = jcol; j <= i__3; ++j) {
  903. /* Reduce Jth column of A. Store cosines and sines in Jth */
  904. /* column of A and B, respectively. */
  905. i__4 = j + 2;
  906. for (i__ = *ihi; i__ >= i__4; --i__) {
  907. temp = a[i__ - 1 + j * a_dim1];
  908. dlartg_(&temp, &a[i__ + j * a_dim1], &c__, &s, &a[i__ - 1
  909. + j * a_dim1]);
  910. a[i__ + j * a_dim1] = c__;
  911. b[i__ + j * b_dim1] = s;
  912. }
  913. /* Accumulate Givens rotations into workspace array. */
  914. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  915. len = j + 2 - jcol;
  916. jrow = j + n2nb * nnb + 2;
  917. i__4 = jrow;
  918. for (i__ = *ihi; i__ >= i__4; --i__) {
  919. c__ = a[i__ + j * a_dim1];
  920. s = b[i__ + j * b_dim1];
  921. i__5 = ppw + len - 1;
  922. for (jj = ppw; jj <= i__5; ++jj) {
  923. temp = work[jj + nblst];
  924. work[jj + nblst] = c__ * temp - s * work[jj];
  925. work[jj] = s * temp + c__ * work[jj];
  926. }
  927. ++len;
  928. ppw = ppw - nblst - 1;
  929. }
  930. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb + nnb;
  931. j0 = jrow - nnb;
  932. i__4 = j + 2;
  933. i__5 = -nnb;
  934. for (jrow = j0; i__5 < 0 ? jrow >= i__4 : jrow <= i__4; jrow
  935. += i__5) {
  936. ppw = ppwo;
  937. len = j + 2 - jcol;
  938. i__6 = jrow;
  939. for (i__ = jrow + nnb - 1; i__ >= i__6; --i__) {
  940. c__ = a[i__ + j * a_dim1];
  941. s = b[i__ + j * b_dim1];
  942. i__7 = ppw + len - 1;
  943. for (jj = ppw; jj <= i__7; ++jj) {
  944. temp = work[jj + (nnb << 1)];
  945. work[jj + (nnb << 1)] = c__ * temp - s * work[jj];
  946. work[jj] = s * temp + c__ * work[jj];
  947. }
  948. ++len;
  949. ppw = ppw - (nnb << 1) - 1;
  950. }
  951. ppwo += (nnb << 2) * nnb;
  952. }
  953. /* TOP denotes the number of top rows in A and B that will */
  954. /* not be updated during the next steps. */
  955. if (jcol <= 2) {
  956. top = 0;
  957. } else {
  958. top = jcol;
  959. }
  960. /* Propagate transformations through B and replace stored */
  961. /* left sines/cosines by right sines/cosines. */
  962. i__5 = j + 1;
  963. for (jj = *n; jj >= i__5; --jj) {
  964. /* Update JJth column of B. */
  965. /* Computing MIN */
  966. i__4 = jj + 1;
  967. i__6 = j + 2;
  968. for (i__ = f2cmin(i__4,*ihi); i__ >= i__6; --i__) {
  969. c__ = a[i__ + j * a_dim1];
  970. s = b[i__ + j * b_dim1];
  971. temp = b[i__ + jj * b_dim1];
  972. b[i__ + jj * b_dim1] = c__ * temp - s * b[i__ - 1 +
  973. jj * b_dim1];
  974. b[i__ - 1 + jj * b_dim1] = s * temp + c__ * b[i__ - 1
  975. + jj * b_dim1];
  976. }
  977. /* Annihilate B( JJ+1, JJ ). */
  978. if (jj < *ihi) {
  979. temp = b[jj + 1 + (jj + 1) * b_dim1];
  980. dlartg_(&temp, &b[jj + 1 + jj * b_dim1], &c__, &s, &b[
  981. jj + 1 + (jj + 1) * b_dim1]);
  982. b[jj + 1 + jj * b_dim1] = 0.;
  983. i__6 = jj - top;
  984. drot_(&i__6, &b[top + 1 + (jj + 1) * b_dim1], &c__1, &
  985. b[top + 1 + jj * b_dim1], &c__1, &c__, &s);
  986. a[jj + 1 + j * a_dim1] = c__;
  987. b[jj + 1 + j * b_dim1] = -s;
  988. }
  989. }
  990. /* Update A by transformations from right. */
  991. /* Explicit loop unrolling provides better performance */
  992. /* compared to DLASR. */
  993. /* CALL DLASR( 'Right', 'Variable', 'Backward', IHI-TOP, */
  994. /* $ IHI-J, A( J+2, J ), B( J+2, J ), */
  995. /* $ A( TOP+1, J+1 ), LDA ) */
  996. jj = (*ihi - j - 1) % 3;
  997. i__5 = jj + 1;
  998. for (i__ = *ihi - j - 3; i__ >= i__5; i__ += -3) {
  999. c__ = a[j + 1 + i__ + j * a_dim1];
  1000. s = -b[j + 1 + i__ + j * b_dim1];
  1001. c1 = a[j + 2 + i__ + j * a_dim1];
  1002. s1 = -b[j + 2 + i__ + j * b_dim1];
  1003. c2 = a[j + 3 + i__ + j * a_dim1];
  1004. s2 = -b[j + 3 + i__ + j * b_dim1];
  1005. i__6 = *ihi;
  1006. for (k = top + 1; k <= i__6; ++k) {
  1007. temp = a[k + (j + i__) * a_dim1];
  1008. temp1 = a[k + (j + i__ + 1) * a_dim1];
  1009. temp2 = a[k + (j + i__ + 2) * a_dim1];
  1010. temp3 = a[k + (j + i__ + 3) * a_dim1];
  1011. a[k + (j + i__ + 3) * a_dim1] = c2 * temp3 + s2 *
  1012. temp2;
  1013. temp2 = -s2 * temp3 + c2 * temp2;
  1014. a[k + (j + i__ + 2) * a_dim1] = c1 * temp2 + s1 *
  1015. temp1;
  1016. temp1 = -s1 * temp2 + c1 * temp1;
  1017. a[k + (j + i__ + 1) * a_dim1] = c__ * temp1 + s *
  1018. temp;
  1019. a[k + (j + i__) * a_dim1] = -s * temp1 + c__ * temp;
  1020. }
  1021. }
  1022. if (jj > 0) {
  1023. for (i__ = jj; i__ >= 1; --i__) {
  1024. i__5 = *ihi - top;
  1025. d__1 = -b[j + 1 + i__ + j * b_dim1];
  1026. drot_(&i__5, &a[top + 1 + (j + i__ + 1) * a_dim1], &
  1027. c__1, &a[top + 1 + (j + i__) * a_dim1], &c__1,
  1028. &a[j + 1 + i__ + j * a_dim1], &d__1);
  1029. }
  1030. }
  1031. /* Update (J+1)th column of A by transformations from left. */
  1032. if (j < jcol + nnb - 1) {
  1033. len = j + 1 - jcol;
  1034. /* Multiply with the trailing accumulated orthogonal */
  1035. /* matrix, which takes the form */
  1036. /* [ U11 U12 ] */
  1037. /* U = [ ], */
  1038. /* [ U21 U22 ] */
  1039. /* where U21 is a LEN-by-LEN matrix and U12 is lower */
  1040. /* triangular. */
  1041. jrow = *ihi - nblst + 1;
  1042. dgemv_("Transpose", &nblst, &len, &c_b15, &work[1], &
  1043. nblst, &a[jrow + (j + 1) * a_dim1], &c__1, &c_b14,
  1044. &work[pw], &c__1);
  1045. ppw = pw + len;
  1046. i__5 = jrow + nblst - len - 1;
  1047. for (i__ = jrow; i__ <= i__5; ++i__) {
  1048. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1049. ++ppw;
  1050. }
  1051. i__5 = nblst - len;
  1052. dtrmv_("Lower", "Transpose", "Non-unit", &i__5, &work[len
  1053. * nblst + 1], &nblst, &work[pw + len], &c__1);
  1054. i__5 = nblst - len;
  1055. dgemv_("Transpose", &len, &i__5, &c_b15, &work[(len + 1) *
  1056. nblst - len + 1], &nblst, &a[jrow + nblst - len
  1057. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw +
  1058. len], &c__1);
  1059. ppw = pw;
  1060. i__5 = jrow + nblst - 1;
  1061. for (i__ = jrow; i__ <= i__5; ++i__) {
  1062. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1063. ++ppw;
  1064. }
  1065. /* Multiply with the other accumulated orthogonal */
  1066. /* matrices, which take the form */
  1067. /* [ U11 U12 0 ] */
  1068. /* [ ] */
  1069. /* U = [ U21 U22 0 ], */
  1070. /* [ ] */
  1071. /* [ 0 0 I ] */
  1072. /* where I denotes the (NNB-LEN)-by-(NNB-LEN) identity */
  1073. /* matrix, U21 is a LEN-by-LEN upper triangular matrix */
  1074. /* and U12 is an NNB-by-NNB lower triangular matrix. */
  1075. ppwo = nblst * nblst + 1;
  1076. j0 = jrow - nnb;
  1077. i__5 = jcol + 1;
  1078. i__6 = -nnb;
  1079. for (jrow = j0; i__6 < 0 ? jrow >= i__5 : jrow <= i__5;
  1080. jrow += i__6) {
  1081. ppw = pw + len;
  1082. i__4 = jrow + nnb - 1;
  1083. for (i__ = jrow; i__ <= i__4; ++i__) {
  1084. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1085. ++ppw;
  1086. }
  1087. ppw = pw;
  1088. i__4 = jrow + nnb + len - 1;
  1089. for (i__ = jrow + nnb; i__ <= i__4; ++i__) {
  1090. work[ppw] = a[i__ + (j + 1) * a_dim1];
  1091. ++ppw;
  1092. }
  1093. i__4 = nnb << 1;
  1094. dtrmv_("Upper", "Transpose", "Non-unit", &len, &work[
  1095. ppwo + nnb], &i__4, &work[pw], &c__1);
  1096. i__4 = nnb << 1;
  1097. dtrmv_("Lower", "Transpose", "Non-unit", &nnb, &work[
  1098. ppwo + (len << 1) * nnb], &i__4, &work[pw +
  1099. len], &c__1);
  1100. i__4 = nnb << 1;
  1101. dgemv_("Transpose", &nnb, &len, &c_b15, &work[ppwo], &
  1102. i__4, &a[jrow + (j + 1) * a_dim1], &c__1, &
  1103. c_b15, &work[pw], &c__1);
  1104. i__4 = nnb << 1;
  1105. dgemv_("Transpose", &len, &nnb, &c_b15, &work[ppwo + (
  1106. len << 1) * nnb + nnb], &i__4, &a[jrow + nnb
  1107. + (j + 1) * a_dim1], &c__1, &c_b15, &work[pw
  1108. + len], &c__1);
  1109. ppw = pw;
  1110. i__4 = jrow + len + nnb - 1;
  1111. for (i__ = jrow; i__ <= i__4; ++i__) {
  1112. a[i__ + (j + 1) * a_dim1] = work[ppw];
  1113. ++ppw;
  1114. }
  1115. ppwo += (nnb << 2) * nnb;
  1116. }
  1117. }
  1118. }
  1119. /* Apply accumulated orthogonal matrices to A. */
  1120. cola = *n - jcol - nnb + 1;
  1121. j = *ihi - nblst + 1;
  1122. dgemm_("Transpose", "No Transpose", &nblst, &cola, &nblst, &c_b15,
  1123. &work[1], &nblst, &a[j + (jcol + nnb) * a_dim1], lda, &
  1124. c_b14, &work[pw], &nblst);
  1125. dlacpy_("All", &nblst, &cola, &work[pw], &nblst, &a[j + (jcol +
  1126. nnb) * a_dim1], lda);
  1127. ppwo = nblst * nblst + 1;
  1128. j0 = j - nnb;
  1129. i__3 = jcol + 1;
  1130. i__6 = -nnb;
  1131. for (j = j0; i__6 < 0 ? j >= i__3 : j <= i__3; j += i__6) {
  1132. if (blk22) {
  1133. /* Exploit the structure of */
  1134. /* [ U11 U12 ] */
  1135. /* U = [ ] */
  1136. /* [ U21 U22 ], */
  1137. /* where all blocks are NNB-by-NNB, U21 is upper */
  1138. /* triangular and U12 is lower triangular. */
  1139. i__5 = nnb << 1;
  1140. i__4 = nnb << 1;
  1141. i__7 = *lwork - pw + 1;
  1142. dorm22_("Left", "Transpose", &i__5, &cola, &nnb, &nnb, &
  1143. work[ppwo], &i__4, &a[j + (jcol + nnb) * a_dim1],
  1144. lda, &work[pw], &i__7, &ierr);
  1145. } else {
  1146. /* Ignore the structure of U. */
  1147. i__5 = nnb << 1;
  1148. i__4 = nnb << 1;
  1149. i__7 = nnb << 1;
  1150. i__8 = nnb << 1;
  1151. dgemm_("Transpose", "No Transpose", &i__5, &cola, &i__4, &
  1152. c_b15, &work[ppwo], &i__7, &a[j + (jcol + nnb) *
  1153. a_dim1], lda, &c_b14, &work[pw], &i__8);
  1154. i__5 = nnb << 1;
  1155. i__4 = nnb << 1;
  1156. dlacpy_("All", &i__5, &cola, &work[pw], &i__4, &a[j + (
  1157. jcol + nnb) * a_dim1], lda);
  1158. }
  1159. ppwo += (nnb << 2) * nnb;
  1160. }
  1161. /* Apply accumulated orthogonal matrices to Q. */
  1162. if (wantq) {
  1163. j = *ihi - nblst + 1;
  1164. if (initq) {
  1165. /* Computing MAX */
  1166. i__6 = 2, i__3 = j - jcol + 1;
  1167. topq = f2cmax(i__6,i__3);
  1168. nh = *ihi - topq + 1;
  1169. } else {
  1170. topq = 1;
  1171. nh = *n;
  1172. }
  1173. dgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1174. c_b15, &q[topq + j * q_dim1], ldq, &work[1], &nblst, &
  1175. c_b14, &work[pw], &nh);
  1176. dlacpy_("All", &nh, &nblst, &work[pw], &nh, &q[topq + j *
  1177. q_dim1], ldq);
  1178. ppwo = nblst * nblst + 1;
  1179. j0 = j - nnb;
  1180. i__6 = jcol + 1;
  1181. i__3 = -nnb;
  1182. for (j = j0; i__3 < 0 ? j >= i__6 : j <= i__6; j += i__3) {
  1183. if (initq) {
  1184. /* Computing MAX */
  1185. i__5 = 2, i__4 = j - jcol + 1;
  1186. topq = f2cmax(i__5,i__4);
  1187. nh = *ihi - topq + 1;
  1188. }
  1189. if (blk22) {
  1190. /* Exploit the structure of U. */
  1191. i__5 = nnb << 1;
  1192. i__4 = nnb << 1;
  1193. i__7 = *lwork - pw + 1;
  1194. dorm22_("Right", "No Transpose", &nh, &i__5, &nnb, &
  1195. nnb, &work[ppwo], &i__4, &q[topq + j * q_dim1]
  1196. , ldq, &work[pw], &i__7, &ierr);
  1197. } else {
  1198. /* Ignore the structure of U. */
  1199. i__5 = nnb << 1;
  1200. i__4 = nnb << 1;
  1201. i__7 = nnb << 1;
  1202. dgemm_("No Transpose", "No Transpose", &nh, &i__5, &
  1203. i__4, &c_b15, &q[topq + j * q_dim1], ldq, &
  1204. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1205. i__5 = nnb << 1;
  1206. dlacpy_("All", &nh, &i__5, &work[pw], &nh, &q[topq +
  1207. j * q_dim1], ldq);
  1208. }
  1209. ppwo += (nnb << 2) * nnb;
  1210. }
  1211. }
  1212. /* Accumulate right Givens rotations if required. */
  1213. if (wantz || top > 0) {
  1214. /* Initialize small orthogonal factors that will hold the */
  1215. /* accumulated Givens rotations in workspace. */
  1216. dlaset_("All", &nblst, &nblst, &c_b14, &c_b15, &work[1], &
  1217. nblst);
  1218. pw = nblst * nblst + 1;
  1219. i__3 = n2nb;
  1220. for (i__ = 1; i__ <= i__3; ++i__) {
  1221. i__6 = nnb << 1;
  1222. i__5 = nnb << 1;
  1223. i__4 = nnb << 1;
  1224. dlaset_("All", &i__6, &i__5, &c_b14, &c_b15, &work[pw], &
  1225. i__4);
  1226. pw += (nnb << 2) * nnb;
  1227. }
  1228. /* Accumulate Givens rotations into workspace array. */
  1229. i__3 = jcol + nnb - 1;
  1230. for (j = jcol; j <= i__3; ++j) {
  1231. ppw = (nblst + 1) * (nblst - 2) - j + jcol + 1;
  1232. len = j + 2 - jcol;
  1233. jrow = j + n2nb * nnb + 2;
  1234. i__6 = jrow;
  1235. for (i__ = *ihi; i__ >= i__6; --i__) {
  1236. c__ = a[i__ + j * a_dim1];
  1237. a[i__ + j * a_dim1] = 0.;
  1238. s = b[i__ + j * b_dim1];
  1239. b[i__ + j * b_dim1] = 0.;
  1240. i__5 = ppw + len - 1;
  1241. for (jj = ppw; jj <= i__5; ++jj) {
  1242. temp = work[jj + nblst];
  1243. work[jj + nblst] = c__ * temp - s * work[jj];
  1244. work[jj] = s * temp + c__ * work[jj];
  1245. }
  1246. ++len;
  1247. ppw = ppw - nblst - 1;
  1248. }
  1249. ppwo = nblst * nblst + (nnb + j - jcol - 1 << 1) * nnb +
  1250. nnb;
  1251. j0 = jrow - nnb;
  1252. i__6 = j + 2;
  1253. i__5 = -nnb;
  1254. for (jrow = j0; i__5 < 0 ? jrow >= i__6 : jrow <= i__6;
  1255. jrow += i__5) {
  1256. ppw = ppwo;
  1257. len = j + 2 - jcol;
  1258. i__4 = jrow;
  1259. for (i__ = jrow + nnb - 1; i__ >= i__4; --i__) {
  1260. c__ = a[i__ + j * a_dim1];
  1261. a[i__ + j * a_dim1] = 0.;
  1262. s = b[i__ + j * b_dim1];
  1263. b[i__ + j * b_dim1] = 0.;
  1264. i__7 = ppw + len - 1;
  1265. for (jj = ppw; jj <= i__7; ++jj) {
  1266. temp = work[jj + (nnb << 1)];
  1267. work[jj + (nnb << 1)] = c__ * temp - s * work[
  1268. jj];
  1269. work[jj] = s * temp + c__ * work[jj];
  1270. }
  1271. ++len;
  1272. ppw = ppw - (nnb << 1) - 1;
  1273. }
  1274. ppwo += (nnb << 2) * nnb;
  1275. }
  1276. }
  1277. } else {
  1278. i__3 = *ihi - jcol - 1;
  1279. dlaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &a[jcol + 2 +
  1280. jcol * a_dim1], lda);
  1281. i__3 = *ihi - jcol - 1;
  1282. dlaset_("Lower", &i__3, &nnb, &c_b14, &c_b14, &b[jcol + 2 +
  1283. jcol * b_dim1], ldb);
  1284. }
  1285. /* Apply accumulated orthogonal matrices to A and B. */
  1286. if (top > 0) {
  1287. j = *ihi - nblst + 1;
  1288. dgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1289. c_b15, &a[j * a_dim1 + 1], lda, &work[1], &nblst, &
  1290. c_b14, &work[pw], &top);
  1291. dlacpy_("All", &top, &nblst, &work[pw], &top, &a[j * a_dim1 +
  1292. 1], lda);
  1293. ppwo = nblst * nblst + 1;
  1294. j0 = j - nnb;
  1295. i__3 = jcol + 1;
  1296. i__5 = -nnb;
  1297. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1298. if (blk22) {
  1299. /* Exploit the structure of U. */
  1300. i__6 = nnb << 1;
  1301. i__4 = nnb << 1;
  1302. i__7 = *lwork - pw + 1;
  1303. dorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1304. nnb, &work[ppwo], &i__4, &a[j * a_dim1 + 1],
  1305. lda, &work[pw], &i__7, &ierr);
  1306. } else {
  1307. /* Ignore the structure of U. */
  1308. i__6 = nnb << 1;
  1309. i__4 = nnb << 1;
  1310. i__7 = nnb << 1;
  1311. dgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1312. i__4, &c_b15, &a[j * a_dim1 + 1], lda, &work[
  1313. ppwo], &i__7, &c_b14, &work[pw], &top);
  1314. i__6 = nnb << 1;
  1315. dlacpy_("All", &top, &i__6, &work[pw], &top, &a[j *
  1316. a_dim1 + 1], lda);
  1317. }
  1318. ppwo += (nnb << 2) * nnb;
  1319. }
  1320. j = *ihi - nblst + 1;
  1321. dgemm_("No Transpose", "No Transpose", &top, &nblst, &nblst, &
  1322. c_b15, &b[j * b_dim1 + 1], ldb, &work[1], &nblst, &
  1323. c_b14, &work[pw], &top);
  1324. dlacpy_("All", &top, &nblst, &work[pw], &top, &b[j * b_dim1 +
  1325. 1], ldb);
  1326. ppwo = nblst * nblst + 1;
  1327. j0 = j - nnb;
  1328. i__5 = jcol + 1;
  1329. i__3 = -nnb;
  1330. for (j = j0; i__3 < 0 ? j >= i__5 : j <= i__5; j += i__3) {
  1331. if (blk22) {
  1332. /* Exploit the structure of U. */
  1333. i__6 = nnb << 1;
  1334. i__4 = nnb << 1;
  1335. i__7 = *lwork - pw + 1;
  1336. dorm22_("Right", "No Transpose", &top, &i__6, &nnb, &
  1337. nnb, &work[ppwo], &i__4, &b[j * b_dim1 + 1],
  1338. ldb, &work[pw], &i__7, &ierr);
  1339. } else {
  1340. /* Ignore the structure of U. */
  1341. i__6 = nnb << 1;
  1342. i__4 = nnb << 1;
  1343. i__7 = nnb << 1;
  1344. dgemm_("No Transpose", "No Transpose", &top, &i__6, &
  1345. i__4, &c_b15, &b[j * b_dim1 + 1], ldb, &work[
  1346. ppwo], &i__7, &c_b14, &work[pw], &top);
  1347. i__6 = nnb << 1;
  1348. dlacpy_("All", &top, &i__6, &work[pw], &top, &b[j *
  1349. b_dim1 + 1], ldb);
  1350. }
  1351. ppwo += (nnb << 2) * nnb;
  1352. }
  1353. }
  1354. /* Apply accumulated orthogonal matrices to Z. */
  1355. if (wantz) {
  1356. j = *ihi - nblst + 1;
  1357. if (initq) {
  1358. /* Computing MAX */
  1359. i__3 = 2, i__5 = j - jcol + 1;
  1360. topq = f2cmax(i__3,i__5);
  1361. nh = *ihi - topq + 1;
  1362. } else {
  1363. topq = 1;
  1364. nh = *n;
  1365. }
  1366. dgemm_("No Transpose", "No Transpose", &nh, &nblst, &nblst, &
  1367. c_b15, &z__[topq + j * z_dim1], ldz, &work[1], &nblst,
  1368. &c_b14, &work[pw], &nh);
  1369. dlacpy_("All", &nh, &nblst, &work[pw], &nh, &z__[topq + j *
  1370. z_dim1], ldz);
  1371. ppwo = nblst * nblst + 1;
  1372. j0 = j - nnb;
  1373. i__3 = jcol + 1;
  1374. i__5 = -nnb;
  1375. for (j = j0; i__5 < 0 ? j >= i__3 : j <= i__3; j += i__5) {
  1376. if (initq) {
  1377. /* Computing MAX */
  1378. i__6 = 2, i__4 = j - jcol + 1;
  1379. topq = f2cmax(i__6,i__4);
  1380. nh = *ihi - topq + 1;
  1381. }
  1382. if (blk22) {
  1383. /* Exploit the structure of U. */
  1384. i__6 = nnb << 1;
  1385. i__4 = nnb << 1;
  1386. i__7 = *lwork - pw + 1;
  1387. dorm22_("Right", "No Transpose", &nh, &i__6, &nnb, &
  1388. nnb, &work[ppwo], &i__4, &z__[topq + j *
  1389. z_dim1], ldz, &work[pw], &i__7, &ierr);
  1390. } else {
  1391. /* Ignore the structure of U. */
  1392. i__6 = nnb << 1;
  1393. i__4 = nnb << 1;
  1394. i__7 = nnb << 1;
  1395. dgemm_("No Transpose", "No Transpose", &nh, &i__6, &
  1396. i__4, &c_b15, &z__[topq + j * z_dim1], ldz, &
  1397. work[ppwo], &i__7, &c_b14, &work[pw], &nh);
  1398. i__6 = nnb << 1;
  1399. dlacpy_("All", &nh, &i__6, &work[pw], &nh, &z__[topq
  1400. + j * z_dim1], ldz);
  1401. }
  1402. ppwo += (nnb << 2) * nnb;
  1403. }
  1404. }
  1405. }
  1406. }
  1407. /* Use unblocked code to reduce the rest of the matrix */
  1408. /* Avoid re-initialization of modified Q and Z. */
  1409. *(unsigned char *)compq2 = *(unsigned char *)compq;
  1410. *(unsigned char *)compz2 = *(unsigned char *)compz;
  1411. if (jcol != *ilo) {
  1412. if (wantq) {
  1413. *(unsigned char *)compq2 = 'V';
  1414. }
  1415. if (wantz) {
  1416. *(unsigned char *)compz2 = 'V';
  1417. }
  1418. }
  1419. if (jcol < *ihi) {
  1420. dgghrd_(compq2, compz2, n, &jcol, ihi, &a[a_offset], lda, &b[b_offset]
  1421. , ldb, &q[q_offset], ldq, &z__[z_offset], ldz, &ierr);
  1422. }
  1423. work[1] = (doublereal) lwkopt;
  1424. return;
  1425. /* End of DGGHD3 */
  1426. } /* dgghd3_ */