You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zlarrv.c 53 kB

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