3 /* Subroutine */ int slarrj_(integer *n, real *d__, real *e2, integer *ifirst,
4 integer *ilast, real *rtol, integer *offset, real *w, real *werr,
5 real *work, integer *iwork, real *pivmin, real *spdiam, integer *info)
7 /* System generated locals */
11 /* Builtin functions */
12 double log(doublereal);
21 integer iter, nint, prev, next, savi1;
22 real right, width, dplus;
23 integer olnint, maxitr;
26 /* -- LAPACK auxiliary routine (version 3.1) -- */
27 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
30 /* .. Scalar Arguments .. */
32 /* .. Array Arguments .. */
38 /* Given the initial eigenvalue approximations of T, SLARRJ */
39 /* does bisection to refine the eigenvalues of T, */
40 /* W( IFIRST-OFFSET ) through W( ILAST-OFFSET ), to more accuracy. Initial */
41 /* guesses for these eigenvalues are input in W, the corresponding estimate */
42 /* of the error in these guesses in WERR. During bisection, intervals */
43 /* [left, right] are maintained by storing their mid-points and */
44 /* semi-widths in the arrays W and WERR respectively. */
49 /* N (input) INTEGER */
50 /* The order of the matrix. */
52 /* D (input) REAL array, dimension (N) */
53 /* The N diagonal elements of T. */
55 /* E2 (input) REAL array, dimension (N-1) */
56 /* The Squares of the (N-1) subdiagonal elements of T. */
58 /* IFIRST (input) INTEGER */
59 /* The index of the first eigenvalue to be computed. */
61 /* ILAST (input) INTEGER */
62 /* The index of the last eigenvalue to be computed. */
64 /* RTOL (input) REAL */
65 /* Tolerance for the convergence of the bisection intervals. */
66 /* An interval [LEFT,RIGHT] has converged if */
67 /* RIGHT-LEFT.LT.RTOL*MAX(|LEFT|,|RIGHT|). */
69 /* OFFSET (input) INTEGER */
70 /* Offset for the arrays W and WERR, i.e., the IFIRST-OFFSET */
71 /* through ILAST-OFFSET elements of these arrays are to be used. */
73 /* W (input/output) REAL array, dimension (N) */
74 /* On input, W( IFIRST-OFFSET ) through W( ILAST-OFFSET ) are */
75 /* estimates of the eigenvalues of L D L^T indexed IFIRST through */
77 /* On output, these estimates are refined. */
79 /* WERR (input/output) REAL array, dimension (N) */
80 /* On input, WERR( IFIRST-OFFSET ) through WERR( ILAST-OFFSET ) are */
81 /* the errors in the estimates of the corresponding elements in W. */
82 /* On output, these errors are refined. */
84 /* WORK (workspace) REAL array, dimension (2*N) */
87 /* IWORK (workspace) INTEGER array, dimension (2*N) */
90 /* PIVMIN (input) DOUBLE PRECISION */
91 /* The minimum pivot in the Sturm sequence for T. */
93 /* SPDIAM (input) DOUBLE PRECISION */
94 /* The spectral diameter of T. */
96 /* INFO (output) INTEGER */
100 /* =============== */
102 /* Based on contributions by */
103 /* Beresford Parlett, University of California, Berkeley, USA */
104 /* Jim Demmel, University of California, Berkeley, USA */
105 /* Inderjit Dhillon, University of Texas, Austin, USA */
106 /* Osni Marques, LBNL/NERSC, USA */
107 /* Christof Voemel, University of California, Berkeley, USA */
109 /* ===================================================================== */
111 /* .. Parameters .. */
113 /* .. Local Scalars .. */
116 /* .. Intrinsic Functions .. */
118 /* .. Executable Statements .. */
120 /* Parameter adjustments */
131 maxitr = (integer) ((log(*spdiam + *pivmin) - log(*pivmin)) / log(2.f)) +
134 /* Initialize unconverged intervals in [ WORK(2*I-1), WORK(2*I) ]. */
135 /* The Sturm Count, Count( WORK(2*I-1) ) is arranged to be I-1, while */
136 /* Count( WORK(2*I) ) is stored in IWORK( 2*I ). The integer IWORK( 2*I-1 ) */
137 /* for an unconverged interval is set to the index of the next unconverged */
138 /* interval, and is -1 or 0 for a converged interval. Thus a linked */
139 /* list of unconverged intervals is set up. */
143 /* The number of unconverged intervals */
145 /* The last unconverged interval found */
148 for (i__ = i1; i__ <= i__1; ++i__) {
151 left = w[ii] - werr[ii];
153 right = w[ii] + werr[ii];
156 r__1 = dabs(left), r__2 = dabs(right);
157 tmp = dmax(r__1,r__2);
158 /* The following test prevents the test of converged intervals */
159 if (width < *rtol * tmp) {
160 /* This interval has already converged and does not need refinement. */
161 /* (Note that the gaps might change through refining the */
162 /* eigenvalues, however, they can only get bigger.) */
163 /* Remove it from the list. */
165 /* Make sure that I1 always points to the first unconverged interval */
166 if (i__ == i1 && i__ < i2) {
169 if (prev >= i1 && i__ <= i2) {
170 iwork[(prev << 1) - 1] = i__ + 1;
173 /* unconverged interval found */
175 /* Make sure that [LEFT,RIGHT] contains the desired eigenvalue */
177 /* Do while( CNT(LEFT).GT.I-1 ) */
188 for (j = 2; j <= i__2; ++j) {
189 dplus = d__[j] - s - e2[j - 1] / dplus;
196 left -= werr[ii] * fac;
201 /* Do while( CNT(RIGHT).LT.I ) */
212 for (j = 2; j <= i__2; ++j) {
213 dplus = d__[j] - s - e2[j - 1] / dplus;
220 right += werr[ii] * fac;
225 iwork[k - 1] = i__ + 1;
234 /* Do while( NINT.GT.0 ), i.e. there are still unconverged intervals */
235 /* and while (ITER.LT.MAXITR) */
243 for (p = 1; p <= i__1; ++p) {
249 mid = (left + right) * .5f;
250 /* semiwidth of interval */
253 r__1 = dabs(left), r__2 = dabs(right);
254 tmp = dmax(r__1,r__2);
255 if (width < *rtol * tmp || iter == maxitr) {
256 /* reduce number of unconverged intervals */
258 /* Mark interval as converged. */
263 /* Prev holds the last unconverged interval previously examined */
265 iwork[(prev << 1) - 1] = next;
273 /* Perform one bisection step */
282 for (j = 2; j <= i__2; ++j) {
283 dplus = d__[j] - s - e2[j - 1] / dplus;
289 if (cnt <= i__ - 1) {
299 /* do another loop if there are still unconverged intervals */
300 /* However, in the last iteration, all intervals are accepted */
301 /* since this is the best we can do. */
302 if (nint > 0 && iter <= maxitr) {
307 /* At this point, all the intervals have converged */
309 for (i__ = savi1; i__ <= i__1; ++i__) {
312 /* All intervals marked by '0' have been refined. */
313 if (iwork[k - 1] == 0) {
314 w[ii] = (work[k - 1] + work[k]) * .5f;
315 werr[ii] = work[k] - w[ii];