3 /* Subroutine */ int dlarrj_(integer *n, doublereal *d__, doublereal *e2,
4 integer *ifirst, integer *ilast, doublereal *rtol, integer *offset,
5 doublereal *w, doublereal *werr, doublereal *work, integer *iwork,
6 doublereal *pivmin, doublereal *spdiam, integer *info)
8 /* System generated locals */
10 doublereal d__1, d__2;
12 /* Builtin functions */
13 double log(doublereal);
22 integer iter, nint, prev, next, savi1;
23 doublereal right, width, dplus;
24 integer olnint, maxitr;
27 /* -- LAPACK auxiliary routine (version 3.1) -- */
28 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
31 /* .. Scalar Arguments .. */
33 /* .. Array Arguments .. */
39 /* Given the initial eigenvalue approximations of T, DLARRJ */
40 /* does bisection to refine the eigenvalues of T, */
41 /* W( IFIRST-OFFSET ) through W( ILAST-OFFSET ), to more accuracy. Initial */
42 /* guesses for these eigenvalues are input in W, the corresponding estimate */
43 /* of the error in these guesses in WERR. During bisection, intervals */
44 /* [left, right] are maintained by storing their mid-points and */
45 /* semi-widths in the arrays W and WERR respectively. */
50 /* N (input) INTEGER */
51 /* The order of the matrix. */
53 /* D (input) DOUBLE PRECISION array, dimension (N) */
54 /* The N diagonal elements of T. */
56 /* E2 (input) DOUBLE PRECISION array, dimension (N-1) */
57 /* The Squares of the (N-1) subdiagonal elements of T. */
59 /* IFIRST (input) INTEGER */
60 /* The index of the first eigenvalue to be computed. */
62 /* ILAST (input) INTEGER */
63 /* The index of the last eigenvalue to be computed. */
65 /* RTOL (input) DOUBLE PRECISION */
66 /* Tolerance for the convergence of the bisection intervals. */
67 /* An interval [LEFT,RIGHT] has converged if */
68 /* RIGHT-LEFT.LT.RTOL*MAX(|LEFT|,|RIGHT|). */
70 /* OFFSET (input) INTEGER */
71 /* Offset for the arrays W and WERR, i.e., the IFIRST-OFFSET */
72 /* through ILAST-OFFSET elements of these arrays are to be used. */
74 /* W (input/output) DOUBLE PRECISION array, dimension (N) */
75 /* On input, W( IFIRST-OFFSET ) through W( ILAST-OFFSET ) are */
76 /* estimates of the eigenvalues of L D L^T indexed IFIRST through */
78 /* On output, these estimates are refined. */
80 /* WERR (input/output) DOUBLE PRECISION array, dimension (N) */
81 /* On input, WERR( IFIRST-OFFSET ) through WERR( ILAST-OFFSET ) are */
82 /* the errors in the estimates of the corresponding elements in W. */
83 /* On output, these errors are refined. */
85 /* WORK (workspace) DOUBLE PRECISION array, dimension (2*N) */
88 /* IWORK (workspace) INTEGER array, dimension (2*N) */
91 /* PIVMIN (input) DOUBLE PRECISION */
92 /* The minimum pivot in the Sturm sequence for T. */
94 /* SPDIAM (input) DOUBLE PRECISION */
95 /* The spectral diameter of T. */
97 /* INFO (output) INTEGER */
100 /* Further Details */
101 /* =============== */
103 /* Based on contributions by */
104 /* Beresford Parlett, University of California, Berkeley, USA */
105 /* Jim Demmel, University of California, Berkeley, USA */
106 /* Inderjit Dhillon, University of Texas, Austin, USA */
107 /* Osni Marques, LBNL/NERSC, USA */
108 /* Christof Voemel, University of California, Berkeley, USA */
110 /* ===================================================================== */
112 /* .. Parameters .. */
114 /* .. Local Scalars .. */
117 /* .. Intrinsic Functions .. */
119 /* .. Executable Statements .. */
121 /* Parameter adjustments */
132 maxitr = (integer) ((log(*spdiam + *pivmin) - log(*pivmin)) / log(2.)) +
135 /* Initialize unconverged intervals in [ WORK(2*I-1), WORK(2*I) ]. */
136 /* The Sturm Count, Count( WORK(2*I-1) ) is arranged to be I-1, while */
137 /* Count( WORK(2*I) ) is stored in IWORK( 2*I ). The integer IWORK( 2*I-1 ) */
138 /* for an unconverged interval is set to the index of the next unconverged */
139 /* interval, and is -1 or 0 for a converged interval. Thus a linked */
140 /* list of unconverged intervals is set up. */
144 /* The number of unconverged intervals */
146 /* The last unconverged interval found */
149 for (i__ = i1; i__ <= i__1; ++i__) {
152 left = w[ii] - werr[ii];
154 right = w[ii] + werr[ii];
157 d__1 = abs(left), d__2 = abs(right);
158 tmp = max(d__1,d__2);
159 /* The following test prevents the test of converged intervals */
160 if (width < *rtol * tmp) {
161 /* This interval has already converged and does not need refinement. */
162 /* (Note that the gaps might change through refining the */
163 /* eigenvalues, however, they can only get bigger.) */
164 /* Remove it from the list. */
166 /* Make sure that I1 always points to the first unconverged interval */
167 if (i__ == i1 && i__ < i2) {
170 if (prev >= i1 && i__ <= i2) {
171 iwork[(prev << 1) - 1] = i__ + 1;
174 /* unconverged interval found */
176 /* Make sure that [LEFT,RIGHT] contains the desired eigenvalue */
178 /* Do while( CNT(LEFT).GT.I-1 ) */
189 for (j = 2; j <= i__2; ++j) {
190 dplus = d__[j] - s - e2[j - 1] / dplus;
197 left -= werr[ii] * fac;
202 /* Do while( CNT(RIGHT).LT.I ) */
213 for (j = 2; j <= i__2; ++j) {
214 dplus = d__[j] - s - e2[j - 1] / dplus;
221 right += werr[ii] * fac;
226 iwork[k - 1] = i__ + 1;
235 /* Do while( NINT.GT.0 ), i.e. there are still unconverged intervals */
236 /* and while (ITER.LT.MAXITR) */
244 for (p = 1; p <= i__1; ++p) {
250 mid = (left + right) * .5;
251 /* semiwidth of interval */
254 d__1 = abs(left), d__2 = abs(right);
255 tmp = max(d__1,d__2);
256 if (width < *rtol * tmp || iter == maxitr) {
257 /* reduce number of unconverged intervals */
259 /* Mark interval as converged. */
264 /* Prev holds the last unconverged interval previously examined */
266 iwork[(prev << 1) - 1] = next;
274 /* Perform one bisection step */
283 for (j = 2; j <= i__2; ++j) {
284 dplus = d__[j] - s - e2[j - 1] / dplus;
290 if (cnt <= i__ - 1) {
300 /* do another loop if there are still unconverged intervals */
301 /* However, in the last iteration, all intervals are accepted */
302 /* since this is the best we can do. */
303 if (nint > 0 && iter <= maxitr) {
308 /* At this point, all the intervals have converged */
310 for (i__ = savi1; i__ <= i__1; ++i__) {
313 /* All intervals marked by '0' have been refined. */
314 if (iwork[k - 1] == 0) {
315 w[ii] = (work[k - 1] + work[k]) * .5;
316 werr[ii] = work[k] - w[ii];