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.

dlarrv.c 55 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <complex.h>
  6. #ifdef complex
  7. #undef complex
  8. #endif
  9. #ifdef I
  10. #undef I
  11. #endif
  12. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef int logical;
  52. typedef short int shortlogical;
  53. typedef char logical1;
  54. typedef char integer1;
  55. #define TRUE_ (1)
  56. #define FALSE_ (0)
  57. /* Extern is for use with -E */
  58. #ifndef Extern
  59. #define Extern extern
  60. #endif
  61. /* I/O stuff */
  62. typedef int flag;
  63. typedef int ftnlen;
  64. typedef int ftnint;
  65. /*external read, write*/
  66. typedef struct
  67. { flag cierr;
  68. ftnint ciunit;
  69. flag ciend;
  70. char *cifmt;
  71. ftnint cirec;
  72. } cilist;
  73. /*internal read, write*/
  74. typedef struct
  75. { flag icierr;
  76. char *iciunit;
  77. flag iciend;
  78. char *icifmt;
  79. ftnint icirlen;
  80. ftnint icirnum;
  81. } icilist;
  82. /*open*/
  83. typedef struct
  84. { flag oerr;
  85. ftnint ounit;
  86. char *ofnm;
  87. ftnlen ofnmlen;
  88. char *osta;
  89. char *oacc;
  90. char *ofm;
  91. ftnint orl;
  92. char *oblnk;
  93. } olist;
  94. /*close*/
  95. typedef struct
  96. { flag cerr;
  97. ftnint cunit;
  98. char *csta;
  99. } cllist;
  100. /*rewind, backspace, endfile*/
  101. typedef struct
  102. { flag aerr;
  103. ftnint aunit;
  104. } alist;
  105. /* inquire */
  106. typedef struct
  107. { flag inerr;
  108. ftnint inunit;
  109. char *infile;
  110. ftnlen infilen;
  111. ftnint *inex; /*parameters in standard's order*/
  112. ftnint *inopen;
  113. ftnint *innum;
  114. ftnint *innamed;
  115. char *inname;
  116. ftnlen innamlen;
  117. char *inacc;
  118. ftnlen inacclen;
  119. char *inseq;
  120. ftnlen inseqlen;
  121. char *indir;
  122. ftnlen indirlen;
  123. char *infmt;
  124. ftnlen infmtlen;
  125. char *inform;
  126. ftnint informlen;
  127. char *inunf;
  128. ftnlen inunflen;
  129. ftnint *inrecl;
  130. ftnint *innrec;
  131. char *inblank;
  132. ftnlen inblanklen;
  133. } inlist;
  134. #define VOID void
  135. union Multitype { /* for multiple entry points */
  136. integer1 g;
  137. shortint h;
  138. integer i;
  139. /* longint j; */
  140. real r;
  141. doublereal d;
  142. complex c;
  143. doublecomplex z;
  144. };
  145. typedef union Multitype Multitype;
  146. struct Vardesc { /* for Namelist */
  147. char *name;
  148. char *addr;
  149. ftnlen *dims;
  150. int type;
  151. };
  152. typedef struct Vardesc Vardesc;
  153. struct Namelist {
  154. char *name;
  155. Vardesc **vars;
  156. int nvars;
  157. };
  158. typedef struct Namelist Namelist;
  159. #define abs(x) ((x) >= 0 ? (x) : -(x))
  160. #define dabs(x) (fabs(x))
  161. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  162. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  163. #define dmin(a,b) (f2cmin(a,b))
  164. #define dmax(a,b) (f2cmax(a,b))
  165. #define bit_test(a,b) ((a) >> (b) & 1)
  166. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  167. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  168. #define abort_() { sig_die("Fortran abort routine called", 1); }
  169. #define c_abs(z) (cabsf(Cf(z)))
  170. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  171. #ifdef _MSC_VER
  172. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  173. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
  174. #else
  175. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  176. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  177. #endif
  178. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  179. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  180. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  181. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  182. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  183. #define d_abs(x) (fabs(*(x)))
  184. #define d_acos(x) (acos(*(x)))
  185. #define d_asin(x) (asin(*(x)))
  186. #define d_atan(x) (atan(*(x)))
  187. #define d_atn2(x, y) (atan2(*(x),*(y)))
  188. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  189. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  190. #define d_cos(x) (cos(*(x)))
  191. #define d_cosh(x) (cosh(*(x)))
  192. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  193. #define d_exp(x) (exp(*(x)))
  194. #define d_imag(z) (cimag(Cd(z)))
  195. #define r_imag(z) (cimagf(Cf(z)))
  196. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  198. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  200. #define d_log(x) (log(*(x)))
  201. #define d_mod(x, y) (fmod(*(x), *(y)))
  202. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  203. #define d_nint(x) u_nint(*(x))
  204. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  205. #define d_sign(a,b) u_sign(*(a),*(b))
  206. #define r_sign(a,b) u_sign(*(a),*(b))
  207. #define d_sin(x) (sin(*(x)))
  208. #define d_sinh(x) (sinh(*(x)))
  209. #define d_sqrt(x) (sqrt(*(x)))
  210. #define d_tan(x) (tan(*(x)))
  211. #define d_tanh(x) (tanh(*(x)))
  212. #define i_abs(x) abs(*(x))
  213. #define i_dnnt(x) ((integer)u_nint(*(x)))
  214. #define i_len(s, n) (n)
  215. #define i_nint(x) ((integer)u_nint(*(x)))
  216. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  217. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  218. #define pow_si(B,E) spow_ui(*(B),*(E))
  219. #define pow_ri(B,E) spow_ui(*(B),*(E))
  220. #define pow_di(B,E) dpow_ui(*(B),*(E))
  221. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  222. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  223. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  224. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  225. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  226. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  227. #define sig_die(s, kill) { exit(1); }
  228. #define s_stop(s, n) {exit(0);}
  229. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  230. #define z_abs(z) (cabs(Cd(z)))
  231. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  232. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  233. #define myexit_() break;
  234. #define mycycle() continue;
  235. #define myceiling(w) {ceil(w)}
  236. #define myhuge(w) {HUGE_VAL}
  237. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  238. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  239. /* procedure parameter types for -A and -C++ */
  240. #define F2C_proc_par_types 1
  241. #ifdef __cplusplus
  242. typedef logical (*L_fp)(...);
  243. #else
  244. typedef logical (*L_fp)();
  245. #endif
  246. static float spow_ui(float x, integer n) {
  247. float pow=1.0; unsigned long int u;
  248. if(n != 0) {
  249. if(n < 0) n = -n, x = 1/x;
  250. for(u = n; ; ) {
  251. if(u & 01) pow *= x;
  252. if(u >>= 1) x *= x;
  253. else break;
  254. }
  255. }
  256. return pow;
  257. }
  258. static double dpow_ui(double x, integer n) {
  259. double pow=1.0; unsigned long int u;
  260. if(n != 0) {
  261. if(n < 0) n = -n, x = 1/x;
  262. for(u = n; ; ) {
  263. if(u & 01) pow *= x;
  264. if(u >>= 1) x *= x;
  265. else break;
  266. }
  267. }
  268. return pow;
  269. }
  270. #ifdef _MSC_VER
  271. static _Fcomplex cpow_ui(complex x, integer n) {
  272. complex pow={1.0,0.0}; unsigned long int u;
  273. if(n != 0) {
  274. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  275. for(u = n; ; ) {
  276. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  277. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  278. else break;
  279. }
  280. }
  281. _Fcomplex p={pow.r, pow.i};
  282. return p;
  283. }
  284. #else
  285. static _Complex float cpow_ui(_Complex float x, integer n) {
  286. _Complex float pow=1.0; unsigned long int u;
  287. if(n != 0) {
  288. if(n < 0) n = -n, x = 1/x;
  289. for(u = n; ; ) {
  290. if(u & 01) pow *= x;
  291. if(u >>= 1) x *= x;
  292. else break;
  293. }
  294. }
  295. return pow;
  296. }
  297. #endif
  298. #ifdef _MSC_VER
  299. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  300. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  301. if(n != 0) {
  302. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  303. for(u = n; ; ) {
  304. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  305. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  306. else break;
  307. }
  308. }
  309. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  310. return p;
  311. }
  312. #else
  313. static _Complex double zpow_ui(_Complex double x, integer n) {
  314. _Complex double pow=1.0; unsigned long int u;
  315. if(n != 0) {
  316. if(n < 0) n = -n, x = 1/x;
  317. for(u = n; ; ) {
  318. if(u & 01) pow *= x;
  319. if(u >>= 1) x *= x;
  320. else break;
  321. }
  322. }
  323. return pow;
  324. }
  325. #endif
  326. static integer pow_ii(integer x, integer n) {
  327. integer pow; unsigned long int u;
  328. if (n <= 0) {
  329. if (n == 0 || x == 1) pow = 1;
  330. else if (x != -1) pow = x == 0 ? 1/x : 0;
  331. else n = -n;
  332. }
  333. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  334. u = n;
  335. for(pow = 1; ; ) {
  336. if(u & 01) pow *= x;
  337. if(u >>= 1) x *= x;
  338. else break;
  339. }
  340. }
  341. return pow;
  342. }
  343. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  344. {
  345. double m; integer i, mi;
  346. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  347. if (w[i-1]>m) mi=i ,m=w[i-1];
  348. return mi-s+1;
  349. }
  350. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  351. {
  352. float m; integer i, mi;
  353. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  354. if (w[i-1]>m) mi=i ,m=w[i-1];
  355. return mi-s+1;
  356. }
  357. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  358. integer n = *n_, incx = *incx_, incy = *incy_, i;
  359. #ifdef _MSC_VER
  360. _Fcomplex zdotc = {0.0, 0.0};
  361. if (incx == 1 && incy == 1) {
  362. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  363. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  364. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  365. }
  366. } else {
  367. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  368. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  369. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  370. }
  371. }
  372. pCf(z) = zdotc;
  373. }
  374. #else
  375. _Complex float zdotc = 0.0;
  376. if (incx == 1 && incy == 1) {
  377. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  378. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  379. }
  380. } else {
  381. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  382. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  383. }
  384. }
  385. pCf(z) = zdotc;
  386. }
  387. #endif
  388. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  389. integer n = *n_, incx = *incx_, incy = *incy_, i;
  390. #ifdef _MSC_VER
  391. _Dcomplex zdotc = {0.0, 0.0};
  392. if (incx == 1 && incy == 1) {
  393. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  394. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  395. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  396. }
  397. } else {
  398. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  399. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  400. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  401. }
  402. }
  403. pCd(z) = zdotc;
  404. }
  405. #else
  406. _Complex double zdotc = 0.0;
  407. if (incx == 1 && incy == 1) {
  408. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  409. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  410. }
  411. } else {
  412. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  413. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  414. }
  415. }
  416. pCd(z) = zdotc;
  417. }
  418. #endif
  419. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  420. integer n = *n_, incx = *incx_, incy = *incy_, i;
  421. #ifdef _MSC_VER
  422. _Fcomplex zdotc = {0.0, 0.0};
  423. if (incx == 1 && incy == 1) {
  424. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  425. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  426. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  427. }
  428. } else {
  429. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  430. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  431. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  432. }
  433. }
  434. pCf(z) = zdotc;
  435. }
  436. #else
  437. _Complex float zdotc = 0.0;
  438. if (incx == 1 && incy == 1) {
  439. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  440. zdotc += Cf(&x[i]) * Cf(&y[i]);
  441. }
  442. } else {
  443. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  444. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  445. }
  446. }
  447. pCf(z) = zdotc;
  448. }
  449. #endif
  450. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  451. integer n = *n_, incx = *incx_, incy = *incy_, i;
  452. #ifdef _MSC_VER
  453. _Dcomplex zdotc = {0.0, 0.0};
  454. if (incx == 1 && incy == 1) {
  455. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  456. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  457. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  458. }
  459. } else {
  460. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  461. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  462. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  463. }
  464. }
  465. pCd(z) = zdotc;
  466. }
  467. #else
  468. _Complex double zdotc = 0.0;
  469. if (incx == 1 && incy == 1) {
  470. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  471. zdotc += Cd(&x[i]) * Cd(&y[i]);
  472. }
  473. } else {
  474. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  475. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  476. }
  477. }
  478. pCd(z) = zdotc;
  479. }
  480. #endif
  481. /* -- translated by f2c (version 20000121).
  482. You must link the resulting object file with the libraries:
  483. -lf2c -lm (in that order)
  484. */
  485. /* Table of constant values */
  486. static doublereal c_b5 = 0.;
  487. static integer c__1 = 1;
  488. static integer c__2 = 2;
  489. /* > \brief \b DLARRV computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenv
  490. alues of L D LT. */
  491. /* =========== DOCUMENTATION =========== */
  492. /* Online html documentation available at */
  493. /* http://www.netlib.org/lapack/explore-html/ */
  494. /* > \htmlonly */
  495. /* > Download DLARRV + dependencies */
  496. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrv.
  497. f"> */
  498. /* > [TGZ]</a> */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrv.
  500. f"> */
  501. /* > [ZIP]</a> */
  502. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrv.
  503. f"> */
  504. /* > [TXT]</a> */
  505. /* > \endhtmlonly */
  506. /* Definition: */
  507. /* =========== */
  508. /* SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN, */
  509. /* ISPLIT, M, DOL, DOU, MINRGP, */
  510. /* RTOL1, RTOL2, W, WERR, WGAP, */
  511. /* IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ, */
  512. /* WORK, IWORK, INFO ) */
  513. /* INTEGER DOL, DOU, INFO, LDZ, M, N */
  514. /* DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU */
  515. /* INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ), */
  516. /* $ ISUPPZ( * ), IWORK( * ) */
  517. /* DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ), */
  518. /* $ WGAP( * ), WORK( * ) */
  519. /* DOUBLE PRECISION Z( LDZ, * ) */
  520. /* > \par Purpose: */
  521. /* ============= */
  522. /* > */
  523. /* > \verbatim */
  524. /* > */
  525. /* > DLARRV computes the eigenvectors of the tridiagonal matrix */
  526. /* > T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T. */
  527. /* > The input eigenvalues should have been computed by DLARRE. */
  528. /* > \endverbatim */
  529. /* Arguments: */
  530. /* ========== */
  531. /* > \param[in] N */
  532. /* > \verbatim */
  533. /* > N is INTEGER */
  534. /* > The order of the matrix. N >= 0. */
  535. /* > \endverbatim */
  536. /* > */
  537. /* > \param[in] VL */
  538. /* > \verbatim */
  539. /* > VL is DOUBLE PRECISION */
  540. /* > Lower bound of the interval that contains the desired */
  541. /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
  542. /* > end of the extremal eigenvalues in the desired RANGE. */
  543. /* > \endverbatim */
  544. /* > */
  545. /* > \param[in] VU */
  546. /* > \verbatim */
  547. /* > VU is DOUBLE PRECISION */
  548. /* > Upper bound of the interval that contains the desired */
  549. /* > eigenvalues. VL < VU. */
  550. /* > Note: VU is currently not used by this implementation of DLARRV, VU is */
  551. /* > passed to DLARRV because it could be used compute gaps on the right end */
  552. /* > of the extremal eigenvalues. However, with not much initial accuracy in */
  553. /* > LAMBDA and VU, the formula can lead to an overestimation of the right gap */
  554. /* > and thus to inadequately early RQI 'convergence'. This is currently */
  555. /* > prevented this by forcing a small right gap. And so it turns out that VU */
  556. /* > is currently not used by this implementation of DLARRV. */
  557. /* > \endverbatim */
  558. /* > */
  559. /* > \param[in,out] D */
  560. /* > \verbatim */
  561. /* > D is DOUBLE PRECISION array, dimension (N) */
  562. /* > On entry, the N diagonal elements of the diagonal matrix D. */
  563. /* > On exit, D may be overwritten. */
  564. /* > \endverbatim */
  565. /* > */
  566. /* > \param[in,out] L */
  567. /* > \verbatim */
  568. /* > L is DOUBLE PRECISION array, dimension (N) */
  569. /* > On entry, the (N-1) subdiagonal elements of the unit */
  570. /* > bidiagonal matrix L are in elements 1 to N-1 of L */
  571. /* > (if the matrix is not split.) At the end of each block */
  572. /* > is stored the corresponding shift as given by DLARRE. */
  573. /* > On exit, L is overwritten. */
  574. /* > \endverbatim */
  575. /* > */
  576. /* > \param[in] PIVMIN */
  577. /* > \verbatim */
  578. /* > PIVMIN is DOUBLE PRECISION */
  579. /* > The minimum pivot allowed in the Sturm sequence. */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[in] ISPLIT */
  583. /* > \verbatim */
  584. /* > ISPLIT is INTEGER array, dimension (N) */
  585. /* > The splitting points, at which T breaks up into blocks. */
  586. /* > The first block consists of rows/columns 1 to */
  587. /* > ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 */
  588. /* > through ISPLIT( 2 ), etc. */
  589. /* > \endverbatim */
  590. /* > */
  591. /* > \param[in] M */
  592. /* > \verbatim */
  593. /* > M is INTEGER */
  594. /* > The total number of input eigenvalues. 0 <= M <= N. */
  595. /* > \endverbatim */
  596. /* > */
  597. /* > \param[in] DOL */
  598. /* > \verbatim */
  599. /* > DOL is INTEGER */
  600. /* > \endverbatim */
  601. /* > */
  602. /* > \param[in] DOU */
  603. /* > \verbatim */
  604. /* > DOU is INTEGER */
  605. /* > If the user wants to compute only selected eigenvectors from all */
  606. /* > the eigenvalues supplied, he can specify an index range DOL:DOU. */
  607. /* > Or else the setting DOL=1, DOU=M should be applied. */
  608. /* > Note that DOL and DOU refer to the order in which the eigenvalues */
  609. /* > are stored in W. */
  610. /* > If the user wants to compute only selected eigenpairs, then */
  611. /* > the columns DOL-1 to DOU+1 of the eigenvector space Z contain the */
  612. /* > computed eigenvectors. All other columns of Z are set to zero. */
  613. /* > \endverbatim */
  614. /* > */
  615. /* > \param[in] MINRGP */
  616. /* > \verbatim */
  617. /* > MINRGP is DOUBLE PRECISION */
  618. /* > \endverbatim */
  619. /* > */
  620. /* > \param[in] RTOL1 */
  621. /* > \verbatim */
  622. /* > RTOL1 is DOUBLE PRECISION */
  623. /* > \endverbatim */
  624. /* > */
  625. /* > \param[in] RTOL2 */
  626. /* > \verbatim */
  627. /* > RTOL2 is DOUBLE PRECISION */
  628. /* > Parameters for bisection. */
  629. /* > An interval [LEFT,RIGHT] has converged if */
  630. /* > RIGHT-LEFT < MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */
  631. /* > \endverbatim */
  632. /* > */
  633. /* > \param[in,out] W */
  634. /* > \verbatim */
  635. /* > W is DOUBLE PRECISION array, dimension (N) */
  636. /* > The first M elements of W contain the APPROXIMATE eigenvalues for */
  637. /* > which eigenvectors are to be computed. The eigenvalues */
  638. /* > should be grouped by split-off block and ordered from */
  639. /* > smallest to largest within the block ( The output array */
  640. /* > W from DLARRE is expected here ). Furthermore, they are with */
  641. /* > respect to the shift of the corresponding root representation */
  642. /* > for their block. On exit, W holds the eigenvalues of the */
  643. /* > UNshifted matrix. */
  644. /* > \endverbatim */
  645. /* > */
  646. /* > \param[in,out] WERR */
  647. /* > \verbatim */
  648. /* > WERR is DOUBLE PRECISION array, dimension (N) */
  649. /* > The first M elements contain the semiwidth of the uncertainty */
  650. /* > interval of the corresponding eigenvalue in W */
  651. /* > \endverbatim */
  652. /* > */
  653. /* > \param[in,out] WGAP */
  654. /* > \verbatim */
  655. /* > WGAP is DOUBLE PRECISION array, dimension (N) */
  656. /* > The separation from the right neighbor eigenvalue in W. */
  657. /* > \endverbatim */
  658. /* > */
  659. /* > \param[in] IBLOCK */
  660. /* > \verbatim */
  661. /* > IBLOCK is INTEGER array, dimension (N) */
  662. /* > The indices of the blocks (submatrices) associated with the */
  663. /* > corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */
  664. /* > W(i) belongs to the first block from the top, =2 if W(i) */
  665. /* > belongs to the second block, etc. */
  666. /* > \endverbatim */
  667. /* > */
  668. /* > \param[in] INDEXW */
  669. /* > \verbatim */
  670. /* > INDEXW is INTEGER array, dimension (N) */
  671. /* > The indices of the eigenvalues within each block (submatrix); */
  672. /* > for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */
  673. /* > i-th eigenvalue W(i) is the 10-th eigenvalue in the second block. */
  674. /* > \endverbatim */
  675. /* > */
  676. /* > \param[in] GERS */
  677. /* > \verbatim */
  678. /* > GERS is DOUBLE PRECISION array, dimension (2*N) */
  679. /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
  680. /* > is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should */
  681. /* > be computed from the original UNshifted matrix. */
  682. /* > \endverbatim */
  683. /* > */
  684. /* > \param[out] Z */
  685. /* > \verbatim */
  686. /* > Z is DOUBLE PRECISION array, dimension (LDZ, f2cmax(1,M) ) */
  687. /* > If INFO = 0, the first M columns of Z contain the */
  688. /* > orthonormal eigenvectors of the matrix T */
  689. /* > corresponding to the input eigenvalues, with the i-th */
  690. /* > column of Z holding the eigenvector associated with W(i). */
  691. /* > Note: the user must ensure that at least f2cmax(1,M) columns are */
  692. /* > supplied in the array Z. */
  693. /* > \endverbatim */
  694. /* > */
  695. /* > \param[in] LDZ */
  696. /* > \verbatim */
  697. /* > LDZ is INTEGER */
  698. /* > The leading dimension of the array Z. LDZ >= 1, and if */
  699. /* > JOBZ = 'V', LDZ >= f2cmax(1,N). */
  700. /* > \endverbatim */
  701. /* > */
  702. /* > \param[out] ISUPPZ */
  703. /* > \verbatim */
  704. /* > ISUPPZ is INTEGER array, dimension ( 2*f2cmax(1,M) ) */
  705. /* > The support of the eigenvectors in Z, i.e., the indices */
  706. /* > indicating the nonzero elements in Z. The I-th eigenvector */
  707. /* > is nonzero only in elements ISUPPZ( 2*I-1 ) through */
  708. /* > ISUPPZ( 2*I ). */
  709. /* > \endverbatim */
  710. /* > */
  711. /* > \param[out] WORK */
  712. /* > \verbatim */
  713. /* > WORK is DOUBLE PRECISION array, dimension (12*N) */
  714. /* > \endverbatim */
  715. /* > */
  716. /* > \param[out] IWORK */
  717. /* > \verbatim */
  718. /* > IWORK is INTEGER array, dimension (7*N) */
  719. /* > \endverbatim */
  720. /* > */
  721. /* > \param[out] INFO */
  722. /* > \verbatim */
  723. /* > INFO is INTEGER */
  724. /* > = 0: successful exit */
  725. /* > */
  726. /* > > 0: A problem occurred in DLARRV. */
  727. /* > < 0: One of the called subroutines signaled an internal problem. */
  728. /* > Needs inspection of the corresponding parameter IINFO */
  729. /* > for further information. */
  730. /* > */
  731. /* > =-1: Problem in DLARRB when refining a child's eigenvalues. */
  732. /* > =-2: Problem in DLARRF when computing the RRR of a child. */
  733. /* > When a child is inside a tight cluster, it can be difficult */
  734. /* > to find an RRR. A partial remedy from the user's point of */
  735. /* > view is to make the parameter MINRGP smaller and recompile. */
  736. /* > However, as the orthogonality of the computed vectors is */
  737. /* > proportional to 1/MINRGP, the user should be aware that */
  738. /* > he might be trading in precision when he decreases MINRGP. */
  739. /* > =-3: Problem in DLARRB when refining a single eigenvalue */
  740. /* > after the Rayleigh correction was rejected. */
  741. /* > = 5: The Rayleigh Quotient Iteration failed to converge to */
  742. /* > full accuracy in MAXITR steps. */
  743. /* > \endverbatim */
  744. /* Authors: */
  745. /* ======== */
  746. /* > \author Univ. of Tennessee */
  747. /* > \author Univ. of California Berkeley */
  748. /* > \author Univ. of Colorado Denver */
  749. /* > \author NAG Ltd. */
  750. /* > \date June 2016 */
  751. /* > \ingroup doubleOTHERauxiliary */
  752. /* > \par Contributors: */
  753. /* ================== */
  754. /* > */
  755. /* > Beresford Parlett, University of California, Berkeley, USA \n */
  756. /* > Jim Demmel, University of California, Berkeley, USA \n */
  757. /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
  758. /* > Osni Marques, LBNL/NERSC, USA \n */
  759. /* > Christof Voemel, University of California, Berkeley, USA */
  760. /* ===================================================================== */
  761. /* Subroutine */ void dlarrv_(integer *n, doublereal *vl, doublereal *vu,
  762. doublereal *d__, doublereal *l, doublereal *pivmin, integer *isplit,
  763. integer *m, integer *dol, integer *dou, doublereal *minrgp,
  764. doublereal *rtol1, doublereal *rtol2, doublereal *w, doublereal *werr,
  765. doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers,
  766. doublereal *z__, integer *ldz, integer *isuppz, doublereal *work,
  767. integer *iwork, integer *info)
  768. {
  769. /* System generated locals */
  770. integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5;
  771. doublereal d__1, d__2;
  772. logical L__1;
  773. /* Local variables */
  774. integer iend, jblk;
  775. doublereal lgap;
  776. integer done;
  777. doublereal rgap, left;
  778. integer wend, iter;
  779. doublereal bstw;
  780. integer minwsize, itmp1, i__, j, k, p, q;
  781. extern /* Subroutine */ void dscal_(integer *, doublereal *, doublereal *,
  782. integer *);
  783. integer indld;
  784. doublereal fudge;
  785. integer idone;
  786. doublereal sigma;
  787. integer iinfo, iindr;
  788. doublereal resid;
  789. logical eskip;
  790. doublereal right;
  791. extern /* Subroutine */ void dcopy_(integer *, doublereal *, integer *,
  792. doublereal *, integer *);
  793. integer nclus, zfrom;
  794. doublereal rqtol;
  795. integer iindc1, iindc2;
  796. extern /* Subroutine */ void dlar1v_(integer *, integer *, integer *,
  797. doublereal *, doublereal *, doublereal *, doublereal *,
  798. doublereal *, doublereal *, doublereal *, doublereal *, logical *,
  799. integer *, doublereal *, doublereal *, integer *, integer *,
  800. doublereal *, doublereal *, doublereal *, doublereal *);
  801. integer miniwsize;
  802. logical stp2ii;
  803. doublereal lambda;
  804. integer ii;
  805. doublereal gl;
  806. integer im, in;
  807. extern doublereal dlamch_(char *);
  808. doublereal gu;
  809. integer ibegin, indeig;
  810. logical needbs;
  811. integer indlld;
  812. doublereal sgndef, mingma;
  813. extern /* Subroutine */ void dlarrb_(integer *, doublereal *, doublereal *,
  814. integer *, integer *, doublereal *, doublereal *, integer *,
  815. doublereal *, doublereal *, doublereal *, doublereal *, integer *,
  816. doublereal *, doublereal *, integer *, integer *);
  817. integer oldien, oldncl, wbegin, negcnt;
  818. doublereal spdiam;
  819. integer oldcls;
  820. doublereal savgap;
  821. integer ndepth;
  822. doublereal ssigma;
  823. extern /* Subroutine */ void dlarrf_(integer *, doublereal *, doublereal *,
  824. doublereal *, integer *, integer *, doublereal *, doublereal *,
  825. doublereal *, doublereal *, doublereal *, doublereal *,
  826. doublereal *, doublereal *, doublereal *, doublereal *,
  827. doublereal *, integer *);
  828. logical usedbs;
  829. integer iindwk, offset;
  830. doublereal gaptol;
  831. extern /* Subroutine */ void dlaset_(char *, integer *, integer *,
  832. doublereal *, doublereal *, doublereal *, integer *);
  833. integer newcls, oldfst, indwrk, windex, oldlst;
  834. logical usedrq;
  835. integer newfst, newftt, parity, windmn, windpl, isupmn, newlst, zusedl;
  836. doublereal bstres;
  837. integer newsiz, zusedu, zusedw;
  838. doublereal nrminv, rqcorr;
  839. logical tryrqc;
  840. integer isupmx;
  841. doublereal gap, eps, tau, tol, tmp;
  842. integer zto;
  843. doublereal ztz;
  844. /* -- LAPACK auxiliary routine (version 3.8.0) -- */
  845. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  846. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  847. /* June 2016 */
  848. /* ===================================================================== */
  849. /* Parameter adjustments */
  850. --d__;
  851. --l;
  852. --isplit;
  853. --w;
  854. --werr;
  855. --wgap;
  856. --iblock;
  857. --indexw;
  858. --gers;
  859. z_dim1 = *ldz;
  860. z_offset = 1 + z_dim1 * 1;
  861. z__ -= z_offset;
  862. --isuppz;
  863. --work;
  864. --iwork;
  865. /* Function Body */
  866. *info = 0;
  867. /* Quick return if possible */
  868. if (*n <= 0 || *m <= 0) {
  869. return;
  870. }
  871. /* The first N entries of WORK are reserved for the eigenvalues */
  872. indld = *n + 1;
  873. indlld = (*n << 1) + 1;
  874. indwrk = *n * 3 + 1;
  875. minwsize = *n * 12;
  876. i__1 = minwsize;
  877. for (i__ = 1; i__ <= i__1; ++i__) {
  878. work[i__] = 0.;
  879. /* L5: */
  880. }
  881. /* IWORK(IINDR+1:IINDR+N) hold the twist indices R for the */
  882. /* factorization used to compute the FP vector */
  883. iindr = 0;
  884. /* IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current */
  885. /* layer and the one above. */
  886. iindc1 = *n;
  887. iindc2 = *n << 1;
  888. iindwk = *n * 3 + 1;
  889. miniwsize = *n * 7;
  890. i__1 = miniwsize;
  891. for (i__ = 1; i__ <= i__1; ++i__) {
  892. iwork[i__] = 0;
  893. /* L10: */
  894. }
  895. zusedl = 1;
  896. if (*dol > 1) {
  897. /* Set lower bound for use of Z */
  898. zusedl = *dol - 1;
  899. }
  900. zusedu = *m;
  901. if (*dou < *m) {
  902. /* Set lower bound for use of Z */
  903. zusedu = *dou + 1;
  904. }
  905. /* The width of the part of Z that is used */
  906. zusedw = zusedu - zusedl + 1;
  907. dlaset_("Full", n, &zusedw, &c_b5, &c_b5, &z__[zusedl * z_dim1 + 1], ldz);
  908. eps = dlamch_("Precision");
  909. rqtol = eps * 2.;
  910. /* Set expert flags for standard code. */
  911. tryrqc = TRUE_;
  912. if (*dol == 1 && *dou == *m) {
  913. } else {
  914. /* Only selected eigenpairs are computed. Since the other evalues */
  915. /* are not refined by RQ iteration, bisection has to compute to full */
  916. /* accuracy. */
  917. *rtol1 = eps * 4.;
  918. *rtol2 = eps * 4.;
  919. }
  920. /* The entries WBEGIN:WEND in W, WERR, WGAP correspond to the */
  921. /* desired eigenvalues. The support of the nonzero eigenvector */
  922. /* entries is contained in the interval IBEGIN:IEND. */
  923. /* Remark that if k eigenpairs are desired, then the eigenvectors */
  924. /* are stored in k contiguous columns of Z. */
  925. /* DONE is the number of eigenvectors already computed */
  926. done = 0;
  927. ibegin = 1;
  928. wbegin = 1;
  929. i__1 = iblock[*m];
  930. for (jblk = 1; jblk <= i__1; ++jblk) {
  931. iend = isplit[jblk];
  932. sigma = l[iend];
  933. /* Find the eigenvectors of the submatrix indexed IBEGIN */
  934. /* through IEND. */
  935. wend = wbegin - 1;
  936. L15:
  937. if (wend < *m) {
  938. if (iblock[wend + 1] == jblk) {
  939. ++wend;
  940. goto L15;
  941. }
  942. }
  943. if (wend < wbegin) {
  944. ibegin = iend + 1;
  945. goto L170;
  946. } else if (wend < *dol || wbegin > *dou) {
  947. ibegin = iend + 1;
  948. wbegin = wend + 1;
  949. goto L170;
  950. }
  951. /* Find local spectral diameter of the block */
  952. gl = gers[(ibegin << 1) - 1];
  953. gu = gers[ibegin * 2];
  954. i__2 = iend;
  955. for (i__ = ibegin + 1; i__ <= i__2; ++i__) {
  956. /* Computing MIN */
  957. d__1 = gers[(i__ << 1) - 1];
  958. gl = f2cmin(d__1,gl);
  959. /* Computing MAX */
  960. d__1 = gers[i__ * 2];
  961. gu = f2cmax(d__1,gu);
  962. /* L20: */
  963. }
  964. spdiam = gu - gl;
  965. /* OLDIEN is the last index of the previous block */
  966. oldien = ibegin - 1;
  967. /* Calculate the size of the current block */
  968. in = iend - ibegin + 1;
  969. /* The number of eigenvalues in the current block */
  970. im = wend - wbegin + 1;
  971. /* This is for a 1x1 block */
  972. if (ibegin == iend) {
  973. ++done;
  974. z__[ibegin + wbegin * z_dim1] = 1.;
  975. isuppz[(wbegin << 1) - 1] = ibegin;
  976. isuppz[wbegin * 2] = ibegin;
  977. w[wbegin] += sigma;
  978. work[wbegin] = w[wbegin];
  979. ibegin = iend + 1;
  980. ++wbegin;
  981. goto L170;
  982. }
  983. /* The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND) */
  984. /* Note that these can be approximations, in this case, the corresp. */
  985. /* entries of WERR give the size of the uncertainty interval. */
  986. /* The eigenvalue approximations will be refined when necessary as */
  987. /* high relative accuracy is required for the computation of the */
  988. /* corresponding eigenvectors. */
  989. dcopy_(&im, &w[wbegin], &c__1, &work[wbegin], &c__1);
  990. /* We store in W the eigenvalue approximations w.r.t. the original */
  991. /* matrix T. */
  992. i__2 = im;
  993. for (i__ = 1; i__ <= i__2; ++i__) {
  994. w[wbegin + i__ - 1] += sigma;
  995. /* L30: */
  996. }
  997. /* NDEPTH is the current depth of the representation tree */
  998. ndepth = 0;
  999. /* PARITY is either 1 or 0 */
  1000. parity = 1;
  1001. /* NCLUS is the number of clusters for the next level of the */
  1002. /* representation tree, we start with NCLUS = 1 for the root */
  1003. nclus = 1;
  1004. iwork[iindc1 + 1] = 1;
  1005. iwork[iindc1 + 2] = im;
  1006. /* IDONE is the number of eigenvectors already computed in the current */
  1007. /* block */
  1008. idone = 0;
  1009. /* loop while( IDONE.LT.IM ) */
  1010. /* generate the representation tree for the current block and */
  1011. /* compute the eigenvectors */
  1012. L40:
  1013. if (idone < im) {
  1014. /* This is a crude protection against infinitely deep trees */
  1015. if (ndepth > *m) {
  1016. *info = -2;
  1017. return;
  1018. }
  1019. /* breadth first processing of the current level of the representation */
  1020. /* tree: OLDNCL = number of clusters on current level */
  1021. oldncl = nclus;
  1022. /* reset NCLUS to count the number of child clusters */
  1023. nclus = 0;
  1024. parity = 1 - parity;
  1025. if (parity == 0) {
  1026. oldcls = iindc1;
  1027. newcls = iindc2;
  1028. } else {
  1029. oldcls = iindc2;
  1030. newcls = iindc1;
  1031. }
  1032. /* Process the clusters on the current level */
  1033. i__2 = oldncl;
  1034. for (i__ = 1; i__ <= i__2; ++i__) {
  1035. j = oldcls + (i__ << 1);
  1036. /* OLDFST, OLDLST = first, last index of current cluster. */
  1037. /* cluster indices start with 1 and are relative */
  1038. /* to WBEGIN when accessing W, WGAP, WERR, Z */
  1039. oldfst = iwork[j - 1];
  1040. oldlst = iwork[j];
  1041. if (ndepth > 0) {
  1042. /* Retrieve relatively robust representation (RRR) of cluster */
  1043. /* that has been computed at the previous level */
  1044. /* The RRR is stored in Z and overwritten once the eigenvectors */
  1045. /* have been computed or when the cluster is refined */
  1046. if (*dol == 1 && *dou == *m) {
  1047. /* Get representation from location of the leftmost evalue */
  1048. /* of the cluster */
  1049. j = wbegin + oldfst - 1;
  1050. } else {
  1051. if (wbegin + oldfst - 1 < *dol) {
  1052. /* Get representation from the left end of Z array */
  1053. j = *dol - 1;
  1054. } else if (wbegin + oldfst - 1 > *dou) {
  1055. /* Get representation from the right end of Z array */
  1056. j = *dou;
  1057. } else {
  1058. j = wbegin + oldfst - 1;
  1059. }
  1060. }
  1061. dcopy_(&in, &z__[ibegin + j * z_dim1], &c__1, &d__[ibegin]
  1062. , &c__1);
  1063. i__3 = in - 1;
  1064. dcopy_(&i__3, &z__[ibegin + (j + 1) * z_dim1], &c__1, &l[
  1065. ibegin], &c__1);
  1066. sigma = z__[iend + (j + 1) * z_dim1];
  1067. /* Set the corresponding entries in Z to zero */
  1068. dlaset_("Full", &in, &c__2, &c_b5, &c_b5, &z__[ibegin + j
  1069. * z_dim1], ldz);
  1070. }
  1071. /* Compute DL and DLL of current RRR */
  1072. i__3 = iend - 1;
  1073. for (j = ibegin; j <= i__3; ++j) {
  1074. tmp = d__[j] * l[j];
  1075. work[indld - 1 + j] = tmp;
  1076. work[indlld - 1 + j] = tmp * l[j];
  1077. /* L50: */
  1078. }
  1079. if (ndepth > 0) {
  1080. /* P and Q are index of the first and last eigenvalue to compute */
  1081. /* within the current block */
  1082. p = indexw[wbegin - 1 + oldfst];
  1083. q = indexw[wbegin - 1 + oldlst];
  1084. /* Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET */
  1085. /* through the Q-OFFSET elements of these arrays are to be used. */
  1086. /* OFFSET = P-OLDFST */
  1087. offset = indexw[wbegin] - 1;
  1088. /* perform limited bisection (if necessary) to get approximate */
  1089. /* eigenvalues to the precision needed. */
  1090. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p,
  1091. &q, rtol1, rtol2, &offset, &work[wbegin], &wgap[
  1092. wbegin], &werr[wbegin], &work[indwrk], &iwork[
  1093. iindwk], pivmin, &spdiam, &in, &iinfo);
  1094. if (iinfo != 0) {
  1095. *info = -1;
  1096. return;
  1097. }
  1098. /* We also recompute the extremal gaps. W holds all eigenvalues */
  1099. /* of the unshifted matrix and must be used for computation */
  1100. /* of WGAP, the entries of WORK might stem from RRRs with */
  1101. /* different shifts. The gaps from WBEGIN-1+OLDFST to */
  1102. /* WBEGIN-1+OLDLST are correctly computed in DLARRB. */
  1103. /* However, we only allow the gaps to become greater since */
  1104. /* this is what should happen when we decrease WERR */
  1105. if (oldfst > 1) {
  1106. /* Computing MAX */
  1107. d__1 = wgap[wbegin + oldfst - 2], d__2 = w[wbegin +
  1108. oldfst - 1] - werr[wbegin + oldfst - 1] - w[
  1109. wbegin + oldfst - 2] - werr[wbegin + oldfst -
  1110. 2];
  1111. wgap[wbegin + oldfst - 2] = f2cmax(d__1,d__2);
  1112. }
  1113. if (wbegin + oldlst - 1 < wend) {
  1114. /* Computing MAX */
  1115. d__1 = wgap[wbegin + oldlst - 1], d__2 = w[wbegin +
  1116. oldlst] - werr[wbegin + oldlst] - w[wbegin +
  1117. oldlst - 1] - werr[wbegin + oldlst - 1];
  1118. wgap[wbegin + oldlst - 1] = f2cmax(d__1,d__2);
  1119. }
  1120. /* Each time the eigenvalues in WORK get refined, we store */
  1121. /* the newly found approximation with all shifts applied in W */
  1122. i__3 = oldlst;
  1123. for (j = oldfst; j <= i__3; ++j) {
  1124. w[wbegin + j - 1] = work[wbegin + j - 1] + sigma;
  1125. /* L53: */
  1126. }
  1127. }
  1128. /* Process the current node. */
  1129. newfst = oldfst;
  1130. i__3 = oldlst;
  1131. for (j = oldfst; j <= i__3; ++j) {
  1132. if (j == oldlst) {
  1133. /* we are at the right end of the cluster, this is also the */
  1134. /* boundary of the child cluster */
  1135. newlst = j;
  1136. } else if (wgap[wbegin + j - 1] >= *minrgp * (d__1 = work[
  1137. wbegin + j - 1], abs(d__1))) {
  1138. /* the right relative gap is big enough, the child cluster */
  1139. /* (NEWFST,..,NEWLST) is well separated from the following */
  1140. newlst = j;
  1141. } else {
  1142. /* inside a child cluster, the relative gap is not */
  1143. /* big enough. */
  1144. goto L140;
  1145. }
  1146. /* Compute size of child cluster found */
  1147. newsiz = newlst - newfst + 1;
  1148. /* NEWFTT is the place in Z where the new RRR or the computed */
  1149. /* eigenvector is to be stored */
  1150. if (*dol == 1 && *dou == *m) {
  1151. /* Store representation at location of the leftmost evalue */
  1152. /* of the cluster */
  1153. newftt = wbegin + newfst - 1;
  1154. } else {
  1155. if (wbegin + newfst - 1 < *dol) {
  1156. /* Store representation at the left end of Z array */
  1157. newftt = *dol - 1;
  1158. } else if (wbegin + newfst - 1 > *dou) {
  1159. /* Store representation at the right end of Z array */
  1160. newftt = *dou;
  1161. } else {
  1162. newftt = wbegin + newfst - 1;
  1163. }
  1164. }
  1165. if (newsiz > 1) {
  1166. /* Current child is not a singleton but a cluster. */
  1167. /* Compute and store new representation of child. */
  1168. /* Compute left and right cluster gap. */
  1169. /* LGAP and RGAP are not computed from WORK because */
  1170. /* the eigenvalue approximations may stem from RRRs */
  1171. /* different shifts. However, W hold all eigenvalues */
  1172. /* of the unshifted matrix. Still, the entries in WGAP */
  1173. /* have to be computed from WORK since the entries */
  1174. /* in W might be of the same order so that gaps are not */
  1175. /* exhibited correctly for very close eigenvalues. */
  1176. if (newfst == 1) {
  1177. /* Computing MAX */
  1178. d__1 = 0., d__2 = w[wbegin] - werr[wbegin] - *vl;
  1179. lgap = f2cmax(d__1,d__2);
  1180. } else {
  1181. lgap = wgap[wbegin + newfst - 2];
  1182. }
  1183. rgap = wgap[wbegin + newlst - 1];
  1184. /* Compute left- and rightmost eigenvalue of child */
  1185. /* to high precision in order to shift as close */
  1186. /* as possible and obtain as large relative gaps */
  1187. /* as possible */
  1188. for (k = 1; k <= 2; ++k) {
  1189. if (k == 1) {
  1190. p = indexw[wbegin - 1 + newfst];
  1191. } else {
  1192. p = indexw[wbegin - 1 + newlst];
  1193. }
  1194. offset = indexw[wbegin] - 1;
  1195. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
  1196. - 1], &p, &p, &rqtol, &rqtol, &offset, &
  1197. work[wbegin], &wgap[wbegin], &werr[wbegin]
  1198. , &work[indwrk], &iwork[iindwk], pivmin, &
  1199. spdiam, &in, &iinfo);
  1200. /* L55: */
  1201. }
  1202. if (wbegin + newlst - 1 < *dol || wbegin + newfst - 1
  1203. > *dou) {
  1204. /* if the cluster contains no desired eigenvalues */
  1205. /* skip the computation of that branch of the rep. tree */
  1206. /* We could skip before the refinement of the extremal */
  1207. /* eigenvalues of the child, but then the representation */
  1208. /* tree could be different from the one when nothing is */
  1209. /* skipped. For this reason we skip at this place. */
  1210. idone = idone + newlst - newfst + 1;
  1211. goto L139;
  1212. }
  1213. /* Compute RRR of child cluster. */
  1214. /* Note that the new RRR is stored in Z */
  1215. /* DLARRF needs LWORK = 2*N */
  1216. dlarrf_(&in, &d__[ibegin], &l[ibegin], &work[indld +
  1217. ibegin - 1], &newfst, &newlst, &work[wbegin],
  1218. &wgap[wbegin], &werr[wbegin], &spdiam, &lgap,
  1219. &rgap, pivmin, &tau, &z__[ibegin + newftt *
  1220. z_dim1], &z__[ibegin + (newftt + 1) * z_dim1],
  1221. &work[indwrk], &iinfo);
  1222. if (iinfo == 0) {
  1223. /* a new RRR for the cluster was found by DLARRF */
  1224. /* update shift and store it */
  1225. ssigma = sigma + tau;
  1226. z__[iend + (newftt + 1) * z_dim1] = ssigma;
  1227. /* WORK() are the midpoints and WERR() the semi-width */
  1228. /* Note that the entries in W are unchanged. */
  1229. i__4 = newlst;
  1230. for (k = newfst; k <= i__4; ++k) {
  1231. fudge = eps * 3. * (d__1 = work[wbegin + k -
  1232. 1], abs(d__1));
  1233. work[wbegin + k - 1] -= tau;
  1234. fudge += eps * 4. * (d__1 = work[wbegin + k -
  1235. 1], abs(d__1));
  1236. /* Fudge errors */
  1237. werr[wbegin + k - 1] += fudge;
  1238. /* Gaps are not fudged. Provided that WERR is small */
  1239. /* when eigenvalues are close, a zero gap indicates */
  1240. /* that a new representation is needed for resolving */
  1241. /* the cluster. A fudge could lead to a wrong decision */
  1242. /* of judging eigenvalues 'separated' which in */
  1243. /* reality are not. This could have a negative impact */
  1244. /* on the orthogonality of the computed eigenvectors. */
  1245. /* L116: */
  1246. }
  1247. ++nclus;
  1248. k = newcls + (nclus << 1);
  1249. iwork[k - 1] = newfst;
  1250. iwork[k] = newlst;
  1251. } else {
  1252. *info = -2;
  1253. return;
  1254. }
  1255. } else {
  1256. /* Compute eigenvector of singleton */
  1257. iter = 0;
  1258. tol = log((doublereal) in) * 4. * eps;
  1259. k = newfst;
  1260. windex = wbegin + k - 1;
  1261. /* Computing MAX */
  1262. i__4 = windex - 1;
  1263. windmn = f2cmax(i__4,1);
  1264. /* Computing MIN */
  1265. i__4 = windex + 1;
  1266. windpl = f2cmin(i__4,*m);
  1267. lambda = work[windex];
  1268. ++done;
  1269. /* Check if eigenvector computation is to be skipped */
  1270. if (windex < *dol || windex > *dou) {
  1271. eskip = TRUE_;
  1272. goto L125;
  1273. } else {
  1274. eskip = FALSE_;
  1275. }
  1276. left = work[windex] - werr[windex];
  1277. right = work[windex] + werr[windex];
  1278. indeig = indexw[windex];
  1279. /* Note that since we compute the eigenpairs for a child, */
  1280. /* all eigenvalue approximations are w.r.t the same shift. */
  1281. /* In this case, the entries in WORK should be used for */
  1282. /* computing the gaps since they exhibit even very small */
  1283. /* differences in the eigenvalues, as opposed to the */
  1284. /* entries in W which might "look" the same. */
  1285. if (k == 1) {
  1286. /* In the case RANGE='I' and with not much initial */
  1287. /* accuracy in LAMBDA and VL, the formula */
  1288. /* LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA ) */
  1289. /* can lead to an overestimation of the left gap and */
  1290. /* thus to inadequately early RQI 'convergence'. */
  1291. /* Prevent this by forcing a small left gap. */
  1292. /* Computing MAX */
  1293. d__1 = abs(left), d__2 = abs(right);
  1294. lgap = eps * f2cmax(d__1,d__2);
  1295. } else {
  1296. lgap = wgap[windmn];
  1297. }
  1298. if (k == im) {
  1299. /* In the case RANGE='I' and with not much initial */
  1300. /* accuracy in LAMBDA and VU, the formula */
  1301. /* can lead to an overestimation of the right gap and */
  1302. /* thus to inadequately early RQI 'convergence'. */
  1303. /* Prevent this by forcing a small right gap. */
  1304. /* Computing MAX */
  1305. d__1 = abs(left), d__2 = abs(right);
  1306. rgap = eps * f2cmax(d__1,d__2);
  1307. } else {
  1308. rgap = wgap[windex];
  1309. }
  1310. gap = f2cmin(lgap,rgap);
  1311. if (k == 1 || k == im) {
  1312. /* The eigenvector support can become wrong */
  1313. /* because significant entries could be cut off due to a */
  1314. /* large GAPTOL parameter in LAR1V. Prevent this. */
  1315. gaptol = 0.;
  1316. } else {
  1317. gaptol = gap * eps;
  1318. }
  1319. isupmn = in;
  1320. isupmx = 1;
  1321. /* Update WGAP so that it holds the minimum gap */
  1322. /* to the left or the right. This is crucial in the */
  1323. /* case where bisection is used to ensure that the */
  1324. /* eigenvalue is refined up to the required precision. */
  1325. /* The correct value is restored afterwards. */
  1326. savgap = wgap[windex];
  1327. wgap[windex] = gap;
  1328. /* We want to use the Rayleigh Quotient Correction */
  1329. /* as often as possible since it converges quadratically */
  1330. /* when we are close enough to the desired eigenvalue. */
  1331. /* However, the Rayleigh Quotient can have the wrong sign */
  1332. /* and lead us away from the desired eigenvalue. In this */
  1333. /* case, the best we can do is to use bisection. */
  1334. usedbs = FALSE_;
  1335. usedrq = FALSE_;
  1336. /* Bisection is initially turned off unless it is forced */
  1337. needbs = ! tryrqc;
  1338. L120:
  1339. /* Check if bisection should be used to refine eigenvalue */
  1340. if (needbs) {
  1341. /* Take the bisection as new iterate */
  1342. usedbs = TRUE_;
  1343. itmp1 = iwork[iindr + windex];
  1344. offset = indexw[wbegin] - 1;
  1345. d__1 = eps * 2.;
  1346. dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
  1347. - 1], &indeig, &indeig, &c_b5, &d__1, &
  1348. offset, &work[wbegin], &wgap[wbegin], &
  1349. werr[wbegin], &work[indwrk], &iwork[
  1350. iindwk], pivmin, &spdiam, &itmp1, &iinfo);
  1351. if (iinfo != 0) {
  1352. *info = -3;
  1353. return;
  1354. }
  1355. lambda = work[windex];
  1356. /* Reset twist index from inaccurate LAMBDA to */
  1357. /* force computation of true MINGMA */
  1358. iwork[iindr + windex] = 0;
  1359. }
  1360. /* Given LAMBDA, compute the eigenvector. */
  1361. L__1 = ! usedbs;
  1362. dlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], &l[
  1363. ibegin], &work[indld + ibegin - 1], &work[
  1364. indlld + ibegin - 1], pivmin, &gaptol, &z__[
  1365. ibegin + windex * z_dim1], &L__1, &negcnt, &
  1366. ztz, &mingma, &iwork[iindr + windex], &isuppz[
  1367. (windex << 1) - 1], &nrminv, &resid, &rqcorr,
  1368. &work[indwrk]);
  1369. if (iter == 0) {
  1370. bstres = resid;
  1371. bstw = lambda;
  1372. } else if (resid < bstres) {
  1373. bstres = resid;
  1374. bstw = lambda;
  1375. }
  1376. /* Computing MIN */
  1377. i__4 = isupmn, i__5 = isuppz[(windex << 1) - 1];
  1378. isupmn = f2cmin(i__4,i__5);
  1379. /* Computing MAX */
  1380. i__4 = isupmx, i__5 = isuppz[windex * 2];
  1381. isupmx = f2cmax(i__4,i__5);
  1382. ++iter;
  1383. /* sin alpha <= |resid|/gap */
  1384. /* Note that both the residual and the gap are */
  1385. /* proportional to the matrix, so ||T|| doesn't play */
  1386. /* a role in the quotient */
  1387. /* Convergence test for Rayleigh-Quotient iteration */
  1388. /* (omitted when Bisection has been used) */
  1389. if (resid > tol * gap && abs(rqcorr) > rqtol * abs(
  1390. lambda) && ! usedbs) {
  1391. /* We need to check that the RQCORR update doesn't */
  1392. /* move the eigenvalue away from the desired one and */
  1393. /* towards a neighbor. -> protection with bisection */
  1394. if (indeig <= negcnt) {
  1395. /* The wanted eigenvalue lies to the left */
  1396. sgndef = -1.;
  1397. } else {
  1398. /* The wanted eigenvalue lies to the right */
  1399. sgndef = 1.;
  1400. }
  1401. /* We only use the RQCORR if it improves the */
  1402. /* the iterate reasonably. */
  1403. if (rqcorr * sgndef >= 0. && lambda + rqcorr <=
  1404. right && lambda + rqcorr >= left) {
  1405. usedrq = TRUE_;
  1406. /* Store new midpoint of bisection interval in WORK */
  1407. if (sgndef == 1.) {
  1408. /* The current LAMBDA is on the left of the true */
  1409. /* eigenvalue */
  1410. left = lambda;
  1411. /* We prefer to assume that the error estimate */
  1412. /* is correct. We could make the interval not */
  1413. /* as a bracket but to be modified if the RQCORR */
  1414. /* chooses to. In this case, the RIGHT side should */
  1415. /* be modified as follows: */
  1416. /* RIGHT = MAX(RIGHT, LAMBDA + RQCORR) */
  1417. } else {
  1418. /* The current LAMBDA is on the right of the true */
  1419. /* eigenvalue */
  1420. right = lambda;
  1421. /* See comment about assuming the error estimate is */
  1422. /* correct above. */
  1423. /* LEFT = MIN(LEFT, LAMBDA + RQCORR) */
  1424. }
  1425. work[windex] = (right + left) * .5;
  1426. /* Take RQCORR since it has the correct sign and */
  1427. /* improves the iterate reasonably */
  1428. lambda += rqcorr;
  1429. /* Update width of error interval */
  1430. werr[windex] = (right - left) * .5;
  1431. } else {
  1432. needbs = TRUE_;
  1433. }
  1434. if (right - left < rqtol * abs(lambda)) {
  1435. /* The eigenvalue is computed to bisection accuracy */
  1436. /* compute eigenvector and stop */
  1437. usedbs = TRUE_;
  1438. goto L120;
  1439. } else if (iter < 10) {
  1440. goto L120;
  1441. } else if (iter == 10) {
  1442. needbs = TRUE_;
  1443. goto L120;
  1444. } else {
  1445. *info = 5;
  1446. return;
  1447. }
  1448. } else {
  1449. stp2ii = FALSE_;
  1450. if (usedrq && usedbs && bstres <= resid) {
  1451. lambda = bstw;
  1452. stp2ii = TRUE_;
  1453. }
  1454. if (stp2ii) {
  1455. /* improve error angle by second step */
  1456. L__1 = ! usedbs;
  1457. dlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin]
  1458. , &l[ibegin], &work[indld + ibegin -
  1459. 1], &work[indlld + ibegin - 1],
  1460. pivmin, &gaptol, &z__[ibegin + windex
  1461. * z_dim1], &L__1, &negcnt, &ztz, &
  1462. mingma, &iwork[iindr + windex], &
  1463. isuppz[(windex << 1) - 1], &nrminv, &
  1464. resid, &rqcorr, &work[indwrk]);
  1465. }
  1466. work[windex] = lambda;
  1467. }
  1468. /* Compute FP-vector support w.r.t. whole matrix */
  1469. isuppz[(windex << 1) - 1] += oldien;
  1470. isuppz[windex * 2] += oldien;
  1471. zfrom = isuppz[(windex << 1) - 1];
  1472. zto = isuppz[windex * 2];
  1473. isupmn += oldien;
  1474. isupmx += oldien;
  1475. /* Ensure vector is ok if support in the RQI has changed */
  1476. if (isupmn < zfrom) {
  1477. i__4 = zfrom - 1;
  1478. for (ii = isupmn; ii <= i__4; ++ii) {
  1479. z__[ii + windex * z_dim1] = 0.;
  1480. /* L122: */
  1481. }
  1482. }
  1483. if (isupmx > zto) {
  1484. i__4 = isupmx;
  1485. for (ii = zto + 1; ii <= i__4; ++ii) {
  1486. z__[ii + windex * z_dim1] = 0.;
  1487. /* L123: */
  1488. }
  1489. }
  1490. i__4 = zto - zfrom + 1;
  1491. dscal_(&i__4, &nrminv, &z__[zfrom + windex * z_dim1],
  1492. &c__1);
  1493. L125:
  1494. /* Update W */
  1495. w[windex] = lambda + sigma;
  1496. /* Recompute the gaps on the left and right */
  1497. /* But only allow them to become larger and not */
  1498. /* smaller (which can only happen through "bad" */
  1499. /* cancellation and doesn't reflect the theory */
  1500. /* where the initial gaps are underestimated due */
  1501. /* to WERR being too crude.) */
  1502. if (! eskip) {
  1503. if (k > 1) {
  1504. /* Computing MAX */
  1505. d__1 = wgap[windmn], d__2 = w[windex] - werr[
  1506. windex] - w[windmn] - werr[windmn];
  1507. wgap[windmn] = f2cmax(d__1,d__2);
  1508. }
  1509. if (windex < wend) {
  1510. /* Computing MAX */
  1511. d__1 = savgap, d__2 = w[windpl] - werr[windpl]
  1512. - w[windex] - werr[windex];
  1513. wgap[windex] = f2cmax(d__1,d__2);
  1514. }
  1515. }
  1516. ++idone;
  1517. }
  1518. /* here ends the code for the current child */
  1519. L139:
  1520. /* Proceed to any remaining child nodes */
  1521. newfst = j + 1;
  1522. L140:
  1523. ;
  1524. }
  1525. /* L150: */
  1526. }
  1527. ++ndepth;
  1528. goto L40;
  1529. }
  1530. ibegin = iend + 1;
  1531. wbegin = wend + 1;
  1532. L170:
  1533. ;
  1534. }
  1535. return;
  1536. /* End of DLARRV */
  1537. } /* dlarrv_ */