14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #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++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #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]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* > \brief \b DLARRB provides limited bisection to locate eigenvalues for more accuracy. */
515 /* =========== DOCUMENTATION =========== */
517 /* Online html documentation available at */
518 /* http://www.netlib.org/lapack/explore-html/ */
521 /* > Download DLARRB + dependencies */
522 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrb.
525 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrb.
528 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrb.
536 /* SUBROUTINE DLARRB( N, D, LLD, IFIRST, ILAST, RTOL1, */
537 /* RTOL2, OFFSET, W, WGAP, WERR, WORK, IWORK, */
538 /* PIVMIN, SPDIAM, TWIST, INFO ) */
540 /* INTEGER IFIRST, ILAST, INFO, N, OFFSET, TWIST */
541 /* DOUBLE PRECISION PIVMIN, RTOL1, RTOL2, SPDIAM */
542 /* INTEGER IWORK( * ) */
543 /* DOUBLE PRECISION D( * ), LLD( * ), W( * ), */
544 /* $ WERR( * ), WGAP( * ), WORK( * ) */
547 /* > \par Purpose: */
552 /* > Given the relatively robust representation(RRR) L D L^T, DLARRB */
553 /* > does "limited" bisection to refine the eigenvalues of L D L^T, */
554 /* > W( IFIRST-OFFSET ) through W( ILAST-OFFSET ), to more accuracy. Initial */
555 /* > guesses for these eigenvalues are input in W, the corresponding estimate */
556 /* > of the error in these guesses and their gaps are input in WERR */
557 /* > and WGAP, respectively. During bisection, intervals */
558 /* > [left, right] are maintained by storing their mid-points and */
559 /* > semi-widths in the arrays W and WERR respectively. */
568 /* > The order of the matrix. */
573 /* > D is DOUBLE PRECISION array, dimension (N) */
574 /* > The N diagonal elements of the diagonal matrix D. */
577 /* > \param[in] LLD */
579 /* > LLD is DOUBLE PRECISION array, dimension (N-1) */
580 /* > The (N-1) elements L(i)*L(i)*D(i). */
583 /* > \param[in] IFIRST */
585 /* > IFIRST is INTEGER */
586 /* > The index of the first eigenvalue to be computed. */
589 /* > \param[in] ILAST */
591 /* > ILAST is INTEGER */
592 /* > The index of the last eigenvalue to be computed. */
595 /* > \param[in] RTOL1 */
597 /* > RTOL1 is DOUBLE PRECISION */
600 /* > \param[in] RTOL2 */
602 /* > RTOL2 is DOUBLE PRECISION */
603 /* > Tolerance for the convergence of the bisection intervals. */
604 /* > An interval [LEFT,RIGHT] has converged if */
605 /* > RIGHT-LEFT < MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */
606 /* > where GAP is the (estimated) distance to the nearest */
610 /* > \param[in] OFFSET */
612 /* > OFFSET is INTEGER */
613 /* > Offset for the arrays W, WGAP and WERR, i.e., the IFIRST-OFFSET */
614 /* > through ILAST-OFFSET elements of these arrays are to be used. */
617 /* > \param[in,out] W */
619 /* > W is DOUBLE PRECISION array, dimension (N) */
620 /* > On input, W( IFIRST-OFFSET ) through W( ILAST-OFFSET ) are */
621 /* > estimates of the eigenvalues of L D L^T indexed IFIRST through */
623 /* > On output, these estimates are refined. */
626 /* > \param[in,out] WGAP */
628 /* > WGAP is DOUBLE PRECISION array, dimension (N-1) */
629 /* > On input, the (estimated) gaps between consecutive */
630 /* > eigenvalues of L D L^T, i.e., WGAP(I-OFFSET) is the gap between */
631 /* > eigenvalues I and I+1. Note that if IFIRST = ILAST */
632 /* > then WGAP(IFIRST-OFFSET) must be set to ZERO. */
633 /* > On output, these gaps are refined. */
636 /* > \param[in,out] WERR */
638 /* > WERR is DOUBLE PRECISION array, dimension (N) */
639 /* > On input, WERR( IFIRST-OFFSET ) through WERR( ILAST-OFFSET ) are */
640 /* > the errors in the estimates of the corresponding elements in W. */
641 /* > On output, these errors are refined. */
644 /* > \param[out] WORK */
646 /* > WORK is DOUBLE PRECISION array, dimension (2*N) */
650 /* > \param[out] IWORK */
652 /* > IWORK is INTEGER array, dimension (2*N) */
656 /* > \param[in] PIVMIN */
658 /* > PIVMIN is DOUBLE PRECISION */
659 /* > The minimum pivot in the Sturm sequence. */
662 /* > \param[in] SPDIAM */
664 /* > SPDIAM is DOUBLE PRECISION */
665 /* > The spectral diameter of the matrix. */
668 /* > \param[in] TWIST */
670 /* > TWIST is INTEGER */
671 /* > The twist index for the twisted factorization that is used */
672 /* > for the negcount. */
673 /* > TWIST = N: Compute negcount from L D L^T - LAMBDA I = L+ D+ L+^T */
674 /* > TWIST = 1: Compute negcount from L D L^T - LAMBDA I = U- D- U-^T */
675 /* > TWIST = R: Compute negcount from L D L^T - LAMBDA I = N(r) D(r) N(r) */
678 /* > \param[out] INFO */
680 /* > INFO is INTEGER */
687 /* > \author Univ. of Tennessee */
688 /* > \author Univ. of California Berkeley */
689 /* > \author Univ. of Colorado Denver */
690 /* > \author NAG Ltd. */
692 /* > \date June 2017 */
694 /* > \ingroup OTHERauxiliary */
696 /* > \par Contributors: */
697 /* ================== */
699 /* > Beresford Parlett, University of California, Berkeley, USA \n */
700 /* > Jim Demmel, University of California, Berkeley, USA \n */
701 /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
702 /* > Osni Marques, LBNL/NERSC, USA \n */
703 /* > Christof Voemel, University of California, Berkeley, USA */
705 /* ===================================================================== */
706 /* Subroutine */ int dlarrb_(integer *n, doublereal *d__, doublereal *lld,
707 integer *ifirst, integer *ilast, doublereal *rtol1, doublereal *rtol2,
708 integer *offset, doublereal *w, doublereal *wgap, doublereal *werr,
709 doublereal *work, integer *iwork, doublereal *pivmin, doublereal *
710 spdiam, integer *twist, integer *info)
712 /* System generated locals */
714 doublereal d__1, d__2;
716 /* Local variables */
717 doublereal back, lgap, rgap, left;
718 integer iter, nint, prev, next, i__, k, r__;
719 doublereal cvrgd, right, width;
721 extern integer dlaneg_(integer *, doublereal *, doublereal *, doublereal *
722 , doublereal *, integer *);
725 integer olnint, maxitr;
726 doublereal gap, mid, tmp;
729 /* -- LAPACK auxiliary routine (version 3.7.1) -- */
730 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
731 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
735 /* ===================================================================== */
739 /* Parameter adjustments */
751 /* Quick return if possible */
757 maxitr = (integer) ((log(*spdiam + *pivmin) - log(*pivmin)) / log(2.)) +
759 mnwdth = *pivmin * 2.;
762 if (r__ < 1 || r__ > *n) {
766 /* Initialize unconverged intervals in [ WORK(2*I-1), WORK(2*I) ]. */
767 /* The Sturm Count, Count( WORK(2*I-1) ) is arranged to be I-1, while */
768 /* Count( WORK(2*I) ) is stored in IWORK( 2*I ). The integer IWORK( 2*I-1 ) */
769 /* for an unconverged interval is set to the index of the next unconverged */
770 /* interval, and is -1 or 0 for a converged interval. Thus a linked */
771 /* list of unconverged intervals is set up. */
774 /* The number of unconverged intervals */
776 /* The last unconverged interval found */
778 rgap = wgap[i1 - *offset];
780 for (i__ = i1; i__ <= i__1; ++i__) {
783 left = w[ii] - werr[ii];
784 right = w[ii] + werr[ii];
787 gap = f2cmin(lgap,rgap);
788 /* Make sure that [LEFT,RIGHT] contains the desired eigenvalue */
789 /* Compute negcount from dstqds facto L+D+L+^T = L D L^T - LEFT */
791 /* Do while( NEGCNT(LEFT).GT.I-1 ) */
795 negcnt = dlaneg_(n, &d__[1], &lld[1], &left, pivmin, &r__);
796 if (negcnt > i__ - 1) {
802 /* Do while( NEGCNT(RIGHT).LT.I ) */
803 /* Compute negcount from dstqds facto L+D+L+^T = L D L^T - RIGHT */
807 negcnt = dlaneg_(n, &d__[1], &lld[1], &right, pivmin, &r__);
813 width = (d__1 = left - right, abs(d__1)) * .5;
815 d__1 = abs(left), d__2 = abs(right);
816 tmp = f2cmax(d__1,d__2);
818 d__1 = *rtol1 * gap, d__2 = *rtol2 * tmp;
819 cvrgd = f2cmax(d__1,d__2);
820 if (width <= cvrgd || width <= mnwdth) {
821 /* This interval has already converged and does not need refinement. */
822 /* (Note that the gaps might change through refining the */
823 /* eigenvalues, however, they can only get bigger.) */
824 /* Remove it from the list. */
826 /* Make sure that I1 always points to the first unconverged interval */
827 if (i__ == i1 && i__ < *ilast) {
830 if (prev >= i1 && i__ <= *ilast) {
831 iwork[(prev << 1) - 1] = i__ + 1;
834 /* unconverged interval found */
837 iwork[k - 1] = i__ + 1;
845 /* Do while( NINT.GT.0 ), i.e. there are still unconverged intervals */
846 /* and while (ITER.LT.MAXITR) */
854 for (ip = 1; ip <= i__1; ++ip) {
862 gap = f2cmin(lgap,rgap);
866 mid = (left + right) * .5;
867 /* semiwidth of interval */
870 d__1 = abs(left), d__2 = abs(right);
871 tmp = f2cmax(d__1,d__2);
873 d__1 = *rtol1 * gap, d__2 = *rtol2 * tmp;
874 cvrgd = f2cmax(d__1,d__2);
875 if (width <= cvrgd || width <= mnwdth || iter == maxitr) {
876 /* reduce number of unconverged intervals */
878 /* Mark interval as converged. */
883 /* Prev holds the last unconverged interval previously examined */
885 iwork[(prev << 1) - 1] = next;
893 /* Perform one bisection step */
895 negcnt = dlaneg_(n, &d__[1], &lld[1], &mid, pivmin, &r__);
896 if (negcnt <= i__ - 1) {
906 /* do another loop if there are still unconverged intervals */
907 /* However, in the last iteration, all intervals are accepted */
908 /* since this is the best we can do. */
909 if (nint > 0 && iter <= maxitr) {
914 /* At this point, all the intervals have converged */
916 for (i__ = *ifirst; i__ <= i__1; ++i__) {
919 /* All intervals marked by '0' have been refined. */
920 if (iwork[k - 1] == 0) {
921 w[ii] = (work[k - 1] + work[k]) * .5;
922 werr[ii] = work[k] - w[ii];
928 for (i__ = *ifirst + 1; i__ <= i__1; ++i__) {
932 d__1 = 0., d__2 = w[ii] - werr[ii] - w[ii - 1] - werr[ii - 1];
933 wgap[ii - 1] = f2cmax(d__1,d__2);