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.

dlaebz.c 37 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  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. /* > \brief \b DLAEBZ computes the number of eigenvalues of a real symmetric tridiagonal matrix which are less
  484. than or equal to a given value, and performs other tasks required by the routine sstebz. */
  485. /* =========== DOCUMENTATION =========== */
  486. /* Online html documentation available at */
  487. /* http://www.netlib.org/lapack/explore-html/ */
  488. /* > \htmlonly */
  489. /* > Download DLAEBZ + dependencies */
  490. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaebz.
  491. f"> */
  492. /* > [TGZ]</a> */
  493. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaebz.
  494. f"> */
  495. /* > [ZIP]</a> */
  496. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaebz.
  497. f"> */
  498. /* > [TXT]</a> */
  499. /* > \endhtmlonly */
  500. /* Definition: */
  501. /* =========== */
  502. /* SUBROUTINE DLAEBZ( IJOB, NITMAX, N, MMAX, MINP, NBMIN, ABSTOL, */
  503. /* RELTOL, PIVMIN, D, E, E2, NVAL, AB, C, MOUT, */
  504. /* NAB, WORK, IWORK, INFO ) */
  505. /* INTEGER IJOB, INFO, MINP, MMAX, MOUT, N, NBMIN, NITMAX */
  506. /* DOUBLE PRECISION ABSTOL, PIVMIN, RELTOL */
  507. /* INTEGER IWORK( * ), NAB( MMAX, * ), NVAL( * ) */
  508. /* DOUBLE PRECISION AB( MMAX, * ), C( * ), D( * ), E( * ), E2( * ), */
  509. /* $ WORK( * ) */
  510. /* > \par Purpose: */
  511. /* ============= */
  512. /* > */
  513. /* > \verbatim */
  514. /* > */
  515. /* > DLAEBZ contains the iteration loops which compute and use the */
  516. /* > function N(w), which is the count of eigenvalues of a symmetric */
  517. /* > tridiagonal matrix T less than or equal to its argument w. It */
  518. /* > performs a choice of two types of loops: */
  519. /* > */
  520. /* > IJOB=1, followed by */
  521. /* > IJOB=2: It takes as input a list of intervals and returns a list of */
  522. /* > sufficiently small intervals whose union contains the same */
  523. /* > eigenvalues as the union of the original intervals. */
  524. /* > The input intervals are (AB(j,1),AB(j,2)], j=1,...,MINP. */
  525. /* > The output interval (AB(j,1),AB(j,2)] will contain */
  526. /* > eigenvalues NAB(j,1)+1,...,NAB(j,2), where 1 <= j <= MOUT. */
  527. /* > */
  528. /* > IJOB=3: It performs a binary search in each input interval */
  529. /* > (AB(j,1),AB(j,2)] for a point w(j) such that */
  530. /* > N(w(j))=NVAL(j), and uses C(j) as the starting point of */
  531. /* > the search. If such a w(j) is found, then on output */
  532. /* > AB(j,1)=AB(j,2)=w. If no such w(j) is found, then on output */
  533. /* > (AB(j,1),AB(j,2)] will be a small interval containing the */
  534. /* > point where N(w) jumps through NVAL(j), unless that point */
  535. /* > lies outside the initial interval. */
  536. /* > */
  537. /* > Note that the intervals are in all cases half-open intervals, */
  538. /* > i.e., of the form (a,b] , which includes b but not a . */
  539. /* > */
  540. /* > To avoid underflow, the matrix should be scaled so that its largest */
  541. /* > element is no greater than overflow**(1/2) * underflow**(1/4) */
  542. /* > in absolute value. To assure the most accurate computation */
  543. /* > of small eigenvalues, the matrix should be scaled to be */
  544. /* > not much smaller than that, either. */
  545. /* > */
  546. /* > See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */
  547. /* > Matrix", Report CS41, Computer Science Dept., Stanford */
  548. /* > University, July 21, 1966 */
  549. /* > */
  550. /* > Note: the arguments are, in general, *not* checked for unreasonable */
  551. /* > values. */
  552. /* > \endverbatim */
  553. /* Arguments: */
  554. /* ========== */
  555. /* > \param[in] IJOB */
  556. /* > \verbatim */
  557. /* > IJOB is INTEGER */
  558. /* > Specifies what is to be done: */
  559. /* > = 1: Compute NAB for the initial intervals. */
  560. /* > = 2: Perform bisection iteration to find eigenvalues of T. */
  561. /* > = 3: Perform bisection iteration to invert N(w), i.e., */
  562. /* > to find a point which has a specified number of */
  563. /* > eigenvalues of T to its left. */
  564. /* > Other values will cause DLAEBZ to return with INFO=-1. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[in] NITMAX */
  568. /* > \verbatim */
  569. /* > NITMAX is INTEGER */
  570. /* > The maximum number of "levels" of bisection to be */
  571. /* > performed, i.e., an interval of width W will not be made */
  572. /* > smaller than 2^(-NITMAX) * W. If not all intervals */
  573. /* > have converged after NITMAX iterations, then INFO is set */
  574. /* > to the number of non-converged intervals. */
  575. /* > \endverbatim */
  576. /* > */
  577. /* > \param[in] N */
  578. /* > \verbatim */
  579. /* > N is INTEGER */
  580. /* > The dimension n of the tridiagonal matrix T. It must be at */
  581. /* > least 1. */
  582. /* > \endverbatim */
  583. /* > */
  584. /* > \param[in] MMAX */
  585. /* > \verbatim */
  586. /* > MMAX is INTEGER */
  587. /* > The maximum number of intervals. If more than MMAX intervals */
  588. /* > are generated, then DLAEBZ will quit with INFO=MMAX+1. */
  589. /* > \endverbatim */
  590. /* > */
  591. /* > \param[in] MINP */
  592. /* > \verbatim */
  593. /* > MINP is INTEGER */
  594. /* > The initial number of intervals. It may not be greater than */
  595. /* > MMAX. */
  596. /* > \endverbatim */
  597. /* > */
  598. /* > \param[in] NBMIN */
  599. /* > \verbatim */
  600. /* > NBMIN is INTEGER */
  601. /* > The smallest number of intervals that should be processed */
  602. /* > using a vector loop. If zero, then only the scalar loop */
  603. /* > will be used. */
  604. /* > \endverbatim */
  605. /* > */
  606. /* > \param[in] ABSTOL */
  607. /* > \verbatim */
  608. /* > ABSTOL is DOUBLE PRECISION */
  609. /* > The minimum (absolute) width of an interval. When an */
  610. /* > interval is narrower than ABSTOL, or than RELTOL times the */
  611. /* > larger (in magnitude) endpoint, then it is considered to be */
  612. /* > sufficiently small, i.e., converged. This must be at least */
  613. /* > zero. */
  614. /* > \endverbatim */
  615. /* > */
  616. /* > \param[in] RELTOL */
  617. /* > \verbatim */
  618. /* > RELTOL is DOUBLE PRECISION */
  619. /* > The minimum relative width of an interval. When an interval */
  620. /* > is narrower than ABSTOL, or than RELTOL times the larger (in */
  621. /* > magnitude) endpoint, then it is considered to be */
  622. /* > sufficiently small, i.e., converged. Note: this should */
  623. /* > always be at least radix*machine epsilon. */
  624. /* > \endverbatim */
  625. /* > */
  626. /* > \param[in] PIVMIN */
  627. /* > \verbatim */
  628. /* > PIVMIN is DOUBLE PRECISION */
  629. /* > The minimum absolute value of a "pivot" in the Sturm */
  630. /* > sequence loop. */
  631. /* > This must be at least f2cmax |e(j)**2|*safe_min and at */
  632. /* > least safe_min, where safe_min is at least */
  633. /* > the smallest number that can divide one without overflow. */
  634. /* > \endverbatim */
  635. /* > */
  636. /* > \param[in] D */
  637. /* > \verbatim */
  638. /* > D is DOUBLE PRECISION array, dimension (N) */
  639. /* > The diagonal elements of the tridiagonal matrix T. */
  640. /* > \endverbatim */
  641. /* > */
  642. /* > \param[in] E */
  643. /* > \verbatim */
  644. /* > E is DOUBLE PRECISION array, dimension (N) */
  645. /* > The offdiagonal elements of the tridiagonal matrix T in */
  646. /* > positions 1 through N-1. E(N) is arbitrary. */
  647. /* > \endverbatim */
  648. /* > */
  649. /* > \param[in] E2 */
  650. /* > \verbatim */
  651. /* > E2 is DOUBLE PRECISION array, dimension (N) */
  652. /* > The squares of the offdiagonal elements of the tridiagonal */
  653. /* > matrix T. E2(N) is ignored. */
  654. /* > \endverbatim */
  655. /* > */
  656. /* > \param[in,out] NVAL */
  657. /* > \verbatim */
  658. /* > NVAL is INTEGER array, dimension (MINP) */
  659. /* > If IJOB=1 or 2, not referenced. */
  660. /* > If IJOB=3, the desired values of N(w). The elements of NVAL */
  661. /* > will be reordered to correspond with the intervals in AB. */
  662. /* > Thus, NVAL(j) on output will not, in general be the same as */
  663. /* > NVAL(j) on input, but it will correspond with the interval */
  664. /* > (AB(j,1),AB(j,2)] on output. */
  665. /* > \endverbatim */
  666. /* > */
  667. /* > \param[in,out] AB */
  668. /* > \verbatim */
  669. /* > AB is DOUBLE PRECISION array, dimension (MMAX,2) */
  670. /* > The endpoints of the intervals. AB(j,1) is a(j), the left */
  671. /* > endpoint of the j-th interval, and AB(j,2) is b(j), the */
  672. /* > right endpoint of the j-th interval. The input intervals */
  673. /* > will, in general, be modified, split, and reordered by the */
  674. /* > calculation. */
  675. /* > \endverbatim */
  676. /* > */
  677. /* > \param[in,out] C */
  678. /* > \verbatim */
  679. /* > C is DOUBLE PRECISION array, dimension (MMAX) */
  680. /* > If IJOB=1, ignored. */
  681. /* > If IJOB=2, workspace. */
  682. /* > If IJOB=3, then on input C(j) should be initialized to the */
  683. /* > first search point in the binary search. */
  684. /* > \endverbatim */
  685. /* > */
  686. /* > \param[out] MOUT */
  687. /* > \verbatim */
  688. /* > MOUT is INTEGER */
  689. /* > If IJOB=1, the number of eigenvalues in the intervals. */
  690. /* > If IJOB=2 or 3, the number of intervals output. */
  691. /* > If IJOB=3, MOUT will equal MINP. */
  692. /* > \endverbatim */
  693. /* > */
  694. /* > \param[in,out] NAB */
  695. /* > \verbatim */
  696. /* > NAB is INTEGER array, dimension (MMAX,2) */
  697. /* > If IJOB=1, then on output NAB(i,j) will be set to N(AB(i,j)). */
  698. /* > If IJOB=2, then on input, NAB(i,j) should be set. It must */
  699. /* > satisfy the condition: */
  700. /* > N(AB(i,1)) <= NAB(i,1) <= NAB(i,2) <= N(AB(i,2)), */
  701. /* > which means that in interval i only eigenvalues */
  702. /* > NAB(i,1)+1,...,NAB(i,2) will be considered. Usually, */
  703. /* > NAB(i,j)=N(AB(i,j)), from a previous call to DLAEBZ with */
  704. /* > IJOB=1. */
  705. /* > On output, NAB(i,j) will contain */
  706. /* > f2cmax(na(k),f2cmin(nb(k),N(AB(i,j)))), where k is the index of */
  707. /* > the input interval that the output interval */
  708. /* > (AB(j,1),AB(j,2)] came from, and na(k) and nb(k) are the */
  709. /* > the input values of NAB(k,1) and NAB(k,2). */
  710. /* > If IJOB=3, then on output, NAB(i,j) contains N(AB(i,j)), */
  711. /* > unless N(w) > NVAL(i) for all search points w , in which */
  712. /* > case NAB(i,1) will not be modified, i.e., the output */
  713. /* > value will be the same as the input value (modulo */
  714. /* > reorderings -- see NVAL and AB), or unless N(w) < NVAL(i) */
  715. /* > for all search points w , in which case NAB(i,2) will */
  716. /* > not be modified. Normally, NAB should be set to some */
  717. /* > distinctive value(s) before DLAEBZ is called. */
  718. /* > \endverbatim */
  719. /* > */
  720. /* > \param[out] WORK */
  721. /* > \verbatim */
  722. /* > WORK is DOUBLE PRECISION array, dimension (MMAX) */
  723. /* > Workspace. */
  724. /* > \endverbatim */
  725. /* > */
  726. /* > \param[out] IWORK */
  727. /* > \verbatim */
  728. /* > IWORK is INTEGER array, dimension (MMAX) */
  729. /* > Workspace. */
  730. /* > \endverbatim */
  731. /* > */
  732. /* > \param[out] INFO */
  733. /* > \verbatim */
  734. /* > INFO is INTEGER */
  735. /* > = 0: All intervals converged. */
  736. /* > = 1--MMAX: The last INFO intervals did not converge. */
  737. /* > = MMAX+1: More than MMAX intervals were generated. */
  738. /* > \endverbatim */
  739. /* Authors: */
  740. /* ======== */
  741. /* > \author Univ. of Tennessee */
  742. /* > \author Univ. of California Berkeley */
  743. /* > \author Univ. of Colorado Denver */
  744. /* > \author NAG Ltd. */
  745. /* > \date December 2016 */
  746. /* > \ingroup OTHERauxiliary */
  747. /* > \par Further Details: */
  748. /* ===================== */
  749. /* > */
  750. /* > \verbatim */
  751. /* > */
  752. /* > This routine is intended to be called only by other LAPACK */
  753. /* > routines, thus the interface is less user-friendly. It is intended */
  754. /* > for two purposes: */
  755. /* > */
  756. /* > (a) finding eigenvalues. In this case, DLAEBZ should have one or */
  757. /* > more initial intervals set up in AB, and DLAEBZ should be called */
  758. /* > with IJOB=1. This sets up NAB, and also counts the eigenvalues. */
  759. /* > Intervals with no eigenvalues would usually be thrown out at */
  760. /* > this point. Also, if not all the eigenvalues in an interval i */
  761. /* > are desired, NAB(i,1) can be increased or NAB(i,2) decreased. */
  762. /* > For example, set NAB(i,1)=NAB(i,2)-1 to get the largest */
  763. /* > eigenvalue. DLAEBZ is then called with IJOB=2 and MMAX */
  764. /* > no smaller than the value of MOUT returned by the call with */
  765. /* > IJOB=1. After this (IJOB=2) call, eigenvalues NAB(i,1)+1 */
  766. /* > through NAB(i,2) are approximately AB(i,1) (or AB(i,2)) to the */
  767. /* > tolerance specified by ABSTOL and RELTOL. */
  768. /* > */
  769. /* > (b) finding an interval (a',b'] containing eigenvalues w(f),...,w(l). */
  770. /* > In this case, start with a Gershgorin interval (a,b). Set up */
  771. /* > AB to contain 2 search intervals, both initially (a,b). One */
  772. /* > NVAL element should contain f-1 and the other should contain l */
  773. /* > , while C should contain a and b, resp. NAB(i,1) should be -1 */
  774. /* > and NAB(i,2) should be N+1, to flag an error if the desired */
  775. /* > interval does not lie in (a,b). DLAEBZ is then called with */
  776. /* > IJOB=3. On exit, if w(f-1) < w(f), then one of the intervals -- */
  777. /* > j -- will have AB(j,1)=AB(j,2) and NAB(j,1)=NAB(j,2)=f-1, while */
  778. /* > if, to the specified tolerance, w(f-k)=...=w(f+r), k > 0 and r */
  779. /* > >= 0, then the interval will have N(AB(j,1))=NAB(j,1)=f-k and */
  780. /* > N(AB(j,2))=NAB(j,2)=f+r. The cases w(l) < w(l+1) and */
  781. /* > w(l-r)=...=w(l+k) are handled similarly. */
  782. /* > \endverbatim */
  783. /* > */
  784. /* ===================================================================== */
  785. /* Subroutine */ void dlaebz_(integer *ijob, integer *nitmax, integer *n,
  786. integer *mmax, integer *minp, integer *nbmin, doublereal *abstol,
  787. doublereal *reltol, doublereal *pivmin, doublereal *d__, doublereal *
  788. e, doublereal *e2, integer *nval, doublereal *ab, doublereal *c__,
  789. integer *mout, integer *nab, doublereal *work, integer *iwork,
  790. integer *info)
  791. {
  792. /* System generated locals */
  793. integer nab_dim1, nab_offset, ab_dim1, ab_offset, i__1, i__2, i__3, i__4,
  794. i__5, i__6;
  795. doublereal d__1, d__2, d__3, d__4;
  796. /* Local variables */
  797. integer itmp1, itmp2, j, kfnew, klnew, kf, ji, kl, jp, jit;
  798. doublereal tmp1, tmp2;
  799. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  800. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  801. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  802. /* December 2016 */
  803. /* ===================================================================== */
  804. /* Check for Errors */
  805. /* Parameter adjustments */
  806. nab_dim1 = *mmax;
  807. nab_offset = 1 + nab_dim1 * 1;
  808. nab -= nab_offset;
  809. ab_dim1 = *mmax;
  810. ab_offset = 1 + ab_dim1 * 1;
  811. ab -= ab_offset;
  812. --d__;
  813. --e;
  814. --e2;
  815. --nval;
  816. --c__;
  817. --work;
  818. --iwork;
  819. /* Function Body */
  820. *info = 0;
  821. if (*ijob < 1 || *ijob > 3) {
  822. *info = -1;
  823. return;
  824. }
  825. /* Initialize NAB */
  826. if (*ijob == 1) {
  827. /* Compute the number of eigenvalues in the initial intervals. */
  828. *mout = 0;
  829. i__1 = *minp;
  830. for (ji = 1; ji <= i__1; ++ji) {
  831. for (jp = 1; jp <= 2; ++jp) {
  832. tmp1 = d__[1] - ab[ji + jp * ab_dim1];
  833. if (abs(tmp1) < *pivmin) {
  834. tmp1 = -(*pivmin);
  835. }
  836. nab[ji + jp * nab_dim1] = 0;
  837. if (tmp1 <= 0.) {
  838. nab[ji + jp * nab_dim1] = 1;
  839. }
  840. i__2 = *n;
  841. for (j = 2; j <= i__2; ++j) {
  842. tmp1 = d__[j] - e2[j - 1] / tmp1 - ab[ji + jp * ab_dim1];
  843. if (abs(tmp1) < *pivmin) {
  844. tmp1 = -(*pivmin);
  845. }
  846. if (tmp1 <= 0.) {
  847. ++nab[ji + jp * nab_dim1];
  848. }
  849. /* L10: */
  850. }
  851. /* L20: */
  852. }
  853. *mout = *mout + nab[ji + (nab_dim1 << 1)] - nab[ji + nab_dim1];
  854. /* L30: */
  855. }
  856. return;
  857. }
  858. /* Initialize for loop */
  859. /* KF and KL have the following meaning: */
  860. /* Intervals 1,...,KF-1 have converged. */
  861. /* Intervals KF,...,KL still need to be refined. */
  862. kf = 1;
  863. kl = *minp;
  864. /* If IJOB=2, initialize C. */
  865. /* If IJOB=3, use the user-supplied starting point. */
  866. if (*ijob == 2) {
  867. i__1 = *minp;
  868. for (ji = 1; ji <= i__1; ++ji) {
  869. c__[ji] = (ab[ji + ab_dim1] + ab[ji + (ab_dim1 << 1)]) * .5;
  870. /* L40: */
  871. }
  872. }
  873. /* Iteration loop */
  874. i__1 = *nitmax;
  875. for (jit = 1; jit <= i__1; ++jit) {
  876. /* Loop over intervals */
  877. if (kl - kf + 1 >= *nbmin && *nbmin > 0) {
  878. /* Begin of Parallel Version of the loop */
  879. i__2 = kl;
  880. for (ji = kf; ji <= i__2; ++ji) {
  881. /* Compute N(c), the number of eigenvalues less than c */
  882. work[ji] = d__[1] - c__[ji];
  883. iwork[ji] = 0;
  884. if (work[ji] <= *pivmin) {
  885. iwork[ji] = 1;
  886. /* Computing MIN */
  887. d__1 = work[ji], d__2 = -(*pivmin);
  888. work[ji] = f2cmin(d__1,d__2);
  889. }
  890. i__3 = *n;
  891. for (j = 2; j <= i__3; ++j) {
  892. work[ji] = d__[j] - e2[j - 1] / work[ji] - c__[ji];
  893. if (work[ji] <= *pivmin) {
  894. ++iwork[ji];
  895. /* Computing MIN */
  896. d__1 = work[ji], d__2 = -(*pivmin);
  897. work[ji] = f2cmin(d__1,d__2);
  898. }
  899. /* L50: */
  900. }
  901. /* L60: */
  902. }
  903. if (*ijob <= 2) {
  904. /* IJOB=2: Choose all intervals containing eigenvalues. */
  905. klnew = kl;
  906. i__2 = kl;
  907. for (ji = kf; ji <= i__2; ++ji) {
  908. /* Insure that N(w) is monotone */
  909. /* Computing MIN */
  910. /* Computing MAX */
  911. i__5 = nab[ji + nab_dim1], i__6 = iwork[ji];
  912. i__3 = nab[ji + (nab_dim1 << 1)], i__4 = f2cmax(i__5,i__6);
  913. iwork[ji] = f2cmin(i__3,i__4);
  914. /* Update the Queue -- add intervals if both halves */
  915. /* contain eigenvalues. */
  916. if (iwork[ji] == nab[ji + (nab_dim1 << 1)]) {
  917. /* No eigenvalue in the upper interval: */
  918. /* just use the lower interval. */
  919. ab[ji + (ab_dim1 << 1)] = c__[ji];
  920. } else if (iwork[ji] == nab[ji + nab_dim1]) {
  921. /* No eigenvalue in the lower interval: */
  922. /* just use the upper interval. */
  923. ab[ji + ab_dim1] = c__[ji];
  924. } else {
  925. ++klnew;
  926. if (klnew <= *mmax) {
  927. /* Eigenvalue in both intervals -- add upper to */
  928. /* queue. */
  929. ab[klnew + (ab_dim1 << 1)] = ab[ji + (ab_dim1 <<
  930. 1)];
  931. nab[klnew + (nab_dim1 << 1)] = nab[ji + (nab_dim1
  932. << 1)];
  933. ab[klnew + ab_dim1] = c__[ji];
  934. nab[klnew + nab_dim1] = iwork[ji];
  935. ab[ji + (ab_dim1 << 1)] = c__[ji];
  936. nab[ji + (nab_dim1 << 1)] = iwork[ji];
  937. } else {
  938. *info = *mmax + 1;
  939. }
  940. }
  941. /* L70: */
  942. }
  943. if (*info != 0) {
  944. return;
  945. }
  946. kl = klnew;
  947. } else {
  948. /* IJOB=3: Binary search. Keep only the interval containing */
  949. /* w s.t. N(w) = NVAL */
  950. i__2 = kl;
  951. for (ji = kf; ji <= i__2; ++ji) {
  952. if (iwork[ji] <= nval[ji]) {
  953. ab[ji + ab_dim1] = c__[ji];
  954. nab[ji + nab_dim1] = iwork[ji];
  955. }
  956. if (iwork[ji] >= nval[ji]) {
  957. ab[ji + (ab_dim1 << 1)] = c__[ji];
  958. nab[ji + (nab_dim1 << 1)] = iwork[ji];
  959. }
  960. /* L80: */
  961. }
  962. }
  963. } else {
  964. /* End of Parallel Version of the loop */
  965. /* Begin of Serial Version of the loop */
  966. klnew = kl;
  967. i__2 = kl;
  968. for (ji = kf; ji <= i__2; ++ji) {
  969. /* Compute N(w), the number of eigenvalues less than w */
  970. tmp1 = c__[ji];
  971. tmp2 = d__[1] - tmp1;
  972. itmp1 = 0;
  973. if (tmp2 <= *pivmin) {
  974. itmp1 = 1;
  975. /* Computing MIN */
  976. d__1 = tmp2, d__2 = -(*pivmin);
  977. tmp2 = f2cmin(d__1,d__2);
  978. }
  979. i__3 = *n;
  980. for (j = 2; j <= i__3; ++j) {
  981. tmp2 = d__[j] - e2[j - 1] / tmp2 - tmp1;
  982. if (tmp2 <= *pivmin) {
  983. ++itmp1;
  984. /* Computing MIN */
  985. d__1 = tmp2, d__2 = -(*pivmin);
  986. tmp2 = f2cmin(d__1,d__2);
  987. }
  988. /* L90: */
  989. }
  990. if (*ijob <= 2) {
  991. /* IJOB=2: Choose all intervals containing eigenvalues. */
  992. /* Insure that N(w) is monotone */
  993. /* Computing MIN */
  994. /* Computing MAX */
  995. i__5 = nab[ji + nab_dim1];
  996. i__3 = nab[ji + (nab_dim1 << 1)], i__4 = f2cmax(i__5,itmp1);
  997. itmp1 = f2cmin(i__3,i__4);
  998. /* Update the Queue -- add intervals if both halves */
  999. /* contain eigenvalues. */
  1000. if (itmp1 == nab[ji + (nab_dim1 << 1)]) {
  1001. /* No eigenvalue in the upper interval: */
  1002. /* just use the lower interval. */
  1003. ab[ji + (ab_dim1 << 1)] = tmp1;
  1004. } else if (itmp1 == nab[ji + nab_dim1]) {
  1005. /* No eigenvalue in the lower interval: */
  1006. /* just use the upper interval. */
  1007. ab[ji + ab_dim1] = tmp1;
  1008. } else if (klnew < *mmax) {
  1009. /* Eigenvalue in both intervals -- add upper to queue. */
  1010. ++klnew;
  1011. ab[klnew + (ab_dim1 << 1)] = ab[ji + (ab_dim1 << 1)];
  1012. nab[klnew + (nab_dim1 << 1)] = nab[ji + (nab_dim1 <<
  1013. 1)];
  1014. ab[klnew + ab_dim1] = tmp1;
  1015. nab[klnew + nab_dim1] = itmp1;
  1016. ab[ji + (ab_dim1 << 1)] = tmp1;
  1017. nab[ji + (nab_dim1 << 1)] = itmp1;
  1018. } else {
  1019. *info = *mmax + 1;
  1020. return;
  1021. }
  1022. } else {
  1023. /* IJOB=3: Binary search. Keep only the interval */
  1024. /* containing w s.t. N(w) = NVAL */
  1025. if (itmp1 <= nval[ji]) {
  1026. ab[ji + ab_dim1] = tmp1;
  1027. nab[ji + nab_dim1] = itmp1;
  1028. }
  1029. if (itmp1 >= nval[ji]) {
  1030. ab[ji + (ab_dim1 << 1)] = tmp1;
  1031. nab[ji + (nab_dim1 << 1)] = itmp1;
  1032. }
  1033. }
  1034. /* L100: */
  1035. }
  1036. kl = klnew;
  1037. }
  1038. /* Check for convergence */
  1039. kfnew = kf;
  1040. i__2 = kl;
  1041. for (ji = kf; ji <= i__2; ++ji) {
  1042. tmp1 = (d__1 = ab[ji + (ab_dim1 << 1)] - ab[ji + ab_dim1], abs(
  1043. d__1));
  1044. /* Computing MAX */
  1045. d__3 = (d__1 = ab[ji + (ab_dim1 << 1)], abs(d__1)), d__4 = (d__2 =
  1046. ab[ji + ab_dim1], abs(d__2));
  1047. tmp2 = f2cmax(d__3,d__4);
  1048. /* Computing MAX */
  1049. d__1 = f2cmax(*abstol,*pivmin), d__2 = *reltol * tmp2;
  1050. if (tmp1 < f2cmax(d__1,d__2) || nab[ji + nab_dim1] >= nab[ji + (
  1051. nab_dim1 << 1)]) {
  1052. /* Converged -- Swap with position KFNEW, */
  1053. /* then increment KFNEW */
  1054. if (ji > kfnew) {
  1055. tmp1 = ab[ji + ab_dim1];
  1056. tmp2 = ab[ji + (ab_dim1 << 1)];
  1057. itmp1 = nab[ji + nab_dim1];
  1058. itmp2 = nab[ji + (nab_dim1 << 1)];
  1059. ab[ji + ab_dim1] = ab[kfnew + ab_dim1];
  1060. ab[ji + (ab_dim1 << 1)] = ab[kfnew + (ab_dim1 << 1)];
  1061. nab[ji + nab_dim1] = nab[kfnew + nab_dim1];
  1062. nab[ji + (nab_dim1 << 1)] = nab[kfnew + (nab_dim1 << 1)];
  1063. ab[kfnew + ab_dim1] = tmp1;
  1064. ab[kfnew + (ab_dim1 << 1)] = tmp2;
  1065. nab[kfnew + nab_dim1] = itmp1;
  1066. nab[kfnew + (nab_dim1 << 1)] = itmp2;
  1067. if (*ijob == 3) {
  1068. itmp1 = nval[ji];
  1069. nval[ji] = nval[kfnew];
  1070. nval[kfnew] = itmp1;
  1071. }
  1072. }
  1073. ++kfnew;
  1074. }
  1075. /* L110: */
  1076. }
  1077. kf = kfnew;
  1078. /* Choose Midpoints */
  1079. i__2 = kl;
  1080. for (ji = kf; ji <= i__2; ++ji) {
  1081. c__[ji] = (ab[ji + ab_dim1] + ab[ji + (ab_dim1 << 1)]) * .5;
  1082. /* L120: */
  1083. }
  1084. /* If no more intervals to refine, quit. */
  1085. if (kf > kl) {
  1086. goto L140;
  1087. }
  1088. /* L130: */
  1089. }
  1090. /* Converged */
  1091. L140:
  1092. /* Computing MAX */
  1093. i__1 = kl + 1 - kf;
  1094. *info = f2cmax(i__1,0);
  1095. *mout = kl;
  1096. return;
  1097. /* End of DLAEBZ */
  1098. } /* dlaebz_ */