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