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.

zlarrv.c 56 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645
  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]/Cd(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 doublecomplex c_b1 = {0.,0.};
  485. static integer c__1 = 1;
  486. static integer c__2 = 2;
  487. static doublereal c_b28 = 0.;
  488. /* > \brief \b ZLARRV computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenv
  489. alues of L D LT. */
  490. /* =========== DOCUMENTATION =========== */
  491. /* Online html documentation available at */
  492. /* http://www.netlib.org/lapack/explore-html/ */
  493. /* > \htmlonly */
  494. /* > Download ZLARRV + dependencies */
  495. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarrv.
  496. f"> */
  497. /* > [TGZ]</a> */
  498. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarrv.
  499. f"> */
  500. /* > [ZIP]</a> */
  501. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarrv.
  502. f"> */
  503. /* > [TXT]</a> */
  504. /* > \endhtmlonly */
  505. /* Definition: */
  506. /* =========== */
  507. /* SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN, */
  508. /* ISPLIT, M, DOL, DOU, MINRGP, */
  509. /* RTOL1, RTOL2, W, WERR, WGAP, */
  510. /* IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ, */
  511. /* WORK, IWORK, INFO ) */
  512. /* INTEGER DOL, DOU, INFO, LDZ, M, N */
  513. /* DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU */
  514. /* INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ), */
  515. /* $ ISUPPZ( * ), IWORK( * ) */
  516. /* DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ), */
  517. /* $ WGAP( * ), WORK( * ) */
  518. /* COMPLEX*16 Z( LDZ, * ) */
  519. /* > \par Purpose: */
  520. /* ============= */
  521. /* > */
  522. /* > \verbatim */
  523. /* > */
  524. /* > ZLARRV computes the eigenvectors of the tridiagonal matrix */
  525. /* > T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T. */
  526. /* > The input eigenvalues should have been computed by DLARRE. */
  527. /* > \endverbatim */
  528. /* Arguments: */
  529. /* ========== */
  530. /* > \param[in] N */
  531. /* > \verbatim */
  532. /* > N is INTEGER */
  533. /* > The order of the matrix. N >= 0. */
  534. /* > \endverbatim */
  535. /* > */
  536. /* > \param[in] VL */
  537. /* > \verbatim */
  538. /* > VL is DOUBLE PRECISION */
  539. /* > Lower bound of the interval that contains the desired */
  540. /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
  541. /* > end of the extremal eigenvalues in the desired RANGE. */
  542. /* > \endverbatim */
  543. /* > */
  544. /* > \param[in] VU */
  545. /* > \verbatim */
  546. /* > VU is DOUBLE PRECISION */
  547. /* > Upper bound of the interval that contains the desired */
  548. /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
  549. /* > end of the extremal eigenvalues in the desired RANGE. */
  550. /* > \endverbatim */
  551. /* > */
  552. /* > \param[in,out] D */
  553. /* > \verbatim */
  554. /* > D is DOUBLE PRECISION array, dimension (N) */
  555. /* > On entry, the N diagonal elements of the diagonal matrix D. */
  556. /* > On exit, D may be overwritten. */
  557. /* > \endverbatim */
  558. /* > */
  559. /* > \param[in,out] L */
  560. /* > \verbatim */
  561. /* > L is DOUBLE PRECISION array, dimension (N) */
  562. /* > On entry, the (N-1) subdiagonal elements of the unit */
  563. /* > bidiagonal matrix L are in elements 1 to N-1 of L */
  564. /* > (if the matrix is not split.) At the end of each block */
  565. /* > is stored the corresponding shift as given by DLARRE. */
  566. /* > On exit, L is overwritten. */
  567. /* > \endverbatim */
  568. /* > */
  569. /* > \param[in] PIVMIN */
  570. /* > \verbatim */
  571. /* > PIVMIN is DOUBLE PRECISION */
  572. /* > The minimum pivot allowed in the Sturm sequence. */
  573. /* > \endverbatim */
  574. /* > */
  575. /* > \param[in] ISPLIT */
  576. /* > \verbatim */
  577. /* > ISPLIT is INTEGER array, dimension (N) */
  578. /* > The splitting points, at which T breaks up into blocks. */
  579. /* > The first block consists of rows/columns 1 to */
  580. /* > ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 */
  581. /* > through ISPLIT( 2 ), etc. */
  582. /* > \endverbatim */
  583. /* > */
  584. /* > \param[in] M */
  585. /* > \verbatim */
  586. /* > M is INTEGER */
  587. /* > The total number of input eigenvalues. 0 <= M <= N. */
  588. /* > \endverbatim */
  589. /* > */
  590. /* > \param[in] DOL */
  591. /* > \verbatim */
  592. /* > DOL is INTEGER */
  593. /* > \endverbatim */
  594. /* > */
  595. /* > \param[in] DOU */
  596. /* > \verbatim */
  597. /* > DOU is INTEGER */
  598. /* > If the user wants to compute only selected eigenvectors from all */
  599. /* > the eigenvalues supplied, he can specify an index range DOL:DOU. */
  600. /* > Or else the setting DOL=1, DOU=M should be applied. */
  601. /* > Note that DOL and DOU refer to the order in which the eigenvalues */
  602. /* > are stored in W. */
  603. /* > If the user wants to compute only selected eigenpairs, then */
  604. /* > the columns DOL-1 to DOU+1 of the eigenvector space Z contain the */
  605. /* > computed eigenvectors. All other columns of Z are set to zero. */
  606. /* > \endverbatim */
  607. /* > */
  608. /* > \param[in] MINRGP */
  609. /* > \verbatim */
  610. /* > MINRGP is DOUBLE PRECISION */
  611. /* > \endverbatim */
  612. /* > */
  613. /* > \param[in] RTOL1 */
  614. /* > \verbatim */
  615. /* > RTOL1 is DOUBLE PRECISION */
  616. /* > \endverbatim */
  617. /* > */
  618. /* > \param[in] RTOL2 */
  619. /* > \verbatim */
  620. /* > RTOL2 is DOUBLE PRECISION */
  621. /* > Parameters for bisection. */
  622. /* > An interval [LEFT,RIGHT] has converged if */
  623. /* > RIGHT-LEFT < MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */
  624. /* > \endverbatim */
  625. /* > */
  626. /* > \param[in,out] W */
  627. /* > \verbatim */
  628. /* > W is DOUBLE PRECISION array, dimension (N) */
  629. /* > The first M elements of W contain the APPROXIMATE eigenvalues for */
  630. /* > which eigenvectors are to be computed. The eigenvalues */
  631. /* > should be grouped by split-off block and ordered from */
  632. /* > smallest to largest within the block ( The output array */
  633. /* > W from DLARRE is expected here ). Furthermore, they are with */
  634. /* > respect to the shift of the corresponding root representation */
  635. /* > for their block. On exit, W holds the eigenvalues of the */
  636. /* > UNshifted matrix. */
  637. /* > \endverbatim */
  638. /* > */
  639. /* > \param[in,out] WERR */
  640. /* > \verbatim */
  641. /* > WERR is DOUBLE PRECISION array, dimension (N) */
  642. /* > The first M elements contain the semiwidth of the uncertainty */
  643. /* > interval of the corresponding eigenvalue in W */
  644. /* > \endverbatim */
  645. /* > */
  646. /* > \param[in,out] WGAP */
  647. /* > \verbatim */
  648. /* > WGAP is DOUBLE PRECISION array, dimension (N) */
  649. /* > The separation from the right neighbor eigenvalue in W. */
  650. /* > \endverbatim */
  651. /* > */
  652. /* > \param[in] IBLOCK */
  653. /* > \verbatim */
  654. /* > IBLOCK is INTEGER array, dimension (N) */
  655. /* > The indices of the blocks (submatrices) associated with the */
  656. /* > corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */
  657. /* > W(i) belongs to the first block from the top, =2 if W(i) */
  658. /* > belongs to the second block, etc. */
  659. /* > \endverbatim */
  660. /* > */
  661. /* > \param[in] INDEXW */
  662. /* > \verbatim */
  663. /* > INDEXW is INTEGER array, dimension (N) */
  664. /* > The indices of the eigenvalues within each block (submatrix); */
  665. /* > for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */
  666. /* > i-th eigenvalue W(i) is the 10-th eigenvalue in the second block. */
  667. /* > \endverbatim */
  668. /* > */
  669. /* > \param[in] GERS */
  670. /* > \verbatim */
  671. /* > GERS is DOUBLE PRECISION array, dimension (2*N) */
  672. /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
  673. /* > is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should */
  674. /* > be computed from the original UNshifted matrix. */
  675. /* > \endverbatim */
  676. /* > */
  677. /* > \param[out] Z */
  678. /* > \verbatim */
  679. /* > Z is COMPLEX*16 array, dimension (LDZ, f2cmax(1,M) ) */
  680. /* > If INFO = 0, the first M columns of Z contain the */
  681. /* > orthonormal eigenvectors of the matrix T */
  682. /* > corresponding to the input eigenvalues, with the i-th */
  683. /* > column of Z holding the eigenvector associated with W(i). */
  684. /* > Note: the user must ensure that at least f2cmax(1,M) columns are */
  685. /* > supplied in the array Z. */
  686. /* > \endverbatim */
  687. /* > */
  688. /* > \param[in] LDZ */
  689. /* > \verbatim */
  690. /* > LDZ is INTEGER */
  691. /* > The leading dimension of the array Z. LDZ >= 1, and if */
  692. /* > JOBZ = 'V', LDZ >= f2cmax(1,N). */
  693. /* > \endverbatim */
  694. /* > */
  695. /* > \param[out] ISUPPZ */
  696. /* > \verbatim */
  697. /* > ISUPPZ is INTEGER array, dimension ( 2*f2cmax(1,M) ) */
  698. /* > The support of the eigenvectors in Z, i.e., the indices */
  699. /* > indicating the nonzero elements in Z. The I-th eigenvector */
  700. /* > is nonzero only in elements ISUPPZ( 2*I-1 ) through */
  701. /* > ISUPPZ( 2*I ). */
  702. /* > \endverbatim */
  703. /* > */
  704. /* > \param[out] WORK */
  705. /* > \verbatim */
  706. /* > WORK is DOUBLE PRECISION array, dimension (12*N) */
  707. /* > \endverbatim */
  708. /* > */
  709. /* > \param[out] IWORK */
  710. /* > \verbatim */
  711. /* > IWORK is INTEGER array, dimension (7*N) */
  712. /* > \endverbatim */
  713. /* > */
  714. /* > \param[out] INFO */
  715. /* > \verbatim */
  716. /* > INFO is INTEGER */
  717. /* > = 0: successful exit */
  718. /* > */
  719. /* > > 0: A problem occurred in ZLARRV. */
  720. /* > < 0: One of the called subroutines signaled an internal problem. */
  721. /* > Needs inspection of the corresponding parameter IINFO */
  722. /* > for further information. */
  723. /* > */
  724. /* > =-1: Problem in DLARRB when refining a child's eigenvalues. */
  725. /* > =-2: Problem in DLARRF when computing the RRR of a child. */
  726. /* > When a child is inside a tight cluster, it can be difficult */
  727. /* > to find an RRR. A partial remedy from the user's point of */
  728. /* > view is to make the parameter MINRGP smaller and recompile. */
  729. /* > However, as the orthogonality of the computed vectors is */
  730. /* > proportional to 1/MINRGP, the user should be aware that */
  731. /* > he might be trading in precision when he decreases MINRGP. */
  732. /* > =-3: Problem in DLARRB when refining a single eigenvalue */
  733. /* > after the Rayleigh correction was rejected. */
  734. /* > = 5: The Rayleigh Quotient Iteration failed to converge to */
  735. /* > full accuracy in MAXITR steps. */
  736. /* > \endverbatim */
  737. /* Authors: */
  738. /* ======== */
  739. /* > \author Univ. of Tennessee */
  740. /* > \author Univ. of California Berkeley */
  741. /* > \author Univ. of Colorado Denver */
  742. /* > \author NAG Ltd. */
  743. /* > \date June 2016 */
  744. /* > \ingroup complex16OTHERauxiliary */
  745. /* > \par Contributors: */
  746. /* ================== */
  747. /* > */
  748. /* > Beresford Parlett, University of California, Berkeley, USA \n */
  749. /* > Jim Demmel, University of California, Berkeley, USA \n */
  750. /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
  751. /* > Osni Marques, LBNL/NERSC, USA \n */
  752. /* > Christof Voemel, University of California, Berkeley, USA */
  753. /* ===================================================================== */
  754. /* Subroutine */ void zlarrv_(integer *n, doublereal *vl, doublereal *vu,
  755. doublereal *d__, doublereal *l, doublereal *pivmin, integer *isplit,
  756. integer *m, integer *dol, integer *dou, doublereal *minrgp,
  757. doublereal *rtol1, doublereal *rtol2, doublereal *w, doublereal *werr,
  758. doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers,
  759. doublecomplex *z__, integer *ldz, integer *isuppz, doublereal *work,
  760. integer *iwork, integer *info)
  761. {
  762. /* System generated locals */
  763. integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  764. doublereal d__1, d__2;
  765. doublecomplex z__1;
  766. logical L__1;
  767. /* Local variables */
  768. integer iend, jblk;
  769. doublereal lgap;
  770. integer done;
  771. doublereal rgap, left;
  772. integer wend, iter;
  773. doublereal bstw;
  774. integer minwsize, itmp1, i__, j, k, p, q, indld;
  775. doublereal fudge;
  776. integer idone;
  777. doublereal sigma;
  778. integer iinfo, iindr;
  779. doublereal resid;
  780. logical eskip;
  781. doublereal right;
  782. extern /* Subroutine */ void dcopy_(integer *, doublereal *, integer *,
  783. doublereal *, integer *);
  784. integer nclus, zfrom;
  785. doublereal rqtol;
  786. integer iindc1, iindc2, indin1, indin2, miniwsize;
  787. logical stp2ii;
  788. extern /* Subroutine */ void zlar1v_(integer *, integer *, integer *,
  789. doublereal *, doublereal *, doublereal *, doublereal *,
  790. doublereal *, doublereal *, doublereal *, doublecomplex *,
  791. logical *, integer *, doublereal *, doublereal *, integer *,
  792. integer *, doublereal *, doublereal *, doublereal *, doublereal *)
  793. ;
  794. doublereal lambda;
  795. integer ii;
  796. doublereal gl;
  797. integer im, in;
  798. extern doublereal dlamch_(char *);
  799. doublereal gu;
  800. integer ibegin, indeig;
  801. logical needbs;
  802. integer indlld;
  803. doublereal sgndef, mingma;
  804. extern /* Subroutine */ void dlarrb_(integer *, doublereal *, doublereal *,
  805. integer *, integer *, doublereal *, doublereal *, integer *,
  806. doublereal *, doublereal *, doublereal *, doublereal *, integer *,
  807. doublereal *, doublereal *, integer *, integer *);
  808. integer oldien, oldncl, wbegin, negcnt;
  809. doublereal spdiam;
  810. integer oldcls;
  811. doublereal savgap;
  812. integer ndepth;
  813. doublereal ssigma;
  814. extern /* Subroutine */ void dlarrf_(integer *, doublereal *, doublereal *,
  815. doublereal *, integer *, integer *, doublereal *, doublereal *,
  816. doublereal *, doublereal *, doublereal *, doublereal *,
  817. doublereal *, doublereal *, doublereal *, doublereal *,
  818. doublereal *, integer *);
  819. logical usedbs;
  820. integer iindwk, offset;
  821. doublereal gaptol;
  822. extern /* Subroutine */ void zdscal_(integer *, doublereal *,
  823. doublecomplex *, integer *);
  824. integer newcls, oldfst, indwrk, windex, oldlst;
  825. logical usedrq;
  826. integer newfst, newftt, parity, windmn, windpl, isupmn, newlst, zusedl;
  827. doublereal bstres;
  828. integer newsiz, zusedu, zusedw;
  829. doublereal nrminv;
  830. logical tryrqc;
  831. integer isupmx;
  832. doublereal rqcorr;
  833. extern /* Subroutine */ void zlaset_(char *, integer *, integer *,
  834. doublecomplex *, doublecomplex *, doublecomplex *, integer *);
  835. doublereal gap, eps, tau, tol, tmp;
  836. integer zto;
  837. doublereal ztz;
  838. /* -- LAPACK auxiliary routine (version 3.7.1) -- */
  839. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  840. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  841. /* June 2016 */
  842. /* ===================================================================== */
  843. /* Parameter adjustments */
  844. --d__;
  845. --l;
  846. --isplit;
  847. --w;
  848. --werr;
  849. --wgap;
  850. --iblock;
  851. --indexw;
  852. --gers;
  853. z_dim1 = *ldz;
  854. z_offset = 1 + z_dim1 * 1;
  855. z__ -= z_offset;
  856. --isuppz;
  857. --work;
  858. --iwork;
  859. /* Function Body */
  860. *info = 0;
  861. /* Quick return if possible */
  862. if (*n <= 0 || *m <= 0) {
  863. return;
  864. }
  865. /* The first N entries of WORK are reserved for the eigenvalues */
  866. indld = *n + 1;
  867. indlld = (*n << 1) + 1;
  868. indin1 = *n * 3 + 1;
  869. indin2 = (*n << 2) + 1;
  870. indwrk = *n * 5 + 1;
  871. minwsize = *n * 12;
  872. i__1 = minwsize;
  873. for (i__ = 1; i__ <= i__1; ++i__) {
  874. work[i__] = 0.;
  875. /* L5: */
  876. }
  877. /* IWORK(IINDR+1:IINDR+N) hold the twist indices R for the */
  878. /* factorization used to compute the FP vector */
  879. iindr = 0;
  880. /* IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current */
  881. /* layer and the one above. */
  882. iindc1 = *n;
  883. iindc2 = *n << 1;
  884. iindwk = *n * 3 + 1;
  885. miniwsize = *n * 7;
  886. i__1 = miniwsize;
  887. for (i__ = 1; i__ <= i__1; ++i__) {
  888. iwork[i__] = 0;
  889. /* L10: */
  890. }
  891. zusedl = 1;
  892. if (*dol > 1) {
  893. /* Set lower bound for use of Z */
  894. zusedl = *dol - 1;
  895. }
  896. zusedu = *m;
  897. if (*dou < *m) {
  898. /* Set lower bound for use of Z */
  899. zusedu = *dou + 1;
  900. }
  901. /* The width of the part of Z that is used */
  902. zusedw = zusedu - zusedl + 1;
  903. zlaset_("Full", n, &zusedw, &c_b1, &c_b1, &z__[zusedl * z_dim1 + 1], ldz);
  904. eps = dlamch_("Precision");
  905. rqtol = eps * 2.;
  906. /* Set expert flags for standard code. */
  907. tryrqc = TRUE_;
  908. if (*dol == 1 && *dou == *m) {
  909. } else {
  910. /* Only selected eigenpairs are computed. Since the other evalues */
  911. /* are not refined by RQ iteration, bisection has to compute to full */
  912. /* accuracy. */
  913. *rtol1 = eps * 4.;
  914. *rtol2 = eps * 4.;
  915. }
  916. /* The entries WBEGIN:WEND in W, WERR, WGAP correspond to the */
  917. /* desired eigenvalues. The support of the nonzero eigenvector */
  918. /* entries is contained in the interval IBEGIN:IEND. */
  919. /* Remark that if k eigenpairs are desired, then the eigenvectors */
  920. /* are stored in k contiguous columns of Z. */
  921. /* DONE is the number of eigenvectors already computed */
  922. done = 0;
  923. ibegin = 1;
  924. wbegin = 1;
  925. i__1 = iblock[*m];
  926. for (jblk = 1; jblk <= i__1; ++jblk) {
  927. iend = isplit[jblk];
  928. sigma = l[iend];
  929. /* Find the eigenvectors of the submatrix indexed IBEGIN */
  930. /* through IEND. */
  931. wend = wbegin - 1;
  932. L15:
  933. if (wend < *m) {
  934. if (iblock[wend + 1] == jblk) {
  935. ++wend;
  936. goto L15;
  937. }
  938. }
  939. if (wend < wbegin) {
  940. ibegin = iend + 1;
  941. goto L170;
  942. } else if (wend < *dol || wbegin > *dou) {
  943. ibegin = iend + 1;
  944. wbegin = wend + 1;
  945. goto L170;
  946. }
  947. /* Find local spectral diameter of the block */
  948. gl = gers[(ibegin << 1) - 1];
  949. gu = gers[ibegin * 2];
  950. i__2 = iend;
  951. for (i__ = ibegin + 1; i__ <= i__2; ++i__) {
  952. /* Computing MIN */
  953. d__1 = gers[(i__ << 1) - 1];
  954. gl = f2cmin(d__1,gl);
  955. /* Computing MAX */
  956. d__1 = gers[i__ * 2];
  957. gu = f2cmax(d__1,gu);
  958. /* L20: */
  959. }
  960. spdiam = gu - gl;
  961. /* OLDIEN is the last index of the previous block */
  962. oldien = ibegin - 1;
  963. /* Calculate the size of the current block */
  964. in = iend - ibegin + 1;
  965. /* The number of eigenvalues in the current block */
  966. im = wend - wbegin + 1;
  967. /* This is for a 1x1 block */
  968. if (ibegin == iend) {
  969. ++done;
  970. i__2 = ibegin + wbegin * z_dim1;
  971. z__[i__2].r = 1., z__[i__2].i = 0.;
  972. isuppz[(wbegin << 1) - 1] = ibegin;
  973. isuppz[wbegin * 2] = ibegin;
  974. w[wbegin] += sigma;
  975. work[wbegin] = w[wbegin];
  976. ibegin = iend + 1;
  977. ++wbegin;
  978. goto L170;
  979. }
  980. /* The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND) */
  981. /* Note that these can be approximations, in this case, the corresp. */
  982. /* entries of WERR give the size of the uncertainty interval. */
  983. /* The eigenvalue approximations will be refined when necessary as */
  984. /* high relative accuracy is required for the computation of the */
  985. /* corresponding eigenvectors. */
  986. dcopy_(&im, &w[wbegin], &c__1, &work[wbegin], &c__1);
  987. /* We store in W the eigenvalue approximations w.r.t. the original */
  988. /* matrix T. */
  989. i__2 = im;
  990. for (i__ = 1; i__ <= i__2; ++i__) {
  991. w[wbegin + i__ - 1] += sigma;
  992. /* L30: */
  993. }
  994. /* NDEPTH is the current depth of the representation tree */
  995. ndepth = 0;
  996. /* PARITY is either 1 or 0 */
  997. parity = 1;
  998. /* NCLUS is the number of clusters for the next level of the */
  999. /* representation tree, we start with NCLUS = 1 for the root */
  1000. nclus = 1;
  1001. iwork[iindc1 + 1] = 1;
  1002. iwork[iindc1 + 2] = im;
  1003. /* IDONE is the number of eigenvectors already computed in the current */
  1004. /* block */
  1005. idone = 0;
  1006. /* loop while( IDONE.LT.IM ) */
  1007. /* generate the representation tree for the current block and */
  1008. /* compute the eigenvectors */
  1009. L40:
  1010. if (idone < im) {
  1011. /* This is a crude protection against infinitely deep trees */
  1012. if (ndepth > *m) {
  1013. *info = -2;
  1014. return;
  1015. }
  1016. /* breadth first processing of the current level of the representation */
  1017. /* tree: OLDNCL = number of clusters on current level */
  1018. oldncl = nclus;
  1019. /* reset NCLUS to count the number of child clusters */
  1020. nclus = 0;
  1021. parity = 1 - parity;
  1022. if (parity == 0) {
  1023. oldcls = iindc1;
  1024. newcls = iindc2;
  1025. } else {
  1026. oldcls = iindc2;
  1027. newcls = iindc1;
  1028. }
  1029. /* Process the clusters on the current level */
  1030. i__2 = oldncl;
  1031. for (i__ = 1; i__ <= i__2; ++i__) {
  1032. j = oldcls + (i__ << 1);
  1033. /* OLDFST, OLDLST = first, last index of current cluster. */
  1034. /* cluster indices start with 1 and are relative */
  1035. /* to WBEGIN when accessing W, WGAP, WERR, Z */
  1036. oldfst = iwork[j - 1];
  1037. oldlst = iwork[j];
  1038. if (ndepth > 0) {
  1039. /* Retrieve relatively robust representation (RRR) of cluster */
  1040. /* that has been computed at the previous level */
  1041. /* The RRR is stored in Z and overwritten once the eigenvectors */
  1042. /* have been computed or when the cluster is refined */
  1043. if (*dol == 1 && *dou == *m) {
  1044. /* Get representation from location of the leftmost evalue */
  1045. /* of the cluster */
  1046. j = wbegin + oldfst - 1;
  1047. } else {
  1048. if (wbegin + oldfst - 1 < *dol) {
  1049. /* Get representation from the left end of Z array */
  1050. j = *dol - 1;
  1051. } else if (wbegin + oldfst - 1 > *dou) {
  1052. /* Get representation from the right end of Z array */
  1053. j = *dou;
  1054. } else {
  1055. j = wbegin + oldfst - 1;
  1056. }
  1057. }
  1058. i__3 = in - 1;
  1059. for (k = 1; k <= i__3; ++k) {
  1060. i__4 = ibegin + k - 1 + j * z_dim1;
  1061. d__[ibegin + k - 1] = z__[i__4].r;
  1062. i__4 = ibegin + k - 1 + (j + 1) * z_dim1;
  1063. l[ibegin + k - 1] = z__[i__4].r;
  1064. /* L45: */
  1065. }
  1066. i__3 = iend + j * z_dim1;
  1067. d__[iend] = z__[i__3].r;
  1068. i__3 = iend + (j + 1) * z_dim1;
  1069. sigma = z__[i__3].r;
  1070. /* Set the corresponding entries in Z to zero */
  1071. zlaset_("Full", &in, &c__2, &c_b1, &c_b1, &z__[ibegin + j
  1072. * z_dim1], ldz);
  1073. }
  1074. /* Compute DL and DLL of current RRR */
  1075. i__3 = iend - 1;
  1076. for (j = ibegin; j <= i__3; ++j) {
  1077. tmp = d__[j] * l[j];
  1078. work[indld - 1 + j] = tmp;
  1079. work[indlld - 1 + j] = tmp * l[j];
  1080. /* L50: */
  1081. }
  1082. if (ndepth > 0) {
  1083. /* P and Q are index of the first and last eigenvalue to compute */
  1084. /* within the current block */
  1085. p = indexw[wbegin - 1 + oldfst];
  1086. q = indexw[wbegin - 1 + oldlst];
  1087. /* Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET */
  1088. /* through the Q-OFFSET elements of these arrays are to be used. */
  1089. /* OFFSET = P-OLDFST */
  1090. offset = indexw[wbegin] - 1;
  1091. /* perform limited bisection (if necessary) to get approximate */
  1092. /* eigenvalues to the precision needed. */
  1093. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p,
  1094. &q, rtol1, rtol2, &offset, &work[wbegin], &wgap[
  1095. wbegin], &werr[wbegin], &work[indwrk], &iwork[
  1096. iindwk], pivmin, &spdiam, &in, &iinfo);
  1097. if (iinfo != 0) {
  1098. *info = -1;
  1099. return;
  1100. }
  1101. /* We also recompute the extremal gaps. W holds all eigenvalues */
  1102. /* of the unshifted matrix and must be used for computation */
  1103. /* of WGAP, the entries of WORK might stem from RRRs with */
  1104. /* different shifts. The gaps from WBEGIN-1+OLDFST to */
  1105. /* WBEGIN-1+OLDLST are correctly computed in DLARRB. */
  1106. /* However, we only allow the gaps to become greater since */
  1107. /* this is what should happen when we decrease WERR */
  1108. if (oldfst > 1) {
  1109. /* Computing MAX */
  1110. d__1 = wgap[wbegin + oldfst - 2], d__2 = w[wbegin +
  1111. oldfst - 1] - werr[wbegin + oldfst - 1] - w[
  1112. wbegin + oldfst - 2] - werr[wbegin + oldfst -
  1113. 2];
  1114. wgap[wbegin + oldfst - 2] = f2cmax(d__1,d__2);
  1115. }
  1116. if (wbegin + oldlst - 1 < wend) {
  1117. /* Computing MAX */
  1118. d__1 = wgap[wbegin + oldlst - 1], d__2 = w[wbegin +
  1119. oldlst] - werr[wbegin + oldlst] - w[wbegin +
  1120. oldlst - 1] - werr[wbegin + oldlst - 1];
  1121. wgap[wbegin + oldlst - 1] = f2cmax(d__1,d__2);
  1122. }
  1123. /* Each time the eigenvalues in WORK get refined, we store */
  1124. /* the newly found approximation with all shifts applied in W */
  1125. i__3 = oldlst;
  1126. for (j = oldfst; j <= i__3; ++j) {
  1127. w[wbegin + j - 1] = work[wbegin + j - 1] + sigma;
  1128. /* L53: */
  1129. }
  1130. }
  1131. /* Process the current node. */
  1132. newfst = oldfst;
  1133. i__3 = oldlst;
  1134. for (j = oldfst; j <= i__3; ++j) {
  1135. if (j == oldlst) {
  1136. /* we are at the right end of the cluster, this is also the */
  1137. /* boundary of the child cluster */
  1138. newlst = j;
  1139. } else if (wgap[wbegin + j - 1] >= *minrgp * (d__1 = work[
  1140. wbegin + j - 1], abs(d__1))) {
  1141. /* the right relative gap is big enough, the child cluster */
  1142. /* (NEWFST,..,NEWLST) is well separated from the following */
  1143. newlst = j;
  1144. } else {
  1145. /* inside a child cluster, the relative gap is not */
  1146. /* big enough. */
  1147. goto L140;
  1148. }
  1149. /* Compute size of child cluster found */
  1150. newsiz = newlst - newfst + 1;
  1151. /* NEWFTT is the place in Z where the new RRR or the computed */
  1152. /* eigenvector is to be stored */
  1153. if (*dol == 1 && *dou == *m) {
  1154. /* Store representation at location of the leftmost evalue */
  1155. /* of the cluster */
  1156. newftt = wbegin + newfst - 1;
  1157. } else {
  1158. if (wbegin + newfst - 1 < *dol) {
  1159. /* Store representation at the left end of Z array */
  1160. newftt = *dol - 1;
  1161. } else if (wbegin + newfst - 1 > *dou) {
  1162. /* Store representation at the right end of Z array */
  1163. newftt = *dou;
  1164. } else {
  1165. newftt = wbegin + newfst - 1;
  1166. }
  1167. }
  1168. if (newsiz > 1) {
  1169. /* Current child is not a singleton but a cluster. */
  1170. /* Compute and store new representation of child. */
  1171. /* Compute left and right cluster gap. */
  1172. /* LGAP and RGAP are not computed from WORK because */
  1173. /* the eigenvalue approximations may stem from RRRs */
  1174. /* different shifts. However, W hold all eigenvalues */
  1175. /* of the unshifted matrix. Still, the entries in WGAP */
  1176. /* have to be computed from WORK since the entries */
  1177. /* in W might be of the same order so that gaps are not */
  1178. /* exhibited correctly for very close eigenvalues. */
  1179. if (newfst == 1) {
  1180. /* Computing MAX */
  1181. d__1 = 0., d__2 = w[wbegin] - werr[wbegin] - *vl;
  1182. lgap = f2cmax(d__1,d__2);
  1183. } else {
  1184. lgap = wgap[wbegin + newfst - 2];
  1185. }
  1186. rgap = wgap[wbegin + newlst - 1];
  1187. /* Compute left- and rightmost eigenvalue of child */
  1188. /* to high precision in order to shift as close */
  1189. /* as possible and obtain as large relative gaps */
  1190. /* as possible */
  1191. for (k = 1; k <= 2; ++k) {
  1192. if (k == 1) {
  1193. p = indexw[wbegin - 1 + newfst];
  1194. } else {
  1195. p = indexw[wbegin - 1 + newlst];
  1196. }
  1197. offset = indexw[wbegin] - 1;
  1198. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
  1199. - 1], &p, &p, &rqtol, &rqtol, &offset, &
  1200. work[wbegin], &wgap[wbegin], &werr[wbegin]
  1201. , &work[indwrk], &iwork[iindwk], pivmin, &
  1202. spdiam, &in, &iinfo);
  1203. /* L55: */
  1204. }
  1205. if (wbegin + newlst - 1 < *dol || wbegin + newfst - 1
  1206. > *dou) {
  1207. /* if the cluster contains no desired eigenvalues */
  1208. /* skip the computation of that branch of the rep. tree */
  1209. /* We could skip before the refinement of the extremal */
  1210. /* eigenvalues of the child, but then the representation */
  1211. /* tree could be different from the one when nothing is */
  1212. /* skipped. For this reason we skip at this place. */
  1213. idone = idone + newlst - newfst + 1;
  1214. goto L139;
  1215. }
  1216. /* Compute RRR of child cluster. */
  1217. /* Note that the new RRR is stored in Z */
  1218. /* DLARRF needs LWORK = 2*N */
  1219. dlarrf_(&in, &d__[ibegin], &l[ibegin], &work[indld +
  1220. ibegin - 1], &newfst, &newlst, &work[wbegin],
  1221. &wgap[wbegin], &werr[wbegin], &spdiam, &lgap,
  1222. &rgap, pivmin, &tau, &work[indin1], &work[
  1223. indin2], &work[indwrk], &iinfo);
  1224. /* In the complex case, DLARRF cannot write */
  1225. /* the new RRR directly into Z and needs an intermediate */
  1226. /* workspace */
  1227. i__4 = in - 1;
  1228. for (k = 1; k <= i__4; ++k) {
  1229. i__5 = ibegin + k - 1 + newftt * z_dim1;
  1230. i__6 = indin1 + k - 1;
  1231. z__1.r = work[i__6], z__1.i = 0.;
  1232. z__[i__5].r = z__1.r, z__[i__5].i = z__1.i;
  1233. i__5 = ibegin + k - 1 + (newftt + 1) * z_dim1;
  1234. i__6 = indin2 + k - 1;
  1235. z__1.r = work[i__6], z__1.i = 0.;
  1236. z__[i__5].r = z__1.r, z__[i__5].i = z__1.i;
  1237. /* L56: */
  1238. }
  1239. i__4 = iend + newftt * z_dim1;
  1240. i__5 = indin1 + in - 1;
  1241. z__1.r = work[i__5], z__1.i = 0.;
  1242. z__[i__4].r = z__1.r, z__[i__4].i = z__1.i;
  1243. if (iinfo == 0) {
  1244. /* a new RRR for the cluster was found by DLARRF */
  1245. /* update shift and store it */
  1246. ssigma = sigma + tau;
  1247. i__4 = iend + (newftt + 1) * z_dim1;
  1248. z__1.r = ssigma, z__1.i = 0.;
  1249. z__[i__4].r = z__1.r, z__[i__4].i = z__1.i;
  1250. /* WORK() are the midpoints and WERR() the semi-width */
  1251. /* Note that the entries in W are unchanged. */
  1252. i__4 = newlst;
  1253. for (k = newfst; k <= i__4; ++k) {
  1254. fudge = eps * 3. * (d__1 = work[wbegin + k -
  1255. 1], abs(d__1));
  1256. work[wbegin + k - 1] -= tau;
  1257. fudge += eps * 4. * (d__1 = work[wbegin + k -
  1258. 1], abs(d__1));
  1259. /* Fudge errors */
  1260. werr[wbegin + k - 1] += fudge;
  1261. /* Gaps are not fudged. Provided that WERR is small */
  1262. /* when eigenvalues are close, a zero gap indicates */
  1263. /* that a new representation is needed for resolving */
  1264. /* the cluster. A fudge could lead to a wrong decision */
  1265. /* of judging eigenvalues 'separated' which in */
  1266. /* reality are not. This could have a negative impact */
  1267. /* on the orthogonality of the computed eigenvectors. */
  1268. /* L116: */
  1269. }
  1270. ++nclus;
  1271. k = newcls + (nclus << 1);
  1272. iwork[k - 1] = newfst;
  1273. iwork[k] = newlst;
  1274. } else {
  1275. *info = -2;
  1276. return;
  1277. }
  1278. } else {
  1279. /* Compute eigenvector of singleton */
  1280. iter = 0;
  1281. tol = log((doublereal) in) * 4. * eps;
  1282. k = newfst;
  1283. windex = wbegin + k - 1;
  1284. /* Computing MAX */
  1285. i__4 = windex - 1;
  1286. windmn = f2cmax(i__4,1);
  1287. /* Computing MIN */
  1288. i__4 = windex + 1;
  1289. windpl = f2cmin(i__4,*m);
  1290. lambda = work[windex];
  1291. ++done;
  1292. /* Check if eigenvector computation is to be skipped */
  1293. if (windex < *dol || windex > *dou) {
  1294. eskip = TRUE_;
  1295. goto L125;
  1296. } else {
  1297. eskip = FALSE_;
  1298. }
  1299. left = work[windex] - werr[windex];
  1300. right = work[windex] + werr[windex];
  1301. indeig = indexw[windex];
  1302. /* Note that since we compute the eigenpairs for a child, */
  1303. /* all eigenvalue approximations are w.r.t the same shift. */
  1304. /* In this case, the entries in WORK should be used for */
  1305. /* computing the gaps since they exhibit even very small */
  1306. /* differences in the eigenvalues, as opposed to the */
  1307. /* entries in W which might "look" the same. */
  1308. if (k == 1) {
  1309. /* In the case RANGE='I' and with not much initial */
  1310. /* accuracy in LAMBDA and VL, the formula */
  1311. /* LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA ) */
  1312. /* can lead to an overestimation of the left gap and */
  1313. /* thus to inadequately early RQI 'convergence'. */
  1314. /* Prevent this by forcing a small left gap. */
  1315. /* Computing MAX */
  1316. d__1 = abs(left), d__2 = abs(right);
  1317. lgap = eps * f2cmax(d__1,d__2);
  1318. } else {
  1319. lgap = wgap[windmn];
  1320. }
  1321. if (k == im) {
  1322. /* In the case RANGE='I' and with not much initial */
  1323. /* accuracy in LAMBDA and VU, the formula */
  1324. /* can lead to an overestimation of the right gap and */
  1325. /* thus to inadequately early RQI 'convergence'. */
  1326. /* Prevent this by forcing a small right gap. */
  1327. /* Computing MAX */
  1328. d__1 = abs(left), d__2 = abs(right);
  1329. rgap = eps * f2cmax(d__1,d__2);
  1330. } else {
  1331. rgap = wgap[windex];
  1332. }
  1333. gap = f2cmin(lgap,rgap);
  1334. if (k == 1 || k == im) {
  1335. /* The eigenvector support can become wrong */
  1336. /* because significant entries could be cut off due to a */
  1337. /* large GAPTOL parameter in LAR1V. Prevent this. */
  1338. gaptol = 0.;
  1339. } else {
  1340. gaptol = gap * eps;
  1341. }
  1342. isupmn = in;
  1343. isupmx = 1;
  1344. /* Update WGAP so that it holds the minimum gap */
  1345. /* to the left or the right. This is crucial in the */
  1346. /* case where bisection is used to ensure that the */
  1347. /* eigenvalue is refined up to the required precision. */
  1348. /* The correct value is restored afterwards. */
  1349. savgap = wgap[windex];
  1350. wgap[windex] = gap;
  1351. /* We want to use the Rayleigh Quotient Correction */
  1352. /* as often as possible since it converges quadratically */
  1353. /* when we are close enough to the desired eigenvalue. */
  1354. /* However, the Rayleigh Quotient can have the wrong sign */
  1355. /* and lead us away from the desired eigenvalue. In this */
  1356. /* case, the best we can do is to use bisection. */
  1357. usedbs = FALSE_;
  1358. usedrq = FALSE_;
  1359. /* Bisection is initially turned off unless it is forced */
  1360. needbs = ! tryrqc;
  1361. L120:
  1362. /* Check if bisection should be used to refine eigenvalue */
  1363. if (needbs) {
  1364. /* Take the bisection as new iterate */
  1365. usedbs = TRUE_;
  1366. itmp1 = iwork[iindr + windex];
  1367. offset = indexw[wbegin] - 1;
  1368. d__1 = eps * 2.;
  1369. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
  1370. - 1], &indeig, &indeig, &c_b28, &d__1, &
  1371. offset, &work[wbegin], &wgap[wbegin], &
  1372. werr[wbegin], &work[indwrk], &iwork[
  1373. iindwk], pivmin, &spdiam, &itmp1, &iinfo);
  1374. if (iinfo != 0) {
  1375. *info = -3;
  1376. return;
  1377. }
  1378. lambda = work[windex];
  1379. /* Reset twist index from inaccurate LAMBDA to */
  1380. /* force computation of true MINGMA */
  1381. iwork[iindr + windex] = 0;
  1382. }
  1383. /* Given LAMBDA, compute the eigenvector. */
  1384. L__1 = ! usedbs;
  1385. zlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], &l[
  1386. ibegin], &work[indld + ibegin - 1], &work[
  1387. indlld + ibegin - 1], pivmin, &gaptol, &z__[
  1388. ibegin + windex * z_dim1], &L__1, &negcnt, &
  1389. ztz, &mingma, &iwork[iindr + windex], &isuppz[
  1390. (windex << 1) - 1], &nrminv, &resid, &rqcorr,
  1391. &work[indwrk]);
  1392. if (iter == 0) {
  1393. bstres = resid;
  1394. bstw = lambda;
  1395. } else if (resid < bstres) {
  1396. bstres = resid;
  1397. bstw = lambda;
  1398. }
  1399. /* Computing MIN */
  1400. i__4 = isupmn, i__5 = isuppz[(windex << 1) - 1];
  1401. isupmn = f2cmin(i__4,i__5);
  1402. /* Computing MAX */
  1403. i__4 = isupmx, i__5 = isuppz[windex * 2];
  1404. isupmx = f2cmax(i__4,i__5);
  1405. ++iter;
  1406. /* sin alpha <= |resid|/gap */
  1407. /* Note that both the residual and the gap are */
  1408. /* proportional to the matrix, so ||T|| doesn't play */
  1409. /* a role in the quotient */
  1410. /* Convergence test for Rayleigh-Quotient iteration */
  1411. /* (omitted when Bisection has been used) */
  1412. if (resid > tol * gap && abs(rqcorr) > rqtol * abs(
  1413. lambda) && ! usedbs) {
  1414. /* We need to check that the RQCORR update doesn't */
  1415. /* move the eigenvalue away from the desired one and */
  1416. /* towards a neighbor. -> protection with bisection */
  1417. if (indeig <= negcnt) {
  1418. /* The wanted eigenvalue lies to the left */
  1419. sgndef = -1.;
  1420. } else {
  1421. /* The wanted eigenvalue lies to the right */
  1422. sgndef = 1.;
  1423. }
  1424. /* We only use the RQCORR if it improves the */
  1425. /* the iterate reasonably. */
  1426. if (rqcorr * sgndef >= 0. && lambda + rqcorr <=
  1427. right && lambda + rqcorr >= left) {
  1428. usedrq = TRUE_;
  1429. /* Store new midpoint of bisection interval in WORK */
  1430. if (sgndef == 1.) {
  1431. /* The current LAMBDA is on the left of the true */
  1432. /* eigenvalue */
  1433. left = lambda;
  1434. /* We prefer to assume that the error estimate */
  1435. /* is correct. We could make the interval not */
  1436. /* as a bracket but to be modified if the RQCORR */
  1437. /* chooses to. In this case, the RIGHT side should */
  1438. /* be modified as follows: */
  1439. /* RIGHT = MAX(RIGHT, LAMBDA + RQCORR) */
  1440. } else {
  1441. /* The current LAMBDA is on the right of the true */
  1442. /* eigenvalue */
  1443. right = lambda;
  1444. /* See comment about assuming the error estimate is */
  1445. /* correct above. */
  1446. /* LEFT = MIN(LEFT, LAMBDA + RQCORR) */
  1447. }
  1448. work[windex] = (right + left) * .5;
  1449. /* Take RQCORR since it has the correct sign and */
  1450. /* improves the iterate reasonably */
  1451. lambda += rqcorr;
  1452. /* Update width of error interval */
  1453. werr[windex] = (right - left) * .5;
  1454. } else {
  1455. needbs = TRUE_;
  1456. }
  1457. if (right - left < rqtol * abs(lambda)) {
  1458. /* The eigenvalue is computed to bisection accuracy */
  1459. /* compute eigenvector and stop */
  1460. usedbs = TRUE_;
  1461. goto L120;
  1462. } else if (iter < 10) {
  1463. goto L120;
  1464. } else if (iter == 10) {
  1465. needbs = TRUE_;
  1466. goto L120;
  1467. } else {
  1468. *info = 5;
  1469. return;
  1470. }
  1471. } else {
  1472. stp2ii = FALSE_;
  1473. if (usedrq && usedbs && bstres <= resid) {
  1474. lambda = bstw;
  1475. stp2ii = TRUE_;
  1476. }
  1477. if (stp2ii) {
  1478. /* improve error angle by second step */
  1479. L__1 = ! usedbs;
  1480. zlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin]
  1481. , &l[ibegin], &work[indld + ibegin -
  1482. 1], &work[indlld + ibegin - 1],
  1483. pivmin, &gaptol, &z__[ibegin + windex
  1484. * z_dim1], &L__1, &negcnt, &ztz, &
  1485. mingma, &iwork[iindr + windex], &
  1486. isuppz[(windex << 1) - 1], &nrminv, &
  1487. resid, &rqcorr, &work[indwrk]);
  1488. }
  1489. work[windex] = lambda;
  1490. }
  1491. /* Compute FP-vector support w.r.t. whole matrix */
  1492. isuppz[(windex << 1) - 1] += oldien;
  1493. isuppz[windex * 2] += oldien;
  1494. zfrom = isuppz[(windex << 1) - 1];
  1495. zto = isuppz[windex * 2];
  1496. isupmn += oldien;
  1497. isupmx += oldien;
  1498. /* Ensure vector is ok if support in the RQI has changed */
  1499. if (isupmn < zfrom) {
  1500. i__4 = zfrom - 1;
  1501. for (ii = isupmn; ii <= i__4; ++ii) {
  1502. i__5 = ii + windex * z_dim1;
  1503. z__[i__5].r = 0., z__[i__5].i = 0.;
  1504. /* L122: */
  1505. }
  1506. }
  1507. if (isupmx > zto) {
  1508. i__4 = isupmx;
  1509. for (ii = zto + 1; ii <= i__4; ++ii) {
  1510. i__5 = ii + windex * z_dim1;
  1511. z__[i__5].r = 0., z__[i__5].i = 0.;
  1512. /* L123: */
  1513. }
  1514. }
  1515. i__4 = zto - zfrom + 1;
  1516. zdscal_(&i__4, &nrminv, &z__[zfrom + windex * z_dim1],
  1517. &c__1);
  1518. L125:
  1519. /* Update W */
  1520. w[windex] = lambda + sigma;
  1521. /* Recompute the gaps on the left and right */
  1522. /* But only allow them to become larger and not */
  1523. /* smaller (which can only happen through "bad" */
  1524. /* cancellation and doesn't reflect the theory */
  1525. /* where the initial gaps are underestimated due */
  1526. /* to WERR being too crude.) */
  1527. if (! eskip) {
  1528. if (k > 1) {
  1529. /* Computing MAX */
  1530. d__1 = wgap[windmn], d__2 = w[windex] - werr[
  1531. windex] - w[windmn] - werr[windmn];
  1532. wgap[windmn] = f2cmax(d__1,d__2);
  1533. }
  1534. if (windex < wend) {
  1535. /* Computing MAX */
  1536. d__1 = savgap, d__2 = w[windpl] - werr[windpl]
  1537. - w[windex] - werr[windex];
  1538. wgap[windex] = f2cmax(d__1,d__2);
  1539. }
  1540. }
  1541. ++idone;
  1542. }
  1543. /* here ends the code for the current child */
  1544. L139:
  1545. /* Proceed to any remaining child nodes */
  1546. newfst = j + 1;
  1547. L140:
  1548. ;
  1549. }
  1550. /* L150: */
  1551. }
  1552. ++ndepth;
  1553. goto L40;
  1554. }
  1555. ibegin = iend + 1;
  1556. wbegin = wend + 1;
  1557. L170:
  1558. ;
  1559. }
  1560. return;
  1561. /* End of ZLARRV */
  1562. } /* zlarrv_ */