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.

sstebz.c 35 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  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 integer c__1 = 1;
  381. static integer c_n1 = -1;
  382. static integer c__3 = 3;
  383. static integer c__2 = 2;
  384. static integer c__0 = 0;
  385. /* > \brief \b SSTEBZ */
  386. /* =========== DOCUMENTATION =========== */
  387. /* Online html documentation available at */
  388. /* http://www.netlib.org/lapack/explore-html/ */
  389. /* > \htmlonly */
  390. /* > Download SSTEBZ + dependencies */
  391. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstebz.
  392. f"> */
  393. /* > [TGZ]</a> */
  394. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstebz.
  395. f"> */
  396. /* > [ZIP]</a> */
  397. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstebz.
  398. f"> */
  399. /* > [TXT]</a> */
  400. /* > \endhtmlonly */
  401. /* Definition: */
  402. /* =========== */
  403. /* SUBROUTINE SSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E, */
  404. /* M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK, */
  405. /* INFO ) */
  406. /* CHARACTER ORDER, RANGE */
  407. /* INTEGER IL, INFO, IU, M, N, NSPLIT */
  408. /* REAL ABSTOL, VL, VU */
  409. /* INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * ) */
  410. /* REAL D( * ), E( * ), W( * ), WORK( * ) */
  411. /* > \par Purpose: */
  412. /* ============= */
  413. /* > */
  414. /* > \verbatim */
  415. /* > */
  416. /* > SSTEBZ computes the eigenvalues of a symmetric tridiagonal */
  417. /* > matrix T. The user may ask for all eigenvalues, all eigenvalues */
  418. /* > in the half-open interval (VL, VU], or the IL-th through IU-th */
  419. /* > eigenvalues. */
  420. /* > */
  421. /* > To avoid overflow, the matrix must be scaled so that its */
  422. /* > largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value, and for greatest
  423. */
  424. /* > accuracy, it should not be much smaller than that. */
  425. /* > */
  426. /* > See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */
  427. /* > Matrix", Report CS41, Computer Science Dept., Stanford */
  428. /* > University, July 21, 1966. */
  429. /* > \endverbatim */
  430. /* Arguments: */
  431. /* ========== */
  432. /* > \param[in] RANGE */
  433. /* > \verbatim */
  434. /* > RANGE is CHARACTER*1 */
  435. /* > = 'A': ("All") all eigenvalues will be found. */
  436. /* > = 'V': ("Value") all eigenvalues in the half-open interval */
  437. /* > (VL, VU] will be found. */
  438. /* > = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */
  439. /* > entire matrix) will be found. */
  440. /* > \endverbatim */
  441. /* > */
  442. /* > \param[in] ORDER */
  443. /* > \verbatim */
  444. /* > ORDER is CHARACTER*1 */
  445. /* > = 'B': ("By Block") the eigenvalues will be grouped by */
  446. /* > split-off block (see IBLOCK, ISPLIT) and */
  447. /* > ordered from smallest to largest within */
  448. /* > the block. */
  449. /* > = 'E': ("Entire matrix") */
  450. /* > the eigenvalues for the entire matrix */
  451. /* > will be ordered from smallest to */
  452. /* > largest. */
  453. /* > \endverbatim */
  454. /* > */
  455. /* > \param[in] N */
  456. /* > \verbatim */
  457. /* > N is INTEGER */
  458. /* > The order of the tridiagonal matrix T. N >= 0. */
  459. /* > \endverbatim */
  460. /* > */
  461. /* > \param[in] VL */
  462. /* > \verbatim */
  463. /* > VL is REAL */
  464. /* > */
  465. /* > If RANGE='V', the lower bound of the interval to */
  466. /* > be searched for eigenvalues. Eigenvalues less than or equal */
  467. /* > to VL, or greater than VU, will not be returned. VL < VU. */
  468. /* > Not referenced if RANGE = 'A' or 'I'. */
  469. /* > \endverbatim */
  470. /* > */
  471. /* > \param[in] VU */
  472. /* > \verbatim */
  473. /* > VU is REAL */
  474. /* > */
  475. /* > If RANGE='V', the upper bound of the interval to */
  476. /* > be searched for eigenvalues. Eigenvalues less than or equal */
  477. /* > to VL, or greater than VU, will not be returned. VL < VU. */
  478. /* > Not referenced if RANGE = 'A' or 'I'. */
  479. /* > \endverbatim */
  480. /* > */
  481. /* > \param[in] IL */
  482. /* > \verbatim */
  483. /* > IL is INTEGER */
  484. /* > */
  485. /* > If RANGE='I', the index of the */
  486. /* > smallest eigenvalue to be returned. */
  487. /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
  488. /* > Not referenced if RANGE = 'A' or 'V'. */
  489. /* > \endverbatim */
  490. /* > */
  491. /* > \param[in] IU */
  492. /* > \verbatim */
  493. /* > IU is INTEGER */
  494. /* > */
  495. /* > If RANGE='I', the index of the */
  496. /* > largest eigenvalue to be returned. */
  497. /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
  498. /* > Not referenced if RANGE = 'A' or 'V'. */
  499. /* > \endverbatim */
  500. /* > */
  501. /* > \param[in] ABSTOL */
  502. /* > \verbatim */
  503. /* > ABSTOL is REAL */
  504. /* > The absolute tolerance for the eigenvalues. An eigenvalue */
  505. /* > (or cluster) is considered to be located if it has been */
  506. /* > determined to lie in an interval whose width is ABSTOL or */
  507. /* > less. If ABSTOL is less than or equal to zero, then ULP*|T| */
  508. /* > will be used, where |T| means the 1-norm of T. */
  509. /* > */
  510. /* > Eigenvalues will be computed most accurately when ABSTOL is */
  511. /* > set to twice the underflow threshold 2*SLAMCH('S'), not zero. */
  512. /* > \endverbatim */
  513. /* > */
  514. /* > \param[in] D */
  515. /* > \verbatim */
  516. /* > D is REAL array, dimension (N) */
  517. /* > The n diagonal elements of the tridiagonal matrix T. */
  518. /* > \endverbatim */
  519. /* > */
  520. /* > \param[in] E */
  521. /* > \verbatim */
  522. /* > E is REAL array, dimension (N-1) */
  523. /* > The (n-1) off-diagonal elements of the tridiagonal matrix T. */
  524. /* > \endverbatim */
  525. /* > */
  526. /* > \param[out] M */
  527. /* > \verbatim */
  528. /* > M is INTEGER */
  529. /* > The actual number of eigenvalues found. 0 <= M <= N. */
  530. /* > (See also the description of INFO=2,3.) */
  531. /* > \endverbatim */
  532. /* > */
  533. /* > \param[out] NSPLIT */
  534. /* > \verbatim */
  535. /* > NSPLIT is INTEGER */
  536. /* > The number of diagonal blocks in the matrix T. */
  537. /* > 1 <= NSPLIT <= N. */
  538. /* > \endverbatim */
  539. /* > */
  540. /* > \param[out] W */
  541. /* > \verbatim */
  542. /* > W is REAL array, dimension (N) */
  543. /* > On exit, the first M elements of W will contain the */
  544. /* > eigenvalues. (SSTEBZ may use the remaining N-M elements as */
  545. /* > workspace.) */
  546. /* > \endverbatim */
  547. /* > */
  548. /* > \param[out] IBLOCK */
  549. /* > \verbatim */
  550. /* > IBLOCK is INTEGER array, dimension (N) */
  551. /* > At each row/column j where E(j) is zero or small, the */
  552. /* > matrix T is considered to split into a block diagonal */
  553. /* > matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which */
  554. /* > block (from 1 to the number of blocks) the eigenvalue W(i) */
  555. /* > belongs. (SSTEBZ may use the remaining N-M elements as */
  556. /* > workspace.) */
  557. /* > \endverbatim */
  558. /* > */
  559. /* > \param[out] ISPLIT */
  560. /* > \verbatim */
  561. /* > ISPLIT is INTEGER array, dimension (N) */
  562. /* > The splitting points, at which T breaks up into submatrices. */
  563. /* > The first submatrix consists of rows/columns 1 to ISPLIT(1), */
  564. /* > the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */
  565. /* > etc., and the NSPLIT-th consists of rows/columns */
  566. /* > ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */
  567. /* > (Only the first NSPLIT elements will actually be used, but */
  568. /* > since the user cannot know a priori what value NSPLIT will */
  569. /* > have, N words must be reserved for ISPLIT.) */
  570. /* > \endverbatim */
  571. /* > */
  572. /* > \param[out] WORK */
  573. /* > \verbatim */
  574. /* > WORK is REAL array, dimension (4*N) */
  575. /* > \endverbatim */
  576. /* > */
  577. /* > \param[out] IWORK */
  578. /* > \verbatim */
  579. /* > IWORK is INTEGER array, dimension (3*N) */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[out] INFO */
  583. /* > \verbatim */
  584. /* > INFO is INTEGER */
  585. /* > = 0: successful exit */
  586. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  587. /* > > 0: some or all of the eigenvalues failed to converge or */
  588. /* > were not computed: */
  589. /* > =1 or 3: Bisection failed to converge for some */
  590. /* > eigenvalues; these eigenvalues are flagged by a */
  591. /* > negative block number. The effect is that the */
  592. /* > eigenvalues may not be as accurate as the */
  593. /* > absolute and relative tolerances. This is */
  594. /* > generally caused by unexpectedly inaccurate */
  595. /* > arithmetic. */
  596. /* > =2 or 3: RANGE='I' only: Not all of the eigenvalues */
  597. /* > IL:IU were found. */
  598. /* > Effect: M < IU+1-IL */
  599. /* > Cause: non-monotonic arithmetic, causing the */
  600. /* > Sturm sequence to be non-monotonic. */
  601. /* > Cure: recalculate, using RANGE='A', and pick */
  602. /* > out eigenvalues IL:IU. In some cases, */
  603. /* > increasing the PARAMETER "FUDGE" may */
  604. /* > make things work. */
  605. /* > = 4: RANGE='I', and the Gershgorin interval */
  606. /* > initially used was too small. No eigenvalues */
  607. /* > were computed. */
  608. /* > Probable cause: your machine has sloppy */
  609. /* > floating-point arithmetic. */
  610. /* > Cure: Increase the PARAMETER "FUDGE", */
  611. /* > recompile, and try again. */
  612. /* > \endverbatim */
  613. /* > \par Internal Parameters: */
  614. /* ========================= */
  615. /* > */
  616. /* > \verbatim */
  617. /* > RELFAC REAL, default = 2.0e0 */
  618. /* > The relative tolerance. An interval (a,b] lies within */
  619. /* > "relative tolerance" if b-a < RELFAC*ulp*f2cmax(|a|,|b|), */
  620. /* > where "ulp" is the machine precision (distance from 1 to */
  621. /* > the next larger floating point number.) */
  622. /* > */
  623. /* > FUDGE REAL, default = 2 */
  624. /* > A "fudge factor" to widen the Gershgorin intervals. Ideally, */
  625. /* > a value of 1 should work, but on machines with sloppy */
  626. /* > arithmetic, this needs to be larger. The default for */
  627. /* > publicly released versions should be large enough to handle */
  628. /* > the worst machine around. Note that this has no effect */
  629. /* > on accuracy of the solution. */
  630. /* > \endverbatim */
  631. /* Authors: */
  632. /* ======== */
  633. /* > \author Univ. of Tennessee */
  634. /* > \author Univ. of California Berkeley */
  635. /* > \author Univ. of Colorado Denver */
  636. /* > \author NAG Ltd. */
  637. /* > \date June 2016 */
  638. /* > \ingroup auxOTHERcomputational */
  639. /* ===================================================================== */
  640. /* Subroutine */ int sstebz_(char *range, char *order, integer *n, real *vl,
  641. real *vu, integer *il, integer *iu, real *abstol, real *d__, real *e,
  642. integer *m, integer *nsplit, real *w, integer *iblock, integer *
  643. isplit, real *work, integer *iwork, integer *info)
  644. {
  645. /* System generated locals */
  646. integer i__1, i__2, i__3;
  647. real r__1, r__2, r__3, r__4, r__5;
  648. /* Local variables */
  649. integer iend, ioff, iout, itmp1, j, jdisc;
  650. extern logical lsame_(char *, char *);
  651. integer iinfo;
  652. real atoli;
  653. integer iwoff;
  654. real bnorm;
  655. integer itmax;
  656. real wkill, rtoli, tnorm;
  657. integer ib, jb, ie, je, nb;
  658. real gl;
  659. integer im, in, ibegin;
  660. real gu;
  661. integer iw;
  662. real wl;
  663. integer irange, idiscl;
  664. extern real slamch_(char *);
  665. real safemn, wu;
  666. integer idumma[1];
  667. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  668. integer *, integer *, ftnlen, ftnlen);
  669. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  670. integer idiscu;
  671. extern /* Subroutine */ int slaebz_(integer *, integer *, integer *,
  672. integer *, integer *, integer *, real *, real *, real *, real *,
  673. real *, real *, integer *, real *, real *, integer *, integer *,
  674. real *, integer *, integer *);
  675. integer iorder;
  676. logical ncnvrg;
  677. real pivmin;
  678. logical toofew;
  679. integer nwl;
  680. real ulp, wlu, wul;
  681. integer nwu;
  682. real tmp1, tmp2;
  683. /* -- LAPACK computational routine (version 3.7.0) -- */
  684. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  685. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  686. /* June 2016 */
  687. /* ===================================================================== */
  688. /* Parameter adjustments */
  689. --iwork;
  690. --work;
  691. --isplit;
  692. --iblock;
  693. --w;
  694. --e;
  695. --d__;
  696. /* Function Body */
  697. *info = 0;
  698. /* Decode RANGE */
  699. if (lsame_(range, "A")) {
  700. irange = 1;
  701. } else if (lsame_(range, "V")) {
  702. irange = 2;
  703. } else if (lsame_(range, "I")) {
  704. irange = 3;
  705. } else {
  706. irange = 0;
  707. }
  708. /* Decode ORDER */
  709. if (lsame_(order, "B")) {
  710. iorder = 2;
  711. } else if (lsame_(order, "E")) {
  712. iorder = 1;
  713. } else {
  714. iorder = 0;
  715. }
  716. /* Check for Errors */
  717. if (irange <= 0) {
  718. *info = -1;
  719. } else if (iorder <= 0) {
  720. *info = -2;
  721. } else if (*n < 0) {
  722. *info = -3;
  723. } else if (irange == 2) {
  724. if (*vl >= *vu) {
  725. *info = -5;
  726. }
  727. } else if (irange == 3 && (*il < 1 || *il > f2cmax(1,*n))) {
  728. *info = -6;
  729. } else if (irange == 3 && (*iu < f2cmin(*n,*il) || *iu > *n)) {
  730. *info = -7;
  731. }
  732. if (*info != 0) {
  733. i__1 = -(*info);
  734. xerbla_("SSTEBZ", &i__1, (ftnlen)6);
  735. return 0;
  736. }
  737. /* Initialize error flags */
  738. *info = 0;
  739. ncnvrg = FALSE_;
  740. toofew = FALSE_;
  741. /* Quick return if possible */
  742. *m = 0;
  743. if (*n == 0) {
  744. return 0;
  745. }
  746. /* Simplifications: */
  747. if (irange == 3 && *il == 1 && *iu == *n) {
  748. irange = 1;
  749. }
  750. /* Get machine constants */
  751. /* NB is the minimum vector length for vector bisection, or 0 */
  752. /* if only scalar is to be done. */
  753. safemn = slamch_("S");
  754. ulp = slamch_("P");
  755. rtoli = ulp * 2.f;
  756. nb = ilaenv_(&c__1, "SSTEBZ", " ", n, &c_n1, &c_n1, &c_n1, (ftnlen)6, (
  757. ftnlen)1);
  758. if (nb <= 1) {
  759. nb = 0;
  760. }
  761. /* Special Case when N=1 */
  762. if (*n == 1) {
  763. *nsplit = 1;
  764. isplit[1] = 1;
  765. if (irange == 2 && (*vl >= d__[1] || *vu < d__[1])) {
  766. *m = 0;
  767. } else {
  768. w[1] = d__[1];
  769. iblock[1] = 1;
  770. *m = 1;
  771. }
  772. return 0;
  773. }
  774. /* Compute Splitting Points */
  775. *nsplit = 1;
  776. work[*n] = 0.f;
  777. pivmin = 1.f;
  778. i__1 = *n;
  779. for (j = 2; j <= i__1; ++j) {
  780. /* Computing 2nd power */
  781. r__1 = e[j - 1];
  782. tmp1 = r__1 * r__1;
  783. /* Computing 2nd power */
  784. r__2 = ulp;
  785. if ((r__1 = d__[j] * d__[j - 1], abs(r__1)) * (r__2 * r__2) + safemn
  786. > tmp1) {
  787. isplit[*nsplit] = j - 1;
  788. ++(*nsplit);
  789. work[j - 1] = 0.f;
  790. } else {
  791. work[j - 1] = tmp1;
  792. pivmin = f2cmax(pivmin,tmp1);
  793. }
  794. /* L10: */
  795. }
  796. isplit[*nsplit] = *n;
  797. pivmin *= safemn;
  798. /* Compute Interval and ATOLI */
  799. if (irange == 3) {
  800. /* RANGE='I': Compute the interval containing eigenvalues */
  801. /* IL through IU. */
  802. /* Compute Gershgorin interval for entire (split) matrix */
  803. /* and use it as the initial interval */
  804. gu = d__[1];
  805. gl = d__[1];
  806. tmp1 = 0.f;
  807. i__1 = *n - 1;
  808. for (j = 1; j <= i__1; ++j) {
  809. tmp2 = sqrt(work[j]);
  810. /* Computing MAX */
  811. r__1 = gu, r__2 = d__[j] + tmp1 + tmp2;
  812. gu = f2cmax(r__1,r__2);
  813. /* Computing MIN */
  814. r__1 = gl, r__2 = d__[j] - tmp1 - tmp2;
  815. gl = f2cmin(r__1,r__2);
  816. tmp1 = tmp2;
  817. /* L20: */
  818. }
  819. /* Computing MAX */
  820. r__1 = gu, r__2 = d__[*n] + tmp1;
  821. gu = f2cmax(r__1,r__2);
  822. /* Computing MIN */
  823. r__1 = gl, r__2 = d__[*n] - tmp1;
  824. gl = f2cmin(r__1,r__2);
  825. /* Computing MAX */
  826. r__1 = abs(gl), r__2 = abs(gu);
  827. tnorm = f2cmax(r__1,r__2);
  828. gl = gl - tnorm * 2.1f * ulp * *n - pivmin * 4.2000000000000002f;
  829. gu = gu + tnorm * 2.1f * ulp * *n + pivmin * 2.1f;
  830. /* Compute Iteration parameters */
  831. itmax = (integer) ((log(tnorm + pivmin) - log(pivmin)) / log(2.f)) +
  832. 2;
  833. if (*abstol <= 0.f) {
  834. atoli = ulp * tnorm;
  835. } else {
  836. atoli = *abstol;
  837. }
  838. work[*n + 1] = gl;
  839. work[*n + 2] = gl;
  840. work[*n + 3] = gu;
  841. work[*n + 4] = gu;
  842. work[*n + 5] = gl;
  843. work[*n + 6] = gu;
  844. iwork[1] = -1;
  845. iwork[2] = -1;
  846. iwork[3] = *n + 1;
  847. iwork[4] = *n + 1;
  848. iwork[5] = *il - 1;
  849. iwork[6] = *iu;
  850. slaebz_(&c__3, &itmax, n, &c__2, &c__2, &nb, &atoli, &rtoli, &pivmin,
  851. &d__[1], &e[1], &work[1], &iwork[5], &work[*n + 1], &work[*n
  852. + 5], &iout, &iwork[1], &w[1], &iblock[1], &iinfo);
  853. if (iwork[6] == *iu) {
  854. wl = work[*n + 1];
  855. wlu = work[*n + 3];
  856. nwl = iwork[1];
  857. wu = work[*n + 4];
  858. wul = work[*n + 2];
  859. nwu = iwork[4];
  860. } else {
  861. wl = work[*n + 2];
  862. wlu = work[*n + 4];
  863. nwl = iwork[2];
  864. wu = work[*n + 3];
  865. wul = work[*n + 1];
  866. nwu = iwork[3];
  867. }
  868. if (nwl < 0 || nwl >= *n || nwu < 1 || nwu > *n) {
  869. *info = 4;
  870. return 0;
  871. }
  872. } else {
  873. /* RANGE='A' or 'V' -- Set ATOLI */
  874. /* Computing MAX */
  875. r__3 = abs(d__[1]) + abs(e[1]), r__4 = (r__1 = d__[*n], abs(r__1)) + (
  876. r__2 = e[*n - 1], abs(r__2));
  877. tnorm = f2cmax(r__3,r__4);
  878. i__1 = *n - 1;
  879. for (j = 2; j <= i__1; ++j) {
  880. /* Computing MAX */
  881. r__4 = tnorm, r__5 = (r__1 = d__[j], abs(r__1)) + (r__2 = e[j - 1]
  882. , abs(r__2)) + (r__3 = e[j], abs(r__3));
  883. tnorm = f2cmax(r__4,r__5);
  884. /* L30: */
  885. }
  886. if (*abstol <= 0.f) {
  887. atoli = ulp * tnorm;
  888. } else {
  889. atoli = *abstol;
  890. }
  891. if (irange == 2) {
  892. wl = *vl;
  893. wu = *vu;
  894. } else {
  895. wl = 0.f;
  896. wu = 0.f;
  897. }
  898. }
  899. /* Find Eigenvalues -- Loop Over Blocks and recompute NWL and NWU. */
  900. /* NWL accumulates the number of eigenvalues .le. WL, */
  901. /* NWU accumulates the number of eigenvalues .le. WU */
  902. *m = 0;
  903. iend = 0;
  904. *info = 0;
  905. nwl = 0;
  906. nwu = 0;
  907. i__1 = *nsplit;
  908. for (jb = 1; jb <= i__1; ++jb) {
  909. ioff = iend;
  910. ibegin = ioff + 1;
  911. iend = isplit[jb];
  912. in = iend - ioff;
  913. if (in == 1) {
  914. /* Special Case -- IN=1 */
  915. if (irange == 1 || wl >= d__[ibegin] - pivmin) {
  916. ++nwl;
  917. }
  918. if (irange == 1 || wu >= d__[ibegin] - pivmin) {
  919. ++nwu;
  920. }
  921. if (irange == 1 || wl < d__[ibegin] - pivmin && wu >= d__[ibegin]
  922. - pivmin) {
  923. ++(*m);
  924. w[*m] = d__[ibegin];
  925. iblock[*m] = jb;
  926. }
  927. } else {
  928. /* General Case -- IN > 1 */
  929. /* Compute Gershgorin Interval */
  930. /* and use it as the initial interval */
  931. gu = d__[ibegin];
  932. gl = d__[ibegin];
  933. tmp1 = 0.f;
  934. i__2 = iend - 1;
  935. for (j = ibegin; j <= i__2; ++j) {
  936. tmp2 = (r__1 = e[j], abs(r__1));
  937. /* Computing MAX */
  938. r__1 = gu, r__2 = d__[j] + tmp1 + tmp2;
  939. gu = f2cmax(r__1,r__2);
  940. /* Computing MIN */
  941. r__1 = gl, r__2 = d__[j] - tmp1 - tmp2;
  942. gl = f2cmin(r__1,r__2);
  943. tmp1 = tmp2;
  944. /* L40: */
  945. }
  946. /* Computing MAX */
  947. r__1 = gu, r__2 = d__[iend] + tmp1;
  948. gu = f2cmax(r__1,r__2);
  949. /* Computing MIN */
  950. r__1 = gl, r__2 = d__[iend] - tmp1;
  951. gl = f2cmin(r__1,r__2);
  952. /* Computing MAX */
  953. r__1 = abs(gl), r__2 = abs(gu);
  954. bnorm = f2cmax(r__1,r__2);
  955. gl = gl - bnorm * 2.1f * ulp * in - pivmin * 2.1f;
  956. gu = gu + bnorm * 2.1f * ulp * in + pivmin * 2.1f;
  957. /* Compute ATOLI for the current submatrix */
  958. if (*abstol <= 0.f) {
  959. /* Computing MAX */
  960. r__1 = abs(gl), r__2 = abs(gu);
  961. atoli = ulp * f2cmax(r__1,r__2);
  962. } else {
  963. atoli = *abstol;
  964. }
  965. if (irange > 1) {
  966. if (gu < wl) {
  967. nwl += in;
  968. nwu += in;
  969. goto L70;
  970. }
  971. gl = f2cmax(gl,wl);
  972. gu = f2cmin(gu,wu);
  973. if (gl >= gu) {
  974. goto L70;
  975. }
  976. }
  977. /* Set Up Initial Interval */
  978. work[*n + 1] = gl;
  979. work[*n + in + 1] = gu;
  980. slaebz_(&c__1, &c__0, &in, &in, &c__1, &nb, &atoli, &rtoli, &
  981. pivmin, &d__[ibegin], &e[ibegin], &work[ibegin], idumma, &
  982. work[*n + 1], &work[*n + (in << 1) + 1], &im, &iwork[1], &
  983. w[*m + 1], &iblock[*m + 1], &iinfo);
  984. nwl += iwork[1];
  985. nwu += iwork[in + 1];
  986. iwoff = *m - iwork[1];
  987. /* Compute Eigenvalues */
  988. itmax = (integer) ((log(gu - gl + pivmin) - log(pivmin)) / log(
  989. 2.f)) + 2;
  990. slaebz_(&c__2, &itmax, &in, &in, &c__1, &nb, &atoli, &rtoli, &
  991. pivmin, &d__[ibegin], &e[ibegin], &work[ibegin], idumma, &
  992. work[*n + 1], &work[*n + (in << 1) + 1], &iout, &iwork[1],
  993. &w[*m + 1], &iblock[*m + 1], &iinfo);
  994. /* Copy Eigenvalues Into W and IBLOCK */
  995. /* Use -JB for block number for unconverged eigenvalues. */
  996. i__2 = iout;
  997. for (j = 1; j <= i__2; ++j) {
  998. tmp1 = (work[j + *n] + work[j + in + *n]) * .5f;
  999. /* Flag non-convergence. */
  1000. if (j > iout - iinfo) {
  1001. ncnvrg = TRUE_;
  1002. ib = -jb;
  1003. } else {
  1004. ib = jb;
  1005. }
  1006. i__3 = iwork[j + in] + iwoff;
  1007. for (je = iwork[j] + 1 + iwoff; je <= i__3; ++je) {
  1008. w[je] = tmp1;
  1009. iblock[je] = ib;
  1010. /* L50: */
  1011. }
  1012. /* L60: */
  1013. }
  1014. *m += im;
  1015. }
  1016. L70:
  1017. ;
  1018. }
  1019. /* If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU */
  1020. /* If NWL+1 < IL or NWU > IU, discard extra eigenvalues. */
  1021. if (irange == 3) {
  1022. im = 0;
  1023. idiscl = *il - 1 - nwl;
  1024. idiscu = nwu - *iu;
  1025. if (idiscl > 0 || idiscu > 0) {
  1026. i__1 = *m;
  1027. for (je = 1; je <= i__1; ++je) {
  1028. if (w[je] <= wlu && idiscl > 0) {
  1029. --idiscl;
  1030. } else if (w[je] >= wul && idiscu > 0) {
  1031. --idiscu;
  1032. } else {
  1033. ++im;
  1034. w[im] = w[je];
  1035. iblock[im] = iblock[je];
  1036. }
  1037. /* L80: */
  1038. }
  1039. *m = im;
  1040. }
  1041. if (idiscl > 0 || idiscu > 0) {
  1042. /* Code to deal with effects of bad arithmetic: */
  1043. /* Some low eigenvalues to be discarded are not in (WL,WLU], */
  1044. /* or high eigenvalues to be discarded are not in (WUL,WU] */
  1045. /* so just kill off the smallest IDISCL/largest IDISCU */
  1046. /* eigenvalues, by simply finding the smallest/largest */
  1047. /* eigenvalue(s). */
  1048. /* (If N(w) is monotone non-decreasing, this should never */
  1049. /* happen.) */
  1050. if (idiscl > 0) {
  1051. wkill = wu;
  1052. i__1 = idiscl;
  1053. for (jdisc = 1; jdisc <= i__1; ++jdisc) {
  1054. iw = 0;
  1055. i__2 = *m;
  1056. for (je = 1; je <= i__2; ++je) {
  1057. if (iblock[je] != 0 && (w[je] < wkill || iw == 0)) {
  1058. iw = je;
  1059. wkill = w[je];
  1060. }
  1061. /* L90: */
  1062. }
  1063. iblock[iw] = 0;
  1064. /* L100: */
  1065. }
  1066. }
  1067. if (idiscu > 0) {
  1068. wkill = wl;
  1069. i__1 = idiscu;
  1070. for (jdisc = 1; jdisc <= i__1; ++jdisc) {
  1071. iw = 0;
  1072. i__2 = *m;
  1073. for (je = 1; je <= i__2; ++je) {
  1074. if (iblock[je] != 0 && (w[je] > wkill || iw == 0)) {
  1075. iw = je;
  1076. wkill = w[je];
  1077. }
  1078. /* L110: */
  1079. }
  1080. iblock[iw] = 0;
  1081. /* L120: */
  1082. }
  1083. }
  1084. im = 0;
  1085. i__1 = *m;
  1086. for (je = 1; je <= i__1; ++je) {
  1087. if (iblock[je] != 0) {
  1088. ++im;
  1089. w[im] = w[je];
  1090. iblock[im] = iblock[je];
  1091. }
  1092. /* L130: */
  1093. }
  1094. *m = im;
  1095. }
  1096. if (idiscl < 0 || idiscu < 0) {
  1097. toofew = TRUE_;
  1098. }
  1099. }
  1100. /* If ORDER='B', do nothing -- the eigenvalues are already sorted */
  1101. /* by block. */
  1102. /* If ORDER='E', sort the eigenvalues from smallest to largest */
  1103. if (iorder == 1 && *nsplit > 1) {
  1104. i__1 = *m - 1;
  1105. for (je = 1; je <= i__1; ++je) {
  1106. ie = 0;
  1107. tmp1 = w[je];
  1108. i__2 = *m;
  1109. for (j = je + 1; j <= i__2; ++j) {
  1110. if (w[j] < tmp1) {
  1111. ie = j;
  1112. tmp1 = w[j];
  1113. }
  1114. /* L140: */
  1115. }
  1116. if (ie != 0) {
  1117. itmp1 = iblock[ie];
  1118. w[ie] = w[je];
  1119. iblock[ie] = iblock[je];
  1120. w[je] = tmp1;
  1121. iblock[je] = itmp1;
  1122. }
  1123. /* L150: */
  1124. }
  1125. }
  1126. *info = 0;
  1127. if (ncnvrg) {
  1128. ++(*info);
  1129. }
  1130. if (toofew) {
  1131. *info += 2;
  1132. }
  1133. return 0;
  1134. /* End of SSTEBZ */
  1135. } /* sstebz_ */