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.

slarrd.c 40 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  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. typedef int integer;
  18. typedef unsigned int uinteger;
  19. typedef char *address;
  20. typedef short int shortint;
  21. typedef float real;
  22. typedef double doublereal;
  23. typedef struct { real r, i; } complex;
  24. typedef struct { doublereal r, i; } doublecomplex;
  25. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  26. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  27. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  28. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  29. #define pCf(z) (*_pCf(z))
  30. #define pCd(z) (*_pCd(z))
  31. typedef int logical;
  32. typedef short int shortlogical;
  33. typedef char logical1;
  34. typedef char integer1;
  35. #define TRUE_ (1)
  36. #define FALSE_ (0)
  37. /* Extern is for use with -E */
  38. #ifndef Extern
  39. #define Extern extern
  40. #endif
  41. /* I/O stuff */
  42. typedef int flag;
  43. typedef int ftnlen;
  44. typedef int ftnint;
  45. /*external read, write*/
  46. typedef struct
  47. { flag cierr;
  48. ftnint ciunit;
  49. flag ciend;
  50. char *cifmt;
  51. ftnint cirec;
  52. } cilist;
  53. /*internal read, write*/
  54. typedef struct
  55. { flag icierr;
  56. char *iciunit;
  57. flag iciend;
  58. char *icifmt;
  59. ftnint icirlen;
  60. ftnint icirnum;
  61. } icilist;
  62. /*open*/
  63. typedef struct
  64. { flag oerr;
  65. ftnint ounit;
  66. char *ofnm;
  67. ftnlen ofnmlen;
  68. char *osta;
  69. char *oacc;
  70. char *ofm;
  71. ftnint orl;
  72. char *oblnk;
  73. } olist;
  74. /*close*/
  75. typedef struct
  76. { flag cerr;
  77. ftnint cunit;
  78. char *csta;
  79. } cllist;
  80. /*rewind, backspace, endfile*/
  81. typedef struct
  82. { flag aerr;
  83. ftnint aunit;
  84. } alist;
  85. /* inquire */
  86. typedef struct
  87. { flag inerr;
  88. ftnint inunit;
  89. char *infile;
  90. ftnlen infilen;
  91. ftnint *inex; /*parameters in standard's order*/
  92. ftnint *inopen;
  93. ftnint *innum;
  94. ftnint *innamed;
  95. char *inname;
  96. ftnlen innamlen;
  97. char *inacc;
  98. ftnlen inacclen;
  99. char *inseq;
  100. ftnlen inseqlen;
  101. char *indir;
  102. ftnlen indirlen;
  103. char *infmt;
  104. ftnlen infmtlen;
  105. char *inform;
  106. ftnint informlen;
  107. char *inunf;
  108. ftnlen inunflen;
  109. ftnint *inrecl;
  110. ftnint *innrec;
  111. char *inblank;
  112. ftnlen inblanklen;
  113. } inlist;
  114. #define VOID void
  115. union Multitype { /* for multiple entry points */
  116. integer1 g;
  117. shortint h;
  118. integer i;
  119. /* longint j; */
  120. real r;
  121. doublereal d;
  122. complex c;
  123. doublecomplex z;
  124. };
  125. typedef union Multitype Multitype;
  126. struct Vardesc { /* for Namelist */
  127. char *name;
  128. char *addr;
  129. ftnlen *dims;
  130. int type;
  131. };
  132. typedef struct Vardesc Vardesc;
  133. struct Namelist {
  134. char *name;
  135. Vardesc **vars;
  136. int nvars;
  137. };
  138. typedef struct Namelist Namelist;
  139. #define abs(x) ((x) >= 0 ? (x) : -(x))
  140. #define dabs(x) (fabs(x))
  141. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  142. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  143. #define dmin(a,b) (f2cmin(a,b))
  144. #define dmax(a,b) (f2cmax(a,b))
  145. #define bit_test(a,b) ((a) >> (b) & 1)
  146. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  147. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  148. #define abort_() { sig_die("Fortran abort routine called", 1); }
  149. #define c_abs(z) (cabsf(Cf(z)))
  150. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  151. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  152. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  153. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  154. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  155. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  156. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  157. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  158. #define d_abs(x) (fabs(*(x)))
  159. #define d_acos(x) (acos(*(x)))
  160. #define d_asin(x) (asin(*(x)))
  161. #define d_atan(x) (atan(*(x)))
  162. #define d_atn2(x, y) (atan2(*(x),*(y)))
  163. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  164. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  165. #define d_cos(x) (cos(*(x)))
  166. #define d_cosh(x) (cosh(*(x)))
  167. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  168. #define d_exp(x) (exp(*(x)))
  169. #define d_imag(z) (cimag(Cd(z)))
  170. #define r_imag(z) (cimag(Cf(z)))
  171. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  172. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  173. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  174. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  175. #define d_log(x) (log(*(x)))
  176. #define d_mod(x, y) (fmod(*(x), *(y)))
  177. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  178. #define d_nint(x) u_nint(*(x))
  179. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  180. #define d_sign(a,b) u_sign(*(a),*(b))
  181. #define r_sign(a,b) u_sign(*(a),*(b))
  182. #define d_sin(x) (sin(*(x)))
  183. #define d_sinh(x) (sinh(*(x)))
  184. #define d_sqrt(x) (sqrt(*(x)))
  185. #define d_tan(x) (tan(*(x)))
  186. #define d_tanh(x) (tanh(*(x)))
  187. #define i_abs(x) abs(*(x))
  188. #define i_dnnt(x) ((integer)u_nint(*(x)))
  189. #define i_len(s, n) (n)
  190. #define i_nint(x) ((integer)u_nint(*(x)))
  191. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  192. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  193. #define pow_si(B,E) spow_ui(*(B),*(E))
  194. #define pow_ri(B,E) spow_ui(*(B),*(E))
  195. #define pow_di(B,E) dpow_ui(*(B),*(E))
  196. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  197. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  198. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  199. #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++ = ' '; }
  200. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  201. #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]; }
  202. #define sig_die(s, kill) { exit(1); }
  203. #define s_stop(s, n) {exit(0);}
  204. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  205. #define z_abs(z) (cabs(Cd(z)))
  206. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  207. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  208. #define myexit_() break;
  209. #define mycycle() continue;
  210. #define myceiling(w) {ceil(w)}
  211. #define myhuge(w) {HUGE_VAL}
  212. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  213. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  214. /* procedure parameter types for -A and -C++ */
  215. #define F2C_proc_par_types 1
  216. #ifdef __cplusplus
  217. typedef logical (*L_fp)(...);
  218. #else
  219. typedef logical (*L_fp)();
  220. #endif
  221. static float spow_ui(float x, integer n) {
  222. float pow=1.0; unsigned long int u;
  223. if(n != 0) {
  224. if(n < 0) n = -n, x = 1/x;
  225. for(u = n; ; ) {
  226. if(u & 01) pow *= x;
  227. if(u >>= 1) x *= x;
  228. else break;
  229. }
  230. }
  231. return pow;
  232. }
  233. static double dpow_ui(double x, integer n) {
  234. double pow=1.0; unsigned long int u;
  235. if(n != 0) {
  236. if(n < 0) n = -n, x = 1/x;
  237. for(u = n; ; ) {
  238. if(u & 01) pow *= x;
  239. if(u >>= 1) x *= x;
  240. else break;
  241. }
  242. }
  243. return pow;
  244. }
  245. static _Complex float cpow_ui(_Complex float x, integer n) {
  246. _Complex float pow=1.0; unsigned long int u;
  247. if(n != 0) {
  248. if(n < 0) n = -n, x = 1/x;
  249. for(u = n; ; ) {
  250. if(u & 01) pow *= x;
  251. if(u >>= 1) x *= x;
  252. else break;
  253. }
  254. }
  255. return pow;
  256. }
  257. static _Complex double zpow_ui(_Complex double x, integer n) {
  258. _Complex double pow=1.0; unsigned long int u;
  259. if(n != 0) {
  260. if(n < 0) n = -n, x = 1/x;
  261. for(u = n; ; ) {
  262. if(u & 01) pow *= x;
  263. if(u >>= 1) x *= x;
  264. else break;
  265. }
  266. }
  267. return pow;
  268. }
  269. static integer pow_ii(integer x, integer n) {
  270. integer pow; unsigned long int u;
  271. if (n <= 0) {
  272. if (n == 0 || x == 1) pow = 1;
  273. else if (x != -1) pow = x == 0 ? 1/x : 0;
  274. else n = -n;
  275. }
  276. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  277. u = n;
  278. for(pow = 1; ; ) {
  279. if(u & 01) pow *= x;
  280. if(u >>= 1) x *= x;
  281. else break;
  282. }
  283. }
  284. return pow;
  285. }
  286. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  287. {
  288. double m; integer i, mi;
  289. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  290. if (w[i-1]>m) mi=i ,m=w[i-1];
  291. return mi-s+1;
  292. }
  293. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  294. {
  295. float m; integer i, mi;
  296. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  297. if (w[i-1]>m) mi=i ,m=w[i-1];
  298. return mi-s+1;
  299. }
  300. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  301. integer n = *n_, incx = *incx_, incy = *incy_, i;
  302. _Complex float zdotc = 0.0;
  303. if (incx == 1 && incy == 1) {
  304. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  305. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  306. }
  307. } else {
  308. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  309. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  310. }
  311. }
  312. pCf(z) = zdotc;
  313. }
  314. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  315. integer n = *n_, incx = *incx_, incy = *incy_, i;
  316. _Complex double zdotc = 0.0;
  317. if (incx == 1 && incy == 1) {
  318. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  319. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  320. }
  321. } else {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  324. }
  325. }
  326. pCd(z) = zdotc;
  327. }
  328. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  329. integer n = *n_, incx = *incx_, incy = *incy_, i;
  330. _Complex float zdotc = 0.0;
  331. if (incx == 1 && incy == 1) {
  332. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  333. zdotc += Cf(&x[i]) * Cf(&y[i]);
  334. }
  335. } else {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  338. }
  339. }
  340. pCf(z) = zdotc;
  341. }
  342. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  343. integer n = *n_, incx = *incx_, incy = *incy_, i;
  344. _Complex double zdotc = 0.0;
  345. if (incx == 1 && incy == 1) {
  346. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  347. zdotc += Cd(&x[i]) * Cd(&y[i]);
  348. }
  349. } else {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  352. }
  353. }
  354. pCd(z) = zdotc;
  355. }
  356. #endif
  357. /* -- translated by f2c (version 20000121).
  358. You must link the resulting object file with the libraries:
  359. -lf2c -lm (in that order)
  360. */
  361. /* Table of constant values */
  362. static integer c__1 = 1;
  363. static integer c_n1 = -1;
  364. static integer c__3 = 3;
  365. static integer c__2 = 2;
  366. static integer c__0 = 0;
  367. /* > \brief \b SLARRD computes the eigenvalues of a symmetric tridiagonal matrix to suitable accuracy. */
  368. /* =========== DOCUMENTATION =========== */
  369. /* Online html documentation available at */
  370. /* http://www.netlib.org/lapack/explore-html/ */
  371. /* > \htmlonly */
  372. /* > Download SLARRD + dependencies */
  373. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slarrd.
  374. f"> */
  375. /* > [TGZ]</a> */
  376. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slarrd.
  377. f"> */
  378. /* > [ZIP]</a> */
  379. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slarrd.
  380. f"> */
  381. /* > [TXT]</a> */
  382. /* > \endhtmlonly */
  383. /* Definition: */
  384. /* =========== */
  385. /* SUBROUTINE SLARRD( RANGE, ORDER, N, VL, VU, IL, IU, GERS, */
  386. /* RELTOL, D, E, E2, PIVMIN, NSPLIT, ISPLIT, */
  387. /* M, W, WERR, WL, WU, IBLOCK, INDEXW, */
  388. /* WORK, IWORK, INFO ) */
  389. /* CHARACTER ORDER, RANGE */
  390. /* INTEGER IL, INFO, IU, M, N, NSPLIT */
  391. /* REAL PIVMIN, RELTOL, VL, VU, WL, WU */
  392. /* INTEGER IBLOCK( * ), INDEXW( * ), */
  393. /* $ ISPLIT( * ), IWORK( * ) */
  394. /* REAL D( * ), E( * ), E2( * ), */
  395. /* $ GERS( * ), W( * ), WERR( * ), WORK( * ) */
  396. /* > \par Purpose: */
  397. /* ============= */
  398. /* > */
  399. /* > \verbatim */
  400. /* > */
  401. /* > SLARRD computes the eigenvalues of a symmetric tridiagonal */
  402. /* > matrix T to suitable accuracy. This is an auxiliary code to be */
  403. /* > called from SSTEMR. */
  404. /* > The user may ask for all eigenvalues, all eigenvalues */
  405. /* > in the half-open interval (VL, VU], or the IL-th through IU-th */
  406. /* > eigenvalues. */
  407. /* > */
  408. /* > To avoid overflow, the matrix must be scaled so that its */
  409. /* > largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value, and for greatest
  410. */
  411. /* > accuracy, it should not be much smaller than that. */
  412. /* > */
  413. /* > See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */
  414. /* > Matrix", Report CS41, Computer Science Dept., Stanford */
  415. /* > University, July 21, 1966. */
  416. /* > \endverbatim */
  417. /* Arguments: */
  418. /* ========== */
  419. /* > \param[in] RANGE */
  420. /* > \verbatim */
  421. /* > RANGE is CHARACTER*1 */
  422. /* > = 'A': ("All") all eigenvalues will be found. */
  423. /* > = 'V': ("Value") all eigenvalues in the half-open interval */
  424. /* > (VL, VU] will be found. */
  425. /* > = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */
  426. /* > entire matrix) will be found. */
  427. /* > \endverbatim */
  428. /* > */
  429. /* > \param[in] ORDER */
  430. /* > \verbatim */
  431. /* > ORDER is CHARACTER*1 */
  432. /* > = 'B': ("By Block") the eigenvalues will be grouped by */
  433. /* > split-off block (see IBLOCK, ISPLIT) and */
  434. /* > ordered from smallest to largest within */
  435. /* > the block. */
  436. /* > = 'E': ("Entire matrix") */
  437. /* > the eigenvalues for the entire matrix */
  438. /* > will be ordered from smallest to */
  439. /* > largest. */
  440. /* > \endverbatim */
  441. /* > */
  442. /* > \param[in] N */
  443. /* > \verbatim */
  444. /* > N is INTEGER */
  445. /* > The order of the tridiagonal matrix T. N >= 0. */
  446. /* > \endverbatim */
  447. /* > */
  448. /* > \param[in] VL */
  449. /* > \verbatim */
  450. /* > VL is REAL */
  451. /* > If RANGE='V', the lower bound of the interval to */
  452. /* > be searched for eigenvalues. Eigenvalues less than or equal */
  453. /* > to VL, or greater than VU, will not be returned. VL < VU. */
  454. /* > Not referenced if RANGE = 'A' or 'I'. */
  455. /* > \endverbatim */
  456. /* > */
  457. /* > \param[in] VU */
  458. /* > \verbatim */
  459. /* > VU is REAL */
  460. /* > If RANGE='V', the upper bound of the interval to */
  461. /* > be searched for eigenvalues. Eigenvalues less than or equal */
  462. /* > to VL, or greater than VU, will not be returned. VL < VU. */
  463. /* > Not referenced if RANGE = 'A' or 'I'. */
  464. /* > \endverbatim */
  465. /* > */
  466. /* > \param[in] IL */
  467. /* > \verbatim */
  468. /* > IL is INTEGER */
  469. /* > If RANGE='I', the index of the */
  470. /* > smallest eigenvalue to be returned. */
  471. /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
  472. /* > Not referenced if RANGE = 'A' or 'V'. */
  473. /* > \endverbatim */
  474. /* > */
  475. /* > \param[in] IU */
  476. /* > \verbatim */
  477. /* > IU is INTEGER */
  478. /* > If RANGE='I', the index of the */
  479. /* > largest eigenvalue to be returned. */
  480. /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
  481. /* > Not referenced if RANGE = 'A' or 'V'. */
  482. /* > \endverbatim */
  483. /* > */
  484. /* > \param[in] GERS */
  485. /* > \verbatim */
  486. /* > GERS is REAL array, dimension (2*N) */
  487. /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
  488. /* > is (GERS(2*i-1), GERS(2*i)). */
  489. /* > \endverbatim */
  490. /* > */
  491. /* > \param[in] RELTOL */
  492. /* > \verbatim */
  493. /* > RELTOL is REAL */
  494. /* > The minimum relative width of an interval. When an interval */
  495. /* > is narrower than RELTOL times the larger (in */
  496. /* > magnitude) endpoint, then it is considered to be */
  497. /* > sufficiently small, i.e., converged. Note: this should */
  498. /* > always be at least radix*machine epsilon. */
  499. /* > \endverbatim */
  500. /* > */
  501. /* > \param[in] D */
  502. /* > \verbatim */
  503. /* > D is REAL array, dimension (N) */
  504. /* > The n diagonal elements of the tridiagonal matrix T. */
  505. /* > \endverbatim */
  506. /* > */
  507. /* > \param[in] E */
  508. /* > \verbatim */
  509. /* > E is REAL array, dimension (N-1) */
  510. /* > The (n-1) off-diagonal elements of the tridiagonal matrix T. */
  511. /* > \endverbatim */
  512. /* > */
  513. /* > \param[in] E2 */
  514. /* > \verbatim */
  515. /* > E2 is REAL array, dimension (N-1) */
  516. /* > The (n-1) squared off-diagonal elements of the tridiagonal matrix T. */
  517. /* > \endverbatim */
  518. /* > */
  519. /* > \param[in] PIVMIN */
  520. /* > \verbatim */
  521. /* > PIVMIN is REAL */
  522. /* > The minimum pivot allowed in the Sturm sequence for T. */
  523. /* > \endverbatim */
  524. /* > */
  525. /* > \param[in] NSPLIT */
  526. /* > \verbatim */
  527. /* > NSPLIT is INTEGER */
  528. /* > The number of diagonal blocks in the matrix T. */
  529. /* > 1 <= NSPLIT <= N. */
  530. /* > \endverbatim */
  531. /* > */
  532. /* > \param[in] ISPLIT */
  533. /* > \verbatim */
  534. /* > ISPLIT is INTEGER array, dimension (N) */
  535. /* > The splitting points, at which T breaks up into submatrices. */
  536. /* > The first submatrix consists of rows/columns 1 to ISPLIT(1), */
  537. /* > the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */
  538. /* > etc., and the NSPLIT-th consists of rows/columns */
  539. /* > ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */
  540. /* > (Only the first NSPLIT elements will actually be used, but */
  541. /* > since the user cannot know a priori what value NSPLIT will */
  542. /* > have, N words must be reserved for ISPLIT.) */
  543. /* > \endverbatim */
  544. /* > */
  545. /* > \param[out] M */
  546. /* > \verbatim */
  547. /* > M is INTEGER */
  548. /* > The actual number of eigenvalues found. 0 <= M <= N. */
  549. /* > (See also the description of INFO=2,3.) */
  550. /* > \endverbatim */
  551. /* > */
  552. /* > \param[out] W */
  553. /* > \verbatim */
  554. /* > W is REAL array, dimension (N) */
  555. /* > On exit, the first M elements of W will contain the */
  556. /* > eigenvalue approximations. SLARRD computes an interval */
  557. /* > I_j = (a_j, b_j] that includes eigenvalue j. The eigenvalue */
  558. /* > approximation is given as the interval midpoint */
  559. /* > W(j)= ( a_j + b_j)/2. The corresponding error is bounded by */
  560. /* > WERR(j) = abs( a_j - b_j)/2 */
  561. /* > \endverbatim */
  562. /* > */
  563. /* > \param[out] WERR */
  564. /* > \verbatim */
  565. /* > WERR is REAL array, dimension (N) */
  566. /* > The error bound on the corresponding eigenvalue approximation */
  567. /* > in W. */
  568. /* > \endverbatim */
  569. /* > */
  570. /* > \param[out] WL */
  571. /* > \verbatim */
  572. /* > WL is REAL */
  573. /* > \endverbatim */
  574. /* > */
  575. /* > \param[out] WU */
  576. /* > \verbatim */
  577. /* > WU is REAL */
  578. /* > The interval (WL, WU] contains all the wanted eigenvalues. */
  579. /* > If RANGE='V', then WL=VL and WU=VU. */
  580. /* > If RANGE='A', then WL and WU are the global Gerschgorin bounds */
  581. /* > on the spectrum. */
  582. /* > If RANGE='I', then WL and WU are computed by SLAEBZ from the */
  583. /* > index range specified. */
  584. /* > \endverbatim */
  585. /* > */
  586. /* > \param[out] IBLOCK */
  587. /* > \verbatim */
  588. /* > IBLOCK is INTEGER array, dimension (N) */
  589. /* > At each row/column j where E(j) is zero or small, the */
  590. /* > matrix T is considered to split into a block diagonal */
  591. /* > matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which */
  592. /* > block (from 1 to the number of blocks) the eigenvalue W(i) */
  593. /* > belongs. (SLARRD may use the remaining N-M elements as */
  594. /* > workspace.) */
  595. /* > \endverbatim */
  596. /* > */
  597. /* > \param[out] INDEXW */
  598. /* > \verbatim */
  599. /* > INDEXW is INTEGER array, dimension (N) */
  600. /* > The indices of the eigenvalues within each block (submatrix); */
  601. /* > for example, INDEXW(i)= j and IBLOCK(i)=k imply that the */
  602. /* > i-th eigenvalue W(i) is the j-th eigenvalue in block k. */
  603. /* > \endverbatim */
  604. /* > */
  605. /* > \param[out] WORK */
  606. /* > \verbatim */
  607. /* > WORK is REAL array, dimension (4*N) */
  608. /* > \endverbatim */
  609. /* > */
  610. /* > \param[out] IWORK */
  611. /* > \verbatim */
  612. /* > IWORK is INTEGER array, dimension (3*N) */
  613. /* > \endverbatim */
  614. /* > */
  615. /* > \param[out] INFO */
  616. /* > \verbatim */
  617. /* > INFO is INTEGER */
  618. /* > = 0: successful exit */
  619. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  620. /* > > 0: some or all of the eigenvalues failed to converge or */
  621. /* > were not computed: */
  622. /* > =1 or 3: Bisection failed to converge for some */
  623. /* > eigenvalues; these eigenvalues are flagged by a */
  624. /* > negative block number. The effect is that the */
  625. /* > eigenvalues may not be as accurate as the */
  626. /* > absolute and relative tolerances. This is */
  627. /* > generally caused by unexpectedly inaccurate */
  628. /* > arithmetic. */
  629. /* > =2 or 3: RANGE='I' only: Not all of the eigenvalues */
  630. /* > IL:IU were found. */
  631. /* > Effect: M < IU+1-IL */
  632. /* > Cause: non-monotonic arithmetic, causing the */
  633. /* > Sturm sequence to be non-monotonic. */
  634. /* > Cure: recalculate, using RANGE='A', and pick */
  635. /* > out eigenvalues IL:IU. In some cases, */
  636. /* > increasing the PARAMETER "FUDGE" may */
  637. /* > make things work. */
  638. /* > = 4: RANGE='I', and the Gershgorin interval */
  639. /* > initially used was too small. No eigenvalues */
  640. /* > were computed. */
  641. /* > Probable cause: your machine has sloppy */
  642. /* > floating-point arithmetic. */
  643. /* > Cure: Increase the PARAMETER "FUDGE", */
  644. /* > recompile, and try again. */
  645. /* > \endverbatim */
  646. /* > \par Internal Parameters: */
  647. /* ========================= */
  648. /* > */
  649. /* > \verbatim */
  650. /* > FUDGE REAL, default = 2 */
  651. /* > A "fudge factor" to widen the Gershgorin intervals. Ideally, */
  652. /* > a value of 1 should work, but on machines with sloppy */
  653. /* > arithmetic, this needs to be larger. The default for */
  654. /* > publicly released versions should be large enough to handle */
  655. /* > the worst machine around. Note that this has no effect */
  656. /* > on accuracy of the solution. */
  657. /* > \endverbatim */
  658. /* > */
  659. /* > \par Contributors: */
  660. /* ================== */
  661. /* > */
  662. /* > W. Kahan, University of California, Berkeley, USA \n */
  663. /* > Beresford Parlett, University of California, Berkeley, USA \n */
  664. /* > Jim Demmel, University of California, Berkeley, USA \n */
  665. /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
  666. /* > Osni Marques, LBNL/NERSC, USA \n */
  667. /* > Christof Voemel, University of California, Berkeley, USA \n */
  668. /* Authors: */
  669. /* ======== */
  670. /* > \author Univ. of Tennessee */
  671. /* > \author Univ. of California Berkeley */
  672. /* > \author Univ. of Colorado Denver */
  673. /* > \author NAG Ltd. */
  674. /* > \date June 2016 */
  675. /* > \ingroup OTHERauxiliary */
  676. /* ===================================================================== */
  677. /* Subroutine */ int slarrd_(char *range, char *order, integer *n, real *vl,
  678. real *vu, integer *il, integer *iu, real *gers, real *reltol, real *
  679. d__, real *e, real *e2, real *pivmin, integer *nsplit, integer *
  680. isplit, integer *m, real *w, real *werr, real *wl, real *wu, integer *
  681. iblock, integer *indexw, real *work, integer *iwork, integer *info)
  682. {
  683. /* System generated locals */
  684. integer i__1, i__2, i__3;
  685. real r__1, r__2;
  686. /* Local variables */
  687. integer iend, jblk, ioff, iout, itmp1, itmp2, i__, j, jdisc;
  688. extern logical lsame_(char *, char *);
  689. integer iinfo;
  690. real atoli;
  691. integer iwoff, itmax;
  692. real wkill, rtoli, uflow, tnorm;
  693. integer ib, ie, je, nb;
  694. real gl;
  695. integer im, in;
  696. real gu;
  697. integer ibegin, iw, irange, idiscl;
  698. extern real slamch_(char *);
  699. integer idumma[1];
  700. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  701. integer *, integer *, ftnlen, ftnlen);
  702. integer idiscu;
  703. extern /* Subroutine */ int slaebz_(integer *, integer *, integer *,
  704. integer *, integer *, integer *, real *, real *, real *, real *,
  705. real *, real *, integer *, real *, real *, integer *, integer *,
  706. real *, integer *, integer *);
  707. logical ncnvrg, toofew;
  708. integer jee;
  709. real eps;
  710. integer nwl;
  711. real wlu, wul;
  712. integer nwu;
  713. real tmp1, tmp2;
  714. /* -- LAPACK auxiliary routine (version 3.7.1) -- */
  715. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  716. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  717. /* June 2016 */
  718. /* ===================================================================== */
  719. /* Parameter adjustments */
  720. --iwork;
  721. --work;
  722. --indexw;
  723. --iblock;
  724. --werr;
  725. --w;
  726. --isplit;
  727. --e2;
  728. --e;
  729. --d__;
  730. --gers;
  731. /* Function Body */
  732. *info = 0;
  733. /* Quick return if possible */
  734. if (*n <= 0) {
  735. return 0;
  736. }
  737. /* Decode RANGE */
  738. if (lsame_(range, "A")) {
  739. irange = 1;
  740. } else if (lsame_(range, "V")) {
  741. irange = 2;
  742. } else if (lsame_(range, "I")) {
  743. irange = 3;
  744. } else {
  745. irange = 0;
  746. }
  747. /* Check for Errors */
  748. if (irange <= 0) {
  749. *info = -1;
  750. } else if (! (lsame_(order, "B") || lsame_(order,
  751. "E"))) {
  752. *info = -2;
  753. } else if (*n < 0) {
  754. *info = -3;
  755. } else if (irange == 2) {
  756. if (*vl >= *vu) {
  757. *info = -5;
  758. }
  759. } else if (irange == 3 && (*il < 1 || *il > f2cmax(1,*n))) {
  760. *info = -6;
  761. } else if (irange == 3 && (*iu < f2cmin(*n,*il) || *iu > *n)) {
  762. *info = -7;
  763. }
  764. if (*info != 0) {
  765. return 0;
  766. }
  767. /* Initialize error flags */
  768. *info = 0;
  769. ncnvrg = FALSE_;
  770. toofew = FALSE_;
  771. /* Quick return if possible */
  772. *m = 0;
  773. if (*n == 0) {
  774. return 0;
  775. }
  776. /* Simplification: */
  777. if (irange == 3 && *il == 1 && *iu == *n) {
  778. irange = 1;
  779. }
  780. /* Get machine constants */
  781. eps = slamch_("P");
  782. uflow = slamch_("U");
  783. /* Special Case when N=1 */
  784. /* Treat case of 1x1 matrix for quick return */
  785. if (*n == 1) {
  786. if (irange == 1 || irange == 2 && d__[1] > *vl && d__[1] <= *vu ||
  787. irange == 3 && *il == 1 && *iu == 1) {
  788. *m = 1;
  789. w[1] = d__[1];
  790. /* The computation error of the eigenvalue is zero */
  791. werr[1] = 0.f;
  792. iblock[1] = 1;
  793. indexw[1] = 1;
  794. }
  795. return 0;
  796. }
  797. /* NB is the minimum vector length for vector bisection, or 0 */
  798. /* if only scalar is to be done. */
  799. nb = ilaenv_(&c__1, "SSTEBZ", " ", n, &c_n1, &c_n1, &c_n1, (ftnlen)6, (
  800. ftnlen)1);
  801. if (nb <= 1) {
  802. nb = 0;
  803. }
  804. /* Find global spectral radius */
  805. gl = d__[1];
  806. gu = d__[1];
  807. i__1 = *n;
  808. for (i__ = 1; i__ <= i__1; ++i__) {
  809. /* Computing MIN */
  810. r__1 = gl, r__2 = gers[(i__ << 1) - 1];
  811. gl = f2cmin(r__1,r__2);
  812. /* Computing MAX */
  813. r__1 = gu, r__2 = gers[i__ * 2];
  814. gu = f2cmax(r__1,r__2);
  815. /* L5: */
  816. }
  817. /* Compute global Gerschgorin bounds and spectral diameter */
  818. /* Computing MAX */
  819. r__1 = abs(gl), r__2 = abs(gu);
  820. tnorm = f2cmax(r__1,r__2);
  821. gl = gl - tnorm * 2.f * eps * *n - *pivmin * 4.f;
  822. gu = gu + tnorm * 2.f * eps * *n + *pivmin * 4.f;
  823. /* [JAN/28/2009] remove the line below since SPDIAM variable not use */
  824. /* SPDIAM = GU - GL */
  825. /* Input arguments for SLAEBZ: */
  826. /* The relative tolerance. An interval (a,b] lies within */
  827. /* "relative tolerance" if b-a < RELTOL*f2cmax(|a|,|b|), */
  828. rtoli = *reltol;
  829. /* Set the absolute tolerance for interval convergence to zero to force */
  830. /* interval convergence based on relative size of the interval. */
  831. /* This is dangerous because intervals might not converge when RELTOL is */
  832. /* small. But at least a very small number should be selected so that for */
  833. /* strongly graded matrices, the code can get relatively accurate */
  834. /* eigenvalues. */
  835. atoli = uflow * 4.f + *pivmin * 4.f;
  836. if (irange == 3) {
  837. /* RANGE='I': Compute an interval containing eigenvalues */
  838. /* IL through IU. The initial interval [GL,GU] from the global */
  839. /* Gerschgorin bounds GL and GU is refined by SLAEBZ. */
  840. itmax = (integer) ((log(tnorm + *pivmin) - log(*pivmin)) / log(2.f))
  841. + 2;
  842. work[*n + 1] = gl;
  843. work[*n + 2] = gl;
  844. work[*n + 3] = gu;
  845. work[*n + 4] = gu;
  846. work[*n + 5] = gl;
  847. work[*n + 6] = gu;
  848. iwork[1] = -1;
  849. iwork[2] = -1;
  850. iwork[3] = *n + 1;
  851. iwork[4] = *n + 1;
  852. iwork[5] = *il - 1;
  853. iwork[6] = *iu;
  854. slaebz_(&c__3, &itmax, n, &c__2, &c__2, &nb, &atoli, &rtoli, pivmin, &
  855. d__[1], &e[1], &e2[1], &iwork[5], &work[*n + 1], &work[*n + 5]
  856. , &iout, &iwork[1], &w[1], &iblock[1], &iinfo);
  857. if (iinfo != 0) {
  858. *info = iinfo;
  859. return 0;
  860. }
  861. /* On exit, output intervals may not be ordered by ascending negcount */
  862. if (iwork[6] == *iu) {
  863. *wl = work[*n + 1];
  864. wlu = work[*n + 3];
  865. nwl = iwork[1];
  866. *wu = work[*n + 4];
  867. wul = work[*n + 2];
  868. nwu = iwork[4];
  869. } else {
  870. *wl = work[*n + 2];
  871. wlu = work[*n + 4];
  872. nwl = iwork[2];
  873. *wu = work[*n + 3];
  874. wul = work[*n + 1];
  875. nwu = iwork[3];
  876. }
  877. /* On exit, the interval [WL, WLU] contains a value with negcount NWL, */
  878. /* and [WUL, WU] contains a value with negcount NWU. */
  879. if (nwl < 0 || nwl >= *n || nwu < 1 || nwu > *n) {
  880. *info = 4;
  881. return 0;
  882. }
  883. } else if (irange == 2) {
  884. *wl = *vl;
  885. *wu = *vu;
  886. } else if (irange == 1) {
  887. *wl = gl;
  888. *wu = gu;
  889. }
  890. /* Find Eigenvalues -- Loop Over blocks and recompute NWL and NWU. */
  891. /* NWL accumulates the number of eigenvalues .le. WL, */
  892. /* NWU accumulates the number of eigenvalues .le. WU */
  893. *m = 0;
  894. iend = 0;
  895. *info = 0;
  896. nwl = 0;
  897. nwu = 0;
  898. i__1 = *nsplit;
  899. for (jblk = 1; jblk <= i__1; ++jblk) {
  900. ioff = iend;
  901. ibegin = ioff + 1;
  902. iend = isplit[jblk];
  903. in = iend - ioff;
  904. if (in == 1) {
  905. /* 1x1 block */
  906. if (*wl >= d__[ibegin] - *pivmin) {
  907. ++nwl;
  908. }
  909. if (*wu >= d__[ibegin] - *pivmin) {
  910. ++nwu;
  911. }
  912. if (irange == 1 || *wl < d__[ibegin] - *pivmin && *wu >= d__[
  913. ibegin] - *pivmin) {
  914. ++(*m);
  915. w[*m] = d__[ibegin];
  916. werr[*m] = 0.f;
  917. /* The gap for a single block doesn't matter for the later */
  918. /* algorithm and is assigned an arbitrary large value */
  919. iblock[*m] = jblk;
  920. indexw[*m] = 1;
  921. }
  922. /* Disabled 2x2 case because of a failure on the following matrix */
  923. /* RANGE = 'I', IL = IU = 4 */
  924. /* Original Tridiagonal, d = [ */
  925. /* -0.150102010615740E+00 */
  926. /* -0.849897989384260E+00 */
  927. /* -0.128208148052635E-15 */
  928. /* 0.128257718286320E-15 */
  929. /* ]; */
  930. /* e = [ */
  931. /* -0.357171383266986E+00 */
  932. /* -0.180411241501588E-15 */
  933. /* -0.175152352710251E-15 */
  934. /* ]; */
  935. /* ELSE IF( IN.EQ.2 ) THEN */
  936. /* * 2x2 block */
  937. /* DISC = SQRT( (HALF*(D(IBEGIN)-D(IEND)))**2 + E(IBEGIN)**2 ) */
  938. /* TMP1 = HALF*(D(IBEGIN)+D(IEND)) */
  939. /* L1 = TMP1 - DISC */
  940. /* IF( WL.GE. L1-PIVMIN ) */
  941. /* $ NWL = NWL + 1 */
  942. /* IF( WU.GE. L1-PIVMIN ) */
  943. /* $ NWU = NWU + 1 */
  944. /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L1-PIVMIN .AND. WU.GE. */
  945. /* $ L1-PIVMIN ) ) THEN */
  946. /* M = M + 1 */
  947. /* W( M ) = L1 */
  948. /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */
  949. /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */
  950. /* IBLOCK( M ) = JBLK */
  951. /* INDEXW( M ) = 1 */
  952. /* ENDIF */
  953. /* L2 = TMP1 + DISC */
  954. /* IF( WL.GE. L2-PIVMIN ) */
  955. /* $ NWL = NWL + 1 */
  956. /* IF( WU.GE. L2-PIVMIN ) */
  957. /* $ NWU = NWU + 1 */
  958. /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L2-PIVMIN .AND. WU.GE. */
  959. /* $ L2-PIVMIN ) ) THEN */
  960. /* M = M + 1 */
  961. /* W( M ) = L2 */
  962. /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */
  963. /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */
  964. /* IBLOCK( M ) = JBLK */
  965. /* INDEXW( M ) = 2 */
  966. /* ENDIF */
  967. } else {
  968. /* General Case - block of size IN >= 2 */
  969. /* Compute local Gerschgorin interval and use it as the initial */
  970. /* interval for SLAEBZ */
  971. gu = d__[ibegin];
  972. gl = d__[ibegin];
  973. tmp1 = 0.f;
  974. i__2 = iend;
  975. for (j = ibegin; j <= i__2; ++j) {
  976. /* Computing MIN */
  977. r__1 = gl, r__2 = gers[(j << 1) - 1];
  978. gl = f2cmin(r__1,r__2);
  979. /* Computing MAX */
  980. r__1 = gu, r__2 = gers[j * 2];
  981. gu = f2cmax(r__1,r__2);
  982. /* L40: */
  983. }
  984. /* [JAN/28/2009] */
  985. /* change SPDIAM by TNORM in lines 2 and 3 thereafter */
  986. /* line 1: remove computation of SPDIAM (not useful anymore) */
  987. /* SPDIAM = GU - GL */
  988. /* GL = GL - FUDGE*SPDIAM*EPS*IN - FUDGE*PIVMIN */
  989. /* GU = GU + FUDGE*SPDIAM*EPS*IN + FUDGE*PIVMIN */
  990. gl = gl - tnorm * 2.f * eps * in - *pivmin * 2.f;
  991. gu = gu + tnorm * 2.f * eps * in + *pivmin * 2.f;
  992. if (irange > 1) {
  993. if (gu < *wl) {
  994. /* the local block contains none of the wanted eigenvalues */
  995. nwl += in;
  996. nwu += in;
  997. goto L70;
  998. }
  999. /* refine search interval if possible, only range (WL,WU] matters */
  1000. gl = f2cmax(gl,*wl);
  1001. gu = f2cmin(gu,*wu);
  1002. if (gl >= gu) {
  1003. goto L70;
  1004. }
  1005. }
  1006. /* Find negcount of initial interval boundaries GL and GU */
  1007. work[*n + 1] = gl;
  1008. work[*n + in + 1] = gu;
  1009. slaebz_(&c__1, &c__0, &in, &in, &c__1, &nb, &atoli, &rtoli,
  1010. pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, &
  1011. work[*n + 1], &work[*n + (in << 1) + 1], &im, &iwork[1], &
  1012. w[*m + 1], &iblock[*m + 1], &iinfo);
  1013. if (iinfo != 0) {
  1014. *info = iinfo;
  1015. return 0;
  1016. }
  1017. nwl += iwork[1];
  1018. nwu += iwork[in + 1];
  1019. iwoff = *m - iwork[1];
  1020. /* Compute Eigenvalues */
  1021. itmax = (integer) ((log(gu - gl + *pivmin) - log(*pivmin)) / log(
  1022. 2.f)) + 2;
  1023. slaebz_(&c__2, &itmax, &in, &in, &c__1, &nb, &atoli, &rtoli,
  1024. pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, &
  1025. work[*n + 1], &work[*n + (in << 1) + 1], &iout, &iwork[1],
  1026. &w[*m + 1], &iblock[*m + 1], &iinfo);
  1027. if (iinfo != 0) {
  1028. *info = iinfo;
  1029. return 0;
  1030. }
  1031. /* Copy eigenvalues into W and IBLOCK */
  1032. /* Use -JBLK for block number for unconverged eigenvalues. */
  1033. /* Loop over the number of output intervals from SLAEBZ */
  1034. i__2 = iout;
  1035. for (j = 1; j <= i__2; ++j) {
  1036. /* eigenvalue approximation is middle point of interval */
  1037. tmp1 = (work[j + *n] + work[j + in + *n]) * .5f;
  1038. /* semi length of error interval */
  1039. tmp2 = (r__1 = work[j + *n] - work[j + in + *n], abs(r__1)) *
  1040. .5f;
  1041. if (j > iout - iinfo) {
  1042. /* Flag non-convergence. */
  1043. ncnvrg = TRUE_;
  1044. ib = -jblk;
  1045. } else {
  1046. ib = jblk;
  1047. }
  1048. i__3 = iwork[j + in] + iwoff;
  1049. for (je = iwork[j] + 1 + iwoff; je <= i__3; ++je) {
  1050. w[je] = tmp1;
  1051. werr[je] = tmp2;
  1052. indexw[je] = je - iwoff;
  1053. iblock[je] = ib;
  1054. /* L50: */
  1055. }
  1056. /* L60: */
  1057. }
  1058. *m += im;
  1059. }
  1060. L70:
  1061. ;
  1062. }
  1063. /* If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU */
  1064. /* If NWL+1 < IL or NWU > IU, discard extra eigenvalues. */
  1065. if (irange == 3) {
  1066. idiscl = *il - 1 - nwl;
  1067. idiscu = nwu - *iu;
  1068. if (idiscl > 0) {
  1069. im = 0;
  1070. i__1 = *m;
  1071. for (je = 1; je <= i__1; ++je) {
  1072. /* Remove some of the smallest eigenvalues from the left so that */
  1073. /* at the end IDISCL =0. Move all eigenvalues up to the left. */
  1074. if (w[je] <= wlu && idiscl > 0) {
  1075. --idiscl;
  1076. } else {
  1077. ++im;
  1078. w[im] = w[je];
  1079. werr[im] = werr[je];
  1080. indexw[im] = indexw[je];
  1081. iblock[im] = iblock[je];
  1082. }
  1083. /* L80: */
  1084. }
  1085. *m = im;
  1086. }
  1087. if (idiscu > 0) {
  1088. /* Remove some of the largest eigenvalues from the right so that */
  1089. /* at the end IDISCU =0. Move all eigenvalues up to the left. */
  1090. im = *m + 1;
  1091. for (je = *m; je >= 1; --je) {
  1092. if (w[je] >= wul && idiscu > 0) {
  1093. --idiscu;
  1094. } else {
  1095. --im;
  1096. w[im] = w[je];
  1097. werr[im] = werr[je];
  1098. indexw[im] = indexw[je];
  1099. iblock[im] = iblock[je];
  1100. }
  1101. /* L81: */
  1102. }
  1103. jee = 0;
  1104. i__1 = *m;
  1105. for (je = im; je <= i__1; ++je) {
  1106. ++jee;
  1107. w[jee] = w[je];
  1108. werr[jee] = werr[je];
  1109. indexw[jee] = indexw[je];
  1110. iblock[jee] = iblock[je];
  1111. /* L82: */
  1112. }
  1113. *m = *m - im + 1;
  1114. }
  1115. if (idiscl > 0 || idiscu > 0) {
  1116. /* Code to deal with effects of bad arithmetic. (If N(w) is */
  1117. /* monotone non-decreasing, this should never happen.) */
  1118. /* Some low eigenvalues to be discarded are not in (WL,WLU], */
  1119. /* or high eigenvalues to be discarded are not in (WUL,WU] */
  1120. /* so just kill off the smallest IDISCL/largest IDISCU */
  1121. /* eigenvalues, by marking the corresponding IBLOCK = 0 */
  1122. if (idiscl > 0) {
  1123. wkill = *wu;
  1124. i__1 = idiscl;
  1125. for (jdisc = 1; jdisc <= i__1; ++jdisc) {
  1126. iw = 0;
  1127. i__2 = *m;
  1128. for (je = 1; je <= i__2; ++je) {
  1129. if (iblock[je] != 0 && (w[je] < wkill || iw == 0)) {
  1130. iw = je;
  1131. wkill = w[je];
  1132. }
  1133. /* L90: */
  1134. }
  1135. iblock[iw] = 0;
  1136. /* L100: */
  1137. }
  1138. }
  1139. if (idiscu > 0) {
  1140. wkill = *wl;
  1141. i__1 = idiscu;
  1142. for (jdisc = 1; jdisc <= i__1; ++jdisc) {
  1143. iw = 0;
  1144. i__2 = *m;
  1145. for (je = 1; je <= i__2; ++je) {
  1146. if (iblock[je] != 0 && (w[je] >= wkill || iw == 0)) {
  1147. iw = je;
  1148. wkill = w[je];
  1149. }
  1150. /* L110: */
  1151. }
  1152. iblock[iw] = 0;
  1153. /* L120: */
  1154. }
  1155. }
  1156. /* Now erase all eigenvalues with IBLOCK set to zero */
  1157. im = 0;
  1158. i__1 = *m;
  1159. for (je = 1; je <= i__1; ++je) {
  1160. if (iblock[je] != 0) {
  1161. ++im;
  1162. w[im] = w[je];
  1163. werr[im] = werr[je];
  1164. indexw[im] = indexw[je];
  1165. iblock[im] = iblock[je];
  1166. }
  1167. /* L130: */
  1168. }
  1169. *m = im;
  1170. }
  1171. if (idiscl < 0 || idiscu < 0) {
  1172. toofew = TRUE_;
  1173. }
  1174. }
  1175. if (irange == 1 && *m != *n || irange == 3 && *m != *iu - *il + 1) {
  1176. toofew = TRUE_;
  1177. }
  1178. /* If ORDER='B', do nothing the eigenvalues are already sorted by */
  1179. /* block. */
  1180. /* If ORDER='E', sort the eigenvalues from smallest to largest */
  1181. if (lsame_(order, "E") && *nsplit > 1) {
  1182. i__1 = *m - 1;
  1183. for (je = 1; je <= i__1; ++je) {
  1184. ie = 0;
  1185. tmp1 = w[je];
  1186. i__2 = *m;
  1187. for (j = je + 1; j <= i__2; ++j) {
  1188. if (w[j] < tmp1) {
  1189. ie = j;
  1190. tmp1 = w[j];
  1191. }
  1192. /* L140: */
  1193. }
  1194. if (ie != 0) {
  1195. tmp2 = werr[ie];
  1196. itmp1 = iblock[ie];
  1197. itmp2 = indexw[ie];
  1198. w[ie] = w[je];
  1199. werr[ie] = werr[je];
  1200. iblock[ie] = iblock[je];
  1201. indexw[ie] = indexw[je];
  1202. w[je] = tmp1;
  1203. werr[je] = tmp2;
  1204. iblock[je] = itmp1;
  1205. indexw[je] = itmp2;
  1206. }
  1207. /* L150: */
  1208. }
  1209. }
  1210. *info = 0;
  1211. if (ncnvrg) {
  1212. ++(*info);
  1213. }
  1214. if (toofew) {
  1215. *info += 2;
  1216. }
  1217. return 0;
  1218. /* End of SLARRD */
  1219. } /* slarrd_ */