/* Subroutine */ int slarre_(char* range, integer* n, real* vl, real* vu, integer* il, integer* iu, real* d__, real* e, real* e2, real* rtol1, real* rtol2, real* spltol, integer* nsplit, integer* isplit, integer * m, real* w, real* werr, real* wgap, integer* iblock, integer* indexw, real* gers, real* pivmin, real* work, integer* iwork, integer* info) { /* System generated locals */ integer i__1, i__2; real r__1, r__2, r__3; /* Builtin functions */ double sqrt(doublereal), log(doublereal); /* Local variables */ integer i__, j; real s1, s2; integer mb; real gl; integer in, mm; real gu; integer cnt; real eps, tau, tmp, rtl; integer cnt1, cnt2; real tmp1, eabs; integer iend, jblk; real eold; integer indl; real dmax__, emax; integer wend, idum, indu; real rtol; integer iseed[4]; real avgap, sigma; extern logical lsame_(char*, char*); integer iinfo; logical norep; extern /* Subroutine */ int scopy_(integer*, real*, integer*, real*, integer*), slasq2_(integer*, real*, integer*); integer ibegin; logical forceb; integer irange; real sgndef; extern doublereal slamch_(char*); integer wbegin; real safmin, spdiam; extern /* Subroutine */ int slarra_(integer*, real*, real*, real*, real*, real*, integer*, integer*, integer*); logical usedqd; real clwdth, isleft; extern /* Subroutine */ int slarrb_(integer*, real*, real*, integer*, integer*, real*, real*, integer*, real*, real*, real*, real*, integer*, real*, real*, integer*, integer*), slarrc_( char*, integer*, real*, real*, real*, real*, real*, integer*, integer*, integer*, integer*), slarrd_(char *, char*, integer*, real*, real*, integer*, integer*, real * , real*, real*, real*, real*, real*, integer*, integer*, integer*, real*, real*, real*, real*, integer*, integer*, real*, integer*, integer*), slarrk_(integer*, integer*, real*, real*, real*, real*, real*, real*, real*, real*, integer*); real isrght, bsrtol, dpivot; extern /* Subroutine */ int slarnv_(integer*, integer*, integer*, real *); /* -- LAPACK auxiliary routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* To find the desired eigenvalues of a given real symmetric */ /* tridiagonal matrix T, SLARRE sets any "small" off-diagonal */ /* elements to zero, and for each unreduced block T_i, it finds */ /* (a) a suitable shift at one end of the block's spectrum, */ /* (b) the base representation, T_i - sigma_i I = L_i D_i L_i^T, and */ /* (c) eigenvalues of each L_i D_i L_i^T. */ /* The representations and eigenvalues found are then used by */ /* SSTEMR to compute the eigenvectors of T. */ /* The accuracy varies depending on whether bisection is used to */ /* find a few eigenvalues or the dqds algorithm (subroutine SLASQ2) to */ /* conpute all and then discard any unwanted one. */ /* As an added benefit, SLARRE also outputs the n */ /* Gerschgorin intervals for the matrices L_i D_i L_i^T. */ /* Arguments */ /* ========= */ /* RANGE (input) CHARACTER */ /* = 'A': ("All") all eigenvalues will be found. */ /* = 'V': ("Value") all eigenvalues in the half-open interval */ /* (VL, VU] will be found. */ /* = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */ /* entire matrix) will be found. */ /* N (input) INTEGER */ /* The order of the matrix. N > 0. */ /* VL (input/output) REAL */ /* VU (input/output) REAL */ /* If RANGE='V', the lower and upper bounds for the eigenvalues. */ /* Eigenvalues less than or equal to VL, or greater than VU, */ /* will not be returned. VL < VU. */ /* If RANGE='I' or ='A', SLARRE computes bounds on the desired */ /* part of the spectrum. */ /* IL (input) INTEGER */ /* IU (input) INTEGER */ /* If RANGE='I', the indices (in ascending order) of the */ /* smallest and largest eigenvalues to be returned. */ /* 1 <= IL <= IU <= N. */ /* D (input/output) REAL array, dimension (N) */ /* On entry, the N diagonal elements of the tridiagonal */ /* matrix T. */ /* On exit, the N diagonal elements of the diagonal */ /* matrices D_i. */ /* E (input/output) REAL array, dimension (N) */ /* On entry, the first (N-1) entries contain the subdiagonal */ /* elements of the tridiagonal matrix T; E(N) need not be set. */ /* On exit, E contains the subdiagonal elements of the unit */ /* bidiagonal matrices L_i. The entries E( ISPLIT( I ) ), */ /* 1 <= I <= NSPLIT, contain the base points sigma_i on output. */ /* E2 (input/output) REAL array, dimension (N) */ /* On entry, the first (N-1) entries contain the SQUARES of the */ /* subdiagonal elements of the tridiagonal matrix T; */ /* E2(N) need not be set. */ /* On exit, the entries E2( ISPLIT( I ) ), */ /* 1 <= I <= NSPLIT, have been set to zero */ /* RTOL1 (input) REAL */ /* RTOL2 (input) REAL */ /* Parameters for bisection. */ /* An interval [LEFT,RIGHT] has converged if */ /* RIGHT-LEFT.LT.MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */ /* SPLTOL (input) REAL */ /* The threshold for splitting. */ /* NSPLIT (output) INTEGER */ /* The number of blocks T splits into. 1 <= NSPLIT <= N. */ /* ISPLIT (output) INTEGER array, dimension (N) */ /* The splitting points, at which T breaks up into blocks. */ /* The first block consists of rows/columns 1 to ISPLIT(1), */ /* the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */ /* etc., and the NSPLIT-th consists of rows/columns */ /* ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */ /* M (output) INTEGER */ /* The total number of eigenvalues (of all L_i D_i L_i^T) */ /* found. */ /* W (output) REAL array, dimension (N) */ /* The first M elements contain the eigenvalues. The */ /* eigenvalues of each of the blocks, L_i D_i L_i^T, are */ /* sorted in ascending order ( SLARRE may use the */ /* remaining N-M elements as workspace). */ /* WERR (output) REAL array, dimension (N) */ /* The error bound on the corresponding eigenvalue in W. */ /* WGAP (output) REAL array, dimension (N) */ /* The separation from the right neighbor eigenvalue in W. */ /* The gap is only with respect to the eigenvalues of the same block */ /* as each block has its own representation tree. */ /* Exception: at the right end of a block we store the left gap */ /* IBLOCK (output) INTEGER array, dimension (N) */ /* The indices of the blocks (submatrices) associated with the */ /* corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */ /* W(i) belongs to the first block from the top, =2 if W(i) */ /* belongs to the second block, etc. */ /* INDEXW (output) INTEGER array, dimension (N) */ /* The indices of the eigenvalues within each block (submatrix); */ /* for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */ /* i-th eigenvalue W(i) is the 10-th eigenvalue in block 2 */ /* GERS (output) REAL array, dimension (2*N) */ /* The N Gerschgorin intervals (the i-th Gerschgorin interval */ /* is (GERS(2*i-1), GERS(2*i)). */ /* PIVMIN (output) DOUBLE PRECISION */ /* The minimum pivot in the Sturm sequence for T. */ /* WORK (workspace) REAL array, dimension (6*N) */ /* Workspace. */ /* IWORK (workspace) INTEGER array, dimension (5*N) */ /* Workspace. */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* > 0: A problem occured in SLARRE. */ /* < 0: One of the called subroutines signaled an internal problem. */ /* Needs inspection of the corresponding parameter IINFO */ /* for further information. */ /* =-1: Problem in SLARRD. */ /* = 2: No base representation could be found in MAXTRY iterations. */ /* Increasing MAXTRY and recompilation might be a remedy. */ /* =-3: Problem in SLARRB when computing the refined root */ /* representation for SLASQ2. */ /* =-4: Problem in SLARRB when preforming bisection on the */ /* desired part of the spectrum. */ /* =-5: Problem in SLASQ2. */ /* =-6: Problem in SLASQ2. */ /* Further Details */ /* The base representations are required to suffer very little */ /* element growth and consequently define all their eigenvalues to */ /* high relative accuracy. */ /* =============== */ /* Based on contributions by */ /* Beresford Parlett, University of California, Berkeley, USA */ /* Jim Demmel, University of California, Berkeley, USA */ /* Inderjit Dhillon, University of Texas, Austin, USA */ /* Osni Marques, LBNL/NERSC, USA */ /* Christof Voemel, University of California, Berkeley, USA */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ --iwork; --work; --gers; --indexw; --iblock; --wgap; --werr; --w; --isplit; --e2; --e; --d__; /* Function Body */ *info = 0; /* Decode RANGE */ if (lsame_(range, "A")) { irange = 1; } else if (lsame_(range, "V")) { irange = 3; } else if (lsame_(range, "I")) { irange = 2; } *m = 0; /* Get machine constants */ safmin = slamch_("S"); eps = slamch_("P"); /* Set parameters */ rtl = eps * 100.f; /* If one were ever to ask for less initial precision in BSRTOL, */ /* one should keep in mind that for the subset case, the extremal */ /* eigenvalues must be at least as accurate as the current setting */ /* (eigenvalues in the middle need not as much accuracy) */ bsrtol = sqrt(eps) * 5e-4f; /* Treat case of 1x1 matrix for quick return */ if (*n == 1) { if (irange == 1 || irange == 3 && d__[1] > *vl && d__[1] <= *vu || irange == 2 && *il == 1 && *iu == 1) { *m = 1; w[1] = d__[1]; /* The computation error of the eigenvalue is zero */ werr[1] = 0.f; wgap[1] = 0.f; iblock[1] = 1; indexw[1] = 1; gers[1] = d__[1]; gers[2] = d__[1]; } /* store the shift for the initial RRR, which is zero in this case */ e[1] = 0.f; return 0; } /* General case: tridiagonal matrix of order > 1 */ /* Init WERR, WGAP. Compute Gerschgorin intervals and spectral diameter. */ /* Compute maximum off-diagonal entry and pivmin. */ gl = d__[1]; gu = d__[1]; eold = 0.f; emax = 0.f; e[*n] = 0.f; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { werr[i__] = 0.f; wgap[i__] = 0.f; eabs = (r__1 = e[i__], dabs(r__1)); if (eabs >= emax) { emax = eabs; } tmp1 = eabs + eold; gers[(i__ << 1) - 1] = d__[i__] - tmp1; /* Computing MIN */ r__1 = gl, r__2 = gers[(i__ << 1) - 1]; gl = dmin(r__1, r__2); gers[i__ * 2] = d__[i__] + tmp1; /* Computing MAX */ r__1 = gu, r__2 = gers[i__ * 2]; gu = dmax(r__1, r__2); eold = eabs; /* L5: */ } /* The minimum pivot allowed in the Sturm sequence for T */ /* Computing MAX */ /* Computing 2nd power */ r__3 = emax; r__1 = 1.f, r__2 = r__3 * r__3; *pivmin = safmin * dmax(r__1, r__2); /* Compute spectral diameter. The Gerschgorin bounds give an */ /* estimate that is wrong by at most a factor of SQRT(2) */ spdiam = gu - gl; /* Compute splitting points */ slarra_(n, &d__[1], &e[1], &e2[1], spltol, &spdiam, nsplit, &isplit[1], & iinfo); /* Can force use of bisection instead of faster DQDS. */ /* Option left in the code for future multisection work. */ forceb = FALSE_; if (irange == 1 && ! forceb) { /* Set interval [VL,VU] that contains all eigenvalues */ *vl = gl; *vu = gu; } else { /* We call SLARRD to find crude approximations to the eigenvalues */ /* in the desired range. In case IRANGE = INDRNG, we also obtain the */ /* interval (VL,VU] that contains all the wanted eigenvalues. */ /* An interval [LEFT,RIGHT] has converged if */ /* RIGHT-LEFT.LT.RTOL*MAX(ABS(LEFT),ABS(RIGHT)) */ /* SLARRD needs a WORK of size 4*N, IWORK of size 3*N */ slarrd_(range, "B", n, vl, vu, il, iu, &gers[1], &bsrtol, &d__[1], &e[ 1], &e2[1], pivmin, nsplit, &isplit[1], &mm, &w[1], &werr[1], vl, vu, &iblock[1], &indexw[1], &work[1], &iwork[1], &iinfo); if (iinfo != 0) { *info = -1; return 0; } /* Make sure that the entries M+1 to N in W, WERR, IBLOCK, INDEXW are 0 */ i__1 = *n; for (i__ = mm + 1; i__ <= i__1; ++i__) { w[i__] = 0.f; werr[i__] = 0.f; iblock[i__] = 0; indexw[i__] = 0; /* L14: */ } } /* ** */ /* Loop over unreduced blocks */ ibegin = 1; wbegin = 1; i__1 = *nsplit; for (jblk = 1; jblk <= i__1; ++jblk) { iend = isplit[jblk]; in = iend - ibegin + 1; /* 1 X 1 block */ if (in == 1) { if (irange == 1 || irange == 3 && d__[ibegin] > *vl && d__[ibegin] <= *vu || irange == 2 && iblock[wbegin] == jblk) { ++(*m); w[*m] = d__[ibegin]; werr[*m] = 0.f; /* The gap for a single block doesn't matter for the later */ /* algorithm and is assigned an arbitrary large value */ wgap[*m] = 0.f; iblock[*m] = jblk; indexw[*m] = 1; ++wbegin; } /* E( IEND ) holds the shift for the initial RRR */ e[iend] = 0.f; ibegin = iend + 1; goto L170; } /* Blocks of size larger than 1x1 */ /* E( IEND ) will hold the shift for the initial RRR, for now set it =0 */ e[iend] = 0.f; /* Find local outer bounds GL,GU for the block */ gl = d__[ibegin]; gu = d__[ibegin]; i__2 = iend; for (i__ = ibegin; i__ <= i__2; ++i__) { /* Computing MIN */ r__1 = gers[(i__ << 1) - 1]; gl = dmin(r__1, gl); /* Computing MAX */ r__1 = gers[i__ * 2]; gu = dmax(r__1, gu); /* L15: */ } spdiam = gu - gl; if (!(irange == 1 && ! forceb)) { /* Count the number of eigenvalues in the current block. */ mb = 0; i__2 = mm; for (i__ = wbegin; i__ <= i__2; ++i__) { if (iblock[i__] == jblk) { ++mb; } else { goto L21; } /* L20: */ } L21: if (mb == 0) { /* No eigenvalue in the current block lies in the desired range */ /* E( IEND ) holds the shift for the initial RRR */ e[iend] = 0.f; ibegin = iend + 1; goto L170; } else { /* Decide whether dqds or bisection is more efficient */ usedqd = (real) mb > in * .5f && ! forceb; wend = wbegin + mb - 1; /* Calculate gaps for the current block */ /* In later stages, when representations for individual */ /* eigenvalues are different, we use SIGMA = E( IEND ). */ sigma = 0.f; i__2 = wend - 1; for (i__ = wbegin; i__ <= i__2; ++i__) { /* Computing MAX */ r__1 = 0.f, r__2 = w[i__ + 1] - werr[i__ + 1] - (w[i__] + werr[i__]); wgap[i__] = dmax(r__1, r__2); /* L30: */ } /* Computing MAX */ r__1 = 0.f, r__2 = *vu - sigma - (w[wend] + werr[wend]); wgap[wend] = dmax(r__1, r__2); /* Find local index of the first and last desired evalue. */ indl = indexw[wbegin]; indu = indexw[wend]; } } if (irange == 1 && ! forceb || usedqd) { /* Case of DQDS */ /* Find approximations to the extremal eigenvalues of the block */ slarrk_(&in, &c__1, &gl, &gu, &d__[ibegin], &e2[ibegin], pivmin, & rtl, &tmp, &tmp1, &iinfo); if (iinfo != 0) { *info = -1; return 0; } /* Computing MAX */ r__2 = gl, r__3 = tmp - tmp1 - eps * 100.f * (r__1 = tmp - tmp1, dabs(r__1)); isleft = dmax(r__2, r__3); slarrk_(&in, &in, &gl, &gu, &d__[ibegin], &e2[ibegin], pivmin, & rtl, &tmp, &tmp1, &iinfo); if (iinfo != 0) { *info = -1; return 0; } /* Computing MIN */ r__2 = gu, r__3 = tmp + tmp1 + eps * 100.f * (r__1 = tmp + tmp1, dabs(r__1)); isrght = dmin(r__2, r__3); /* Improve the estimate of the spectral diameter */ spdiam = isrght - isleft; } else { /* Case of bisection */ /* Find approximations to the wanted extremal eigenvalues */ /* Computing MAX */ r__2 = gl, r__3 = w[wbegin] - werr[wbegin] - eps * 100.f * (r__1 = w[wbegin] - werr[wbegin], dabs(r__1)); isleft = dmax(r__2, r__3); /* Computing MIN */ r__2 = gu, r__3 = w[wend] + werr[wend] + eps * 100.f * (r__1 = w[ wend] + werr[wend], dabs(r__1)); isrght = dmin(r__2, r__3); } /* Decide whether the base representation for the current block */ /* L_JBLK D_JBLK L_JBLK^T = T_JBLK - sigma_JBLK I */ /* should be on the left or the right end of the current block. */ /* The strategy is to shift to the end which is "more populated" */ /* Furthermore, decide whether to use DQDS for the computation of */ /* the eigenvalue approximations at the end of SLARRE or bisection. */ /* dqds is chosen if all eigenvalues are desired or the number of */ /* eigenvalues to be computed is large compared to the blocksize. */ if (irange == 1 && ! forceb) { /* If all the eigenvalues have to be computed, we use dqd */ usedqd = TRUE_; /* INDL is the local index of the first eigenvalue to compute */ indl = 1; indu = in; /* MB = number of eigenvalues to compute */ mb = in; wend = wbegin + mb - 1; /* Define 1/4 and 3/4 points of the spectrum */ s1 = isleft + spdiam * .25f; s2 = isrght - spdiam * .25f; } else { /* SLARRD has computed IBLOCK and INDEXW for each eigenvalue */ /* approximation. */ /* choose sigma */ if (usedqd) { s1 = isleft + spdiam * .25f; s2 = isrght - spdiam * .25f; } else { tmp = dmin(isrght, *vu) - dmax(isleft, *vl); s1 = dmax(isleft, *vl) + tmp * .25f; s2 = dmin(isrght, *vu) - tmp * .25f; } } /* Compute the negcount at the 1/4 and 3/4 points */ if (mb > 1) { slarrc_("T", &in, &s1, &s2, &d__[ibegin], &e[ibegin], pivmin, & cnt, &cnt1, &cnt2, &iinfo); } if (mb == 1) { sigma = gl; sgndef = 1.f; } else if (cnt1 - indl >= indu - cnt2) { if (irange == 1 && ! forceb) { sigma = dmax(isleft, gl); } else if (usedqd) { /* use Gerschgorin bound as shift to get pos def matrix */ /* for dqds */ sigma = isleft; } else { /* use approximation of the first desired eigenvalue of the */ /* block as shift */ sigma = dmax(isleft, *vl); } sgndef = 1.f; } else { if (irange == 1 && ! forceb) { sigma = dmin(isrght, gu); } else if (usedqd) { /* use Gerschgorin bound as shift to get neg def matrix */ /* for dqds */ sigma = isrght; } else { /* use approximation of the first desired eigenvalue of the */ /* block as shift */ sigma = dmin(isrght, *vu); } sgndef = -1.f; } /* An initial SIGMA has been chosen that will be used for computing */ /* T - SIGMA I = L D L^T */ /* Define the increment TAU of the shift in case the initial shift */ /* needs to be refined to obtain a factorization with not too much */ /* element growth. */ if (usedqd) { /* The initial SIGMA was to the outer end of the spectrum */ /* the matrix is definite and we need not retreat. */ tau = spdiam * eps * *n + *pivmin * 2.f; } else { if (mb > 1) { clwdth = w[wend] + werr[wend] - w[wbegin] - werr[wbegin]; avgap = (r__1 = clwdth / (real)(wend - wbegin), dabs(r__1)); if (sgndef == 1.f) { /* Computing MAX */ r__1 = wgap[wbegin]; tau = dmax(r__1, avgap) * .5f; /* Computing MAX */ r__1 = tau, r__2 = werr[wbegin]; tau = dmax(r__1, r__2); } else { /* Computing MAX */ r__1 = wgap[wend - 1]; tau = dmax(r__1, avgap) * .5f; /* Computing MAX */ r__1 = tau, r__2 = werr[wend]; tau = dmax(r__1, r__2); } } else { tau = werr[wbegin]; } } for (idum = 1; idum <= 6; ++idum) { /* Compute L D L^T factorization of tridiagonal matrix T - sigma I. */ /* Store D in WORK(1:IN), L in WORK(IN+1:2*IN), and reciprocals of */ /* pivots in WORK(2*IN+1:3*IN) */ dpivot = d__[ibegin] - sigma; work[1] = dpivot; dmax__ = dabs(work[1]); j = ibegin; i__2 = in - 1; for (i__ = 1; i__ <= i__2; ++i__) { work[(in << 1) + i__] = 1.f / work[i__]; tmp = e[j] * work[(in << 1) + i__]; work[in + i__] = tmp; dpivot = d__[j + 1] - sigma - tmp * e[j]; work[i__ + 1] = dpivot; /* Computing MAX */ r__1 = dmax__, r__2 = dabs(dpivot); dmax__ = dmax(r__1, r__2); ++j; /* L70: */ } /* check for element growth */ if (dmax__ > spdiam * 64.f) { norep = TRUE_; } else { norep = FALSE_; } if (usedqd && ! norep) { /* Ensure the definiteness of the representation */ /* All entries of D (of L D L^T) must have the same sign */ i__2 = in; for (i__ = 1; i__ <= i__2; ++i__) { tmp = sgndef * work[i__]; if (tmp < 0.f) { norep = TRUE_; } /* L71: */ } } if (norep) { /* Note that in the case of IRANGE=ALLRNG, we use the Gerschgorin */ /* shift which makes the matrix definite. So we should end up */ /* here really only in the case of IRANGE = VALRNG or INDRNG. */ if (idum == 5) { if (sgndef == 1.f) { /* The fudged Gerschgorin shift should succeed */ sigma = gl - spdiam * 2.f * eps * *n - *pivmin * 4.f; } else { sigma = gu + spdiam * 2.f * eps * *n + *pivmin * 4.f; } } else { sigma -= sgndef * tau; tau *= 2.f; } } else { /* an initial RRR is found */ goto L83; } /* L80: */ } /* if the program reaches this point, no base representation could be */ /* found in MAXTRY iterations. */ *info = 2; return 0; L83: /* At this point, we have found an initial base representation */ /* T - SIGMA I = L D L^T with not too much element growth. */ /* Store the shift. */ e[iend] = sigma; /* Store D and L. */ scopy_(&in, &work[1], &c__1, &d__[ibegin], &c__1); i__2 = in - 1; scopy_(&i__2, &work[in + 1], &c__1, &e[ibegin], &c__1); if (mb > 1) { /* Perturb each entry of the base representation by a small */ /* (but random) relative amount to overcome difficulties with */ /* glued matrices. */ for (i__ = 1; i__ <= 4; ++i__) { iseed[i__ - 1] = 1; /* L122: */ } i__2 = (in << 1) - 1; slarnv_(&c__2, iseed, &i__2, &work[1]); i__2 = in - 1; for (i__ = 1; i__ <= i__2; ++i__) { d__[ibegin + i__ - 1] *= eps * 4.f * work[i__] + 1.f; e[ibegin + i__ - 1] *= eps * 4.f * work[in + i__] + 1.f; /* L125: */ } d__[iend] *= eps * 4.f * work[in] + 1.f; } /* Don't update the Gerschgorin intervals because keeping track */ /* of the updates would be too much work in SLARRV. */ /* We update W instead and use it to locate the proper Gerschgorin */ /* intervals. */ /* Compute the required eigenvalues of L D L' by bisection or dqds */ if (! usedqd) { /* If SLARRD has been used, shift the eigenvalue approximations */ /* according to their representation. This is necessary for */ /* a uniform SLARRV since dqds computes eigenvalues of the */ /* shifted representation. In SLARRV, W will always hold the */ /* UNshifted eigenvalue approximation. */ i__2 = wend; for (j = wbegin; j <= i__2; ++j) { w[j] -= sigma; werr[j] += (r__1 = w[j], dabs(r__1)) * eps; /* L134: */ } /* call SLARRB to reduce eigenvalue error of the approximations */ /* from SLARRD */ i__2 = iend - 1; for (i__ = ibegin; i__ <= i__2; ++i__) { /* Computing 2nd power */ r__1 = e[i__]; work[i__] = d__[i__] * (r__1 * r__1); /* L135: */ } /* use bisection to find EV from INDL to INDU */ i__2 = indl - 1; slarrb_(&in, &d__[ibegin], &work[ibegin], &indl, &indu, rtol1, rtol2, &i__2, &w[wbegin], &wgap[wbegin], &werr[wbegin], & work[(*n << 1) + 1], &iwork[1], pivmin, &spdiam, &in, & iinfo); if (iinfo != 0) { *info = -4; return 0; } /* SLARRB computes all gaps correctly except for the last one */ /* Record distance to VU/GU */ /* Computing MAX */ r__1 = 0.f, r__2 = *vu - sigma - (w[wend] + werr[wend]); wgap[wend] = dmax(r__1, r__2); i__2 = indu; for (i__ = indl; i__ <= i__2; ++i__) { ++(*m); iblock[*m] = jblk; indexw[*m] = i__; /* L138: */ } } else { /* Call dqds to get all eigs (and then possibly delete unwanted */ /* eigenvalues). */ /* Note that dqds finds the eigenvalues of the L D L^T representation */ /* of T to high relative accuracy. High relative accuracy */ /* might be lost when the shift of the RRR is subtracted to obtain */ /* the eigenvalues of T. However, T is not guaranteed to define its */ /* eigenvalues to high relative accuracy anyway. */ /* Set RTOL to the order of the tolerance used in SLASQ2 */ /* This is an ESTIMATED error, the worst case bound is 4*N*EPS */ /* which is usually too large and requires unnecessary work to be */ /* done by bisection when computing the eigenvectors */ rtol = log((real) in) * 4.f * eps; j = ibegin; i__2 = in - 1; for (i__ = 1; i__ <= i__2; ++i__) { work[(i__ << 1) - 1] = (r__1 = d__[j], dabs(r__1)); work[i__ * 2] = e[j] * e[j] * work[(i__ << 1) - 1]; ++j; /* L140: */ } work[(in << 1) - 1] = (r__1 = d__[iend], dabs(r__1)); work[in * 2] = 0.f; slasq2_(&in, &work[1], &iinfo); if (iinfo != 0) { /* If IINFO = -5 then an index is part of a tight cluster */ /* and should be changed. The index is in IWORK(1) and the */ /* gap is in WORK(N+1) */ *info = -5; return 0; } else { /* Test that all eigenvalues are positive as expected */ i__2 = in; for (i__ = 1; i__ <= i__2; ++i__) { if (work[i__] < 0.f) { *info = -6; return 0; } /* L149: */ } } if (sgndef > 0.f) { i__2 = indu; for (i__ = indl; i__ <= i__2; ++i__) { ++(*m); w[*m] = work[in - i__ + 1]; iblock[*m] = jblk; indexw[*m] = i__; /* L150: */ } } else { i__2 = indu; for (i__ = indl; i__ <= i__2; ++i__) { ++(*m); w[*m] = -work[i__]; iblock[*m] = jblk; indexw[*m] = i__; /* L160: */ } } i__2 = *m; for (i__ = *m - mb + 1; i__ <= i__2; ++i__) { /* the value of RTOL below should be the tolerance in SLASQ2 */ werr[i__] = rtol * (r__1 = w[i__], dabs(r__1)); /* L165: */ } i__2 = *m - 1; for (i__ = *m - mb + 1; i__ <= i__2; ++i__) { /* compute the right gap between the intervals */ /* Computing MAX */ r__1 = 0.f, r__2 = w[i__ + 1] - werr[i__ + 1] - (w[i__] + werr[i__]); wgap[i__] = dmax(r__1, r__2); /* L166: */ } /* Computing MAX */ r__1 = 0.f, r__2 = *vu - sigma - (w[*m] + werr[*m]); wgap[*m] = dmax(r__1, r__2); } /* proceed with next block */ ibegin = iend + 1; wbegin = wend + 1; L170: ; } return 0; /* end of SLARRE */ } /* slarre_ */
/* Subroutine */ int slarrv_(integer *n, real *vl, real *vu, real *d__, real * l, real *pivmin, integer *isplit, integer *m, integer *dol, integer * dou, real *minrgp, real *rtol1, real *rtol2, real *w, real *werr, real *wgap, integer *iblock, integer *indexw, real *gers, real *z__, integer *ldz, integer *isuppz, real *work, integer *iwork, integer * info) { /* System generated locals */ integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5; real r__1, r__2; logical L__1; /* Builtin functions */ double log(doublereal); /* Local variables */ integer minwsize, i__, j, k, p, q, miniwsize, ii; real gl; integer im, in; real gu, gap, eps, tau, tol, tmp; integer zto; real ztz; integer iend, jblk; real lgap; integer done; real rgap, left; integer wend, iter; real bstw; integer itmp1, indld; real fudge; integer idone; real sigma; integer iinfo, iindr; real resid; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); logical eskip; real right; integer nclus, zfrom; extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, integer *); real rqtol; integer iindc1, iindc2; extern /* Subroutine */ int slar1v_(integer *, integer *, integer *, real *, real *, real *, real *, real *, real *, real *, real *, logical *, integer *, real *, real *, integer *, integer *, real * , real *, real *, real *); logical stp2ii; real lambda; integer ibegin, indeig; logical needbs; integer indlld; real sgndef, mingma; extern doublereal slamch_(char *); integer oldien, oldncl, wbegin; real spdiam; integer negcnt, oldcls; real savgap; integer ndepth; real ssigma; logical usedbs; integer iindwk, offset; real gaptol; extern /* Subroutine */ int slarrb_(integer *, real *, real *, integer *, integer *, real *, real *, integer *, real *, real *, real *, real *, integer *, real *, real *, integer *, integer *), slarrf_( integer *, real *, real *, real *, integer *, integer *, real *, real *, real *, real *, real *, real *, real *, real *, real *, real *, real *, integer *); integer newcls, oldfst, indwrk, windex, oldlst; logical usedrq; integer newfst, newftt, parity, windmn, isupmn, newlst, windpl, zusedl, newsiz, zusedu, zusedw; real bstres, nrminv; logical tryrqc; integer isupmx; real rqcorr; extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, real *, real *, integer *); /* -- LAPACK auxiliary routine (version 3.1.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SLARRV computes the eigenvectors of the tridiagonal matrix */ /* T = L D L^T given L, D and APPROXIMATIONS to the eigenvalues of L D L^T. */ /* The input eigenvalues should have been computed by SLARRE. */ /* Arguments */ /* ========= */ /* N (input) INTEGER */ /* The order of the matrix. N >= 0. */ /* VL (input) REAL */ /* VU (input) REAL */ /* Lower and upper bounds of the interval that contains the desired */ /* eigenvalues. VL < VU. Needed to compute gaps on the left or right */ /* end of the extremal eigenvalues in the desired RANGE. */ /* D (input/output) REAL array, dimension (N) */ /* On entry, the N diagonal elements of the diagonal matrix D. */ /* On exit, D may be overwritten. */ /* L (input/output) REAL array, dimension (N) */ /* On entry, the (N-1) subdiagonal elements of the unit */ /* bidiagonal matrix L are in elements 1 to N-1 of L */ /* (if the matrix is not splitted.) At the end of each block */ /* is stored the corresponding shift as given by SLARRE. */ /* On exit, L is overwritten. */ /* PIVMIN (in) DOUBLE PRECISION */ /* The minimum pivot allowed in the Sturm sequence. */ /* ISPLIT (input) INTEGER array, dimension (N) */ /* The splitting points, at which T breaks up into blocks. */ /* The first block consists of rows/columns 1 to */ /* ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 */ /* through ISPLIT( 2 ), etc. */ /* M (input) INTEGER */ /* The total number of input eigenvalues. 0 <= M <= N. */ /* DOL (input) INTEGER */ /* DOU (input) INTEGER */ /* If the user wants to compute only selected eigenvectors from all */ /* the eigenvalues supplied, he can specify an index range DOL:DOU. */ /* Or else the setting DOL=1, DOU=M should be applied. */ /* Note that DOL and DOU refer to the order in which the eigenvalues */ /* are stored in W. */ /* If the user wants to compute only selected eigenpairs, then */ /* the columns DOL-1 to DOU+1 of the eigenvector space Z contain the */ /* computed eigenvectors. All other columns of Z are set to zero. */ /* MINRGP (input) REAL */ /* RTOL1 (input) REAL */ /* RTOL2 (input) REAL */ /* Parameters for bisection. */ /* An interval [LEFT,RIGHT] has converged if */ /* RIGHT-LEFT.LT.MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */ /* W (input/output) REAL array, dimension (N) */ /* The first M elements of W contain the APPROXIMATE eigenvalues for */ /* which eigenvectors are to be computed. The eigenvalues */ /* should be grouped by split-off block and ordered from */ /* smallest to largest within the block ( The output array */ /* W from SLARRE is expected here ). Furthermore, they are with */ /* respect to the shift of the corresponding root representation */ /* for their block. On exit, W holds the eigenvalues of the */ /* UNshifted matrix. */ /* WERR (input/output) REAL array, dimension (N) */ /* The first M elements contain the semiwidth of the uncertainty */ /* interval of the corresponding eigenvalue in W */ /* WGAP (input/output) REAL array, dimension (N) */ /* The separation from the right neighbor eigenvalue in W. */ /* IBLOCK (input) INTEGER array, dimension (N) */ /* The indices of the blocks (submatrices) associated with the */ /* corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */ /* W(i) belongs to the first block from the top, =2 if W(i) */ /* belongs to the second block, etc. */ /* INDEXW (input) INTEGER array, dimension (N) */ /* The indices of the eigenvalues within each block (submatrix); */ /* for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */ /* i-th eigenvalue W(i) is the 10-th eigenvalue in the second block. */ /* GERS (input) REAL array, dimension (2*N) */ /* The N Gerschgorin intervals (the i-th Gerschgorin interval */ /* is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should */ /* be computed from the original UNshifted matrix. */ /* Z (output) REAL array, dimension (LDZ, max(1,M) ) */ /* If INFO = 0, the first M columns of Z contain the */ /* orthonormal eigenvectors of the matrix T */ /* corresponding to the input eigenvalues, with the i-th */ /* column of Z holding the eigenvector associated with W(i). */ /* Note: the user must ensure that at least max(1,M) columns are */ /* supplied in the array Z. */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDZ >= 1, and if */ /* JOBZ = 'V', LDZ >= max(1,N). */ /* ISUPPZ (output) INTEGER array, dimension ( 2*max(1,M) ) */ /* The support of the eigenvectors in Z, i.e., the indices */ /* indicating the nonzero elements in Z. The I-th eigenvector */ /* is nonzero only in elements ISUPPZ( 2*I-1 ) through */ /* ISUPPZ( 2*I ). */ /* WORK (workspace) REAL array, dimension (12*N) */ /* IWORK (workspace) INTEGER array, dimension (7*N) */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* > 0: A problem occured in SLARRV. */ /* < 0: One of the called subroutines signaled an internal problem. */ /* Needs inspection of the corresponding parameter IINFO */ /* for further information. */ /* =-1: Problem in SLARRB when refining a child's eigenvalues. */ /* =-2: Problem in SLARRF when computing the RRR of a child. */ /* When a child is inside a tight cluster, it can be difficult */ /* to find an RRR. A partial remedy from the user's point of */ /* view is to make the parameter MINRGP smaller and recompile. */ /* However, as the orthogonality of the computed vectors is */ /* proportional to 1/MINRGP, the user should be aware that */ /* he might be trading in precision when he decreases MINRGP. */ /* =-3: Problem in SLARRB when refining a single eigenvalue */ /* after the Rayleigh correction was rejected. */ /* = 5: The Rayleigh Quotient Iteration failed to converge to */ /* full accuracy in MAXITR steps. */ /* Further Details */ /* =============== */ /* Based on contributions by */ /* Beresford Parlett, University of California, Berkeley, USA */ /* Jim Demmel, University of California, Berkeley, USA */ /* Inderjit Dhillon, University of Texas, Austin, USA */ /* Osni Marques, LBNL/NERSC, USA */ /* Christof Voemel, University of California, Berkeley, USA */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* .. */ /* The first N entries of WORK are reserved for the eigenvalues */ /* Parameter adjustments */ --d__; --l; --isplit; --w; --werr; --wgap; --iblock; --indexw; --gers; z_dim1 = *ldz; z_offset = 1 + z_dim1; z__ -= z_offset; --isuppz; --work; --iwork; /* Function Body */ indld = *n + 1; indlld = (*n << 1) + 1; indwrk = *n * 3 + 1; minwsize = *n * 12; i__1 = minwsize; for (i__ = 1; i__ <= i__1; ++i__) { work[i__] = 0.f; /* L5: */ } /* IWORK(IINDR+1:IINDR+N) hold the twist indices R for the */ /* factorization used to compute the FP vector */ iindr = 0; /* IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current */ /* layer and the one above. */ iindc1 = *n; iindc2 = *n << 1; iindwk = *n * 3 + 1; miniwsize = *n * 7; i__1 = miniwsize; for (i__ = 1; i__ <= i__1; ++i__) { iwork[i__] = 0; /* L10: */ } zusedl = 1; if (*dol > 1) { /* Set lower bound for use of Z */ zusedl = *dol - 1; } zusedu = *m; if (*dou < *m) { /* Set lower bound for use of Z */ zusedu = *dou + 1; } /* The width of the part of Z that is used */ zusedw = zusedu - zusedl + 1; slaset_("Full", n, &zusedw, &c_b5, &c_b5, &z__[zusedl * z_dim1 + 1], ldz); eps = slamch_("Precision"); rqtol = eps * 2.f; /* Set expert flags for standard code. */ tryrqc = TRUE_; if (*dol == 1 && *dou == *m) { } else { /* Only selected eigenpairs are computed. Since the other evalues */ /* are not refined by RQ iteration, bisection has to compute to full */ /* accuracy. */ *rtol1 = eps * 4.f; *rtol2 = eps * 4.f; } /* The entries WBEGIN:WEND in W, WERR, WGAP correspond to the */ /* desired eigenvalues. The support of the nonzero eigenvector */ /* entries is contained in the interval IBEGIN:IEND. */ /* Remark that if k eigenpairs are desired, then the eigenvectors */ /* are stored in k contiguous columns of Z. */ /* DONE is the number of eigenvectors already computed */ done = 0; ibegin = 1; wbegin = 1; i__1 = iblock[*m]; for (jblk = 1; jblk <= i__1; ++jblk) { iend = isplit[jblk]; sigma = l[iend]; /* Find the eigenvectors of the submatrix indexed IBEGIN */ /* through IEND. */ wend = wbegin - 1; L15: if (wend < *m) { if (iblock[wend + 1] == jblk) { ++wend; goto L15; } } if (wend < wbegin) { ibegin = iend + 1; goto L170; } else if (wend < *dol || wbegin > *dou) { ibegin = iend + 1; wbegin = wend + 1; goto L170; } /* Find local spectral diameter of the block */ gl = gers[(ibegin << 1) - 1]; gu = gers[ibegin * 2]; i__2 = iend; for (i__ = ibegin + 1; i__ <= i__2; ++i__) { /* Computing MIN */ r__1 = gers[(i__ << 1) - 1]; gl = dmin(r__1,gl); /* Computing MAX */ r__1 = gers[i__ * 2]; gu = dmax(r__1,gu); /* L20: */ } spdiam = gu - gl; /* OLDIEN is the last index of the previous block */ oldien = ibegin - 1; /* Calculate the size of the current block */ in = iend - ibegin + 1; /* The number of eigenvalues in the current block */ im = wend - wbegin + 1; /* This is for a 1x1 block */ if (ibegin == iend) { ++done; z__[ibegin + wbegin * z_dim1] = 1.f; isuppz[(wbegin << 1) - 1] = ibegin; isuppz[wbegin * 2] = ibegin; w[wbegin] += sigma; work[wbegin] = w[wbegin]; ibegin = iend + 1; ++wbegin; goto L170; } /* The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND) */ /* Note that these can be approximations, in this case, the corresp. */ /* entries of WERR give the size of the uncertainty interval. */ /* The eigenvalue approximations will be refined when necessary as */ /* high relative accuracy is required for the computation of the */ /* corresponding eigenvectors. */ scopy_(&im, &w[wbegin], &c__1, &work[wbegin], &c__1); /* We store in W the eigenvalue approximations w.r.t. the original */ /* matrix T. */ i__2 = im; for (i__ = 1; i__ <= i__2; ++i__) { w[wbegin + i__ - 1] += sigma; /* L30: */ } /* NDEPTH is the current depth of the representation tree */ ndepth = 0; /* PARITY is either 1 or 0 */ parity = 1; /* NCLUS is the number of clusters for the next level of the */ /* representation tree, we start with NCLUS = 1 for the root */ nclus = 1; iwork[iindc1 + 1] = 1; iwork[iindc1 + 2] = im; /* IDONE is the number of eigenvectors already computed in the current */ /* block */ idone = 0; /* loop while( IDONE.LT.IM ) */ /* generate the representation tree for the current block and */ /* compute the eigenvectors */ L40: if (idone < im) { /* This is a crude protection against infinitely deep trees */ if (ndepth > *m) { *info = -2; return 0; } /* breadth first processing of the current level of the representation */ /* tree: OLDNCL = number of clusters on current level */ oldncl = nclus; /* reset NCLUS to count the number of child clusters */ nclus = 0; parity = 1 - parity; if (parity == 0) { oldcls = iindc1; newcls = iindc2; } else { oldcls = iindc2; newcls = iindc1; } /* Process the clusters on the current level */ i__2 = oldncl; for (i__ = 1; i__ <= i__2; ++i__) { j = oldcls + (i__ << 1); /* OLDFST, OLDLST = first, last index of current cluster. */ /* cluster indices start with 1 and are relative */ /* to WBEGIN when accessing W, WGAP, WERR, Z */ oldfst = iwork[j - 1]; oldlst = iwork[j]; if (ndepth > 0) { /* Retrieve relatively robust representation (RRR) of cluster */ /* that has been computed at the previous level */ /* The RRR is stored in Z and overwritten once the eigenvectors */ /* have been computed or when the cluster is refined */ if (*dol == 1 && *dou == *m) { /* Get representation from location of the leftmost evalue */ /* of the cluster */ j = wbegin + oldfst - 1; } else { if (wbegin + oldfst - 1 < *dol) { /* Get representation from the left end of Z array */ j = *dol - 1; } else if (wbegin + oldfst - 1 > *dou) { /* Get representation from the right end of Z array */ j = *dou; } else { j = wbegin + oldfst - 1; } } scopy_(&in, &z__[ibegin + j * z_dim1], &c__1, &d__[ibegin] , &c__1); i__3 = in - 1; scopy_(&i__3, &z__[ibegin + (j + 1) * z_dim1], &c__1, &l[ ibegin], &c__1); sigma = z__[iend + (j + 1) * z_dim1]; /* Set the corresponding entries in Z to zero */ slaset_("Full", &in, &c__2, &c_b5, &c_b5, &z__[ibegin + j * z_dim1], ldz); } /* Compute DL and DLL of current RRR */ i__3 = iend - 1; for (j = ibegin; j <= i__3; ++j) { tmp = d__[j] * l[j]; work[indld - 1 + j] = tmp; work[indlld - 1 + j] = tmp * l[j]; /* L50: */ } if (ndepth > 0) { /* P and Q are index of the first and last eigenvalue to compute */ /* within the current block */ p = indexw[wbegin - 1 + oldfst]; q = indexw[wbegin - 1 + oldlst]; /* Offset for the arrays WORK, WGAP and WERR, i.e., th P-OFFSET */ /* thru' Q-OFFSET elements of these arrays are to be used. */ /* OFFSET = P-OLDFST */ offset = indexw[wbegin] - 1; /* perform limited bisection (if necessary) to get approximate */ /* eigenvalues to the precision needed. */ slarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p, &q, rtol1, rtol2, &offset, &work[wbegin], &wgap[ wbegin], &werr[wbegin], &work[indwrk], &iwork[ iindwk], pivmin, &spdiam, &in, &iinfo); if (iinfo != 0) { *info = -1; return 0; } /* We also recompute the extremal gaps. W holds all eigenvalues */ /* of the unshifted matrix and must be used for computation */ /* of WGAP, the entries of WORK might stem from RRRs with */ /* different shifts. The gaps from WBEGIN-1+OLDFST to */ /* WBEGIN-1+OLDLST are correctly computed in SLARRB. */ /* However, we only allow the gaps to become greater since */ /* this is what should happen when we decrease WERR */ if (oldfst > 1) { /* Computing MAX */ r__1 = wgap[wbegin + oldfst - 2], r__2 = w[wbegin + oldfst - 1] - werr[wbegin + oldfst - 1] - w[ wbegin + oldfst - 2] - werr[wbegin + oldfst - 2]; wgap[wbegin + oldfst - 2] = dmax(r__1,r__2); } if (wbegin + oldlst - 1 < wend) { /* Computing MAX */ r__1 = wgap[wbegin + oldlst - 1], r__2 = w[wbegin + oldlst] - werr[wbegin + oldlst] - w[wbegin + oldlst - 1] - werr[wbegin + oldlst - 1]; wgap[wbegin + oldlst - 1] = dmax(r__1,r__2); } /* Each time the eigenvalues in WORK get refined, we store */ /* the newly found approximation with all shifts applied in W */ i__3 = oldlst; for (j = oldfst; j <= i__3; ++j) { w[wbegin + j - 1] = work[wbegin + j - 1] + sigma; /* L53: */ } } /* Process the current node. */ newfst = oldfst; i__3 = oldlst; for (j = oldfst; j <= i__3; ++j) { if (j == oldlst) { /* we are at the right end of the cluster, this is also the */ /* boundary of the child cluster */ newlst = j; } else if (wgap[wbegin + j - 1] >= *minrgp * (r__1 = work[ wbegin + j - 1], dabs(r__1))) { /* the right relative gap is big enough, the child cluster */ /* (NEWFST,..,NEWLST) is well separated from the following */ newlst = j; } else { /* inside a child cluster, the relative gap is not */ /* big enough. */ goto L140; } /* Compute size of child cluster found */ newsiz = newlst - newfst + 1; /* NEWFTT is the place in Z where the new RRR or the computed */ /* eigenvector is to be stored */ if (*dol == 1 && *dou == *m) { /* Store representation at location of the leftmost evalue */ /* of the cluster */ newftt = wbegin + newfst - 1; } else { if (wbegin + newfst - 1 < *dol) { /* Store representation at the left end of Z array */ newftt = *dol - 1; } else if (wbegin + newfst - 1 > *dou) { /* Store representation at the right end of Z array */ newftt = *dou; } else { newftt = wbegin + newfst - 1; } } if (newsiz > 1) { /* Current child is not a singleton but a cluster. */ /* Compute and store new representation of child. */ /* Compute left and right cluster gap. */ /* LGAP and RGAP are not computed from WORK because */ /* the eigenvalue approximations may stem from RRRs */ /* different shifts. However, W hold all eigenvalues */ /* of the unshifted matrix. Still, the entries in WGAP */ /* have to be computed from WORK since the entries */ /* in W might be of the same order so that gaps are not */ /* exhibited correctly for very close eigenvalues. */ if (newfst == 1) { /* Computing MAX */ r__1 = 0.f, r__2 = w[wbegin] - werr[wbegin] - *vl; lgap = dmax(r__1,r__2); } else { lgap = wgap[wbegin + newfst - 2]; } rgap = wgap[wbegin + newlst - 1]; /* Compute left- and rightmost eigenvalue of child */ /* to high precision in order to shift as close */ /* as possible and obtain as large relative gaps */ /* as possible */ for (k = 1; k <= 2; ++k) { if (k == 1) { p = indexw[wbegin - 1 + newfst]; } else { p = indexw[wbegin - 1 + newlst]; } offset = indexw[wbegin] - 1; slarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p, &p, &rqtol, &rqtol, &offset, & work[wbegin], &wgap[wbegin], &werr[wbegin] , &work[indwrk], &iwork[iindwk], pivmin, & spdiam, &in, &iinfo); /* L55: */ } if (wbegin + newlst - 1 < *dol || wbegin + newfst - 1 > *dou) { /* if the cluster contains no desired eigenvalues */ /* skip the computation of that branch of the rep. tree */ /* We could skip before the refinement of the extremal */ /* eigenvalues of the child, but then the representation */ /* tree could be different from the one when nothing is */ /* skipped. For this reason we skip at this place. */ idone = idone + newlst - newfst + 1; goto L139; } /* Compute RRR of child cluster. */ /* Note that the new RRR is stored in Z */ /* SLARRF needs LWORK = 2*N */ slarrf_(&in, &d__[ibegin], &l[ibegin], &work[indld + ibegin - 1], &newfst, &newlst, &work[wbegin], &wgap[wbegin], &werr[wbegin], &spdiam, &lgap, &rgap, pivmin, &tau, &z__[ibegin + newftt * z_dim1], &z__[ibegin + (newftt + 1) * z_dim1], &work[indwrk], &iinfo); if (iinfo == 0) { /* a new RRR for the cluster was found by SLARRF */ /* update shift and store it */ ssigma = sigma + tau; z__[iend + (newftt + 1) * z_dim1] = ssigma; /* WORK() are the midpoints and WERR() the semi-width */ /* Note that the entries in W are unchanged. */ i__4 = newlst; for (k = newfst; k <= i__4; ++k) { fudge = eps * 3.f * (r__1 = work[wbegin + k - 1], dabs(r__1)); work[wbegin + k - 1] -= tau; fudge += eps * 4.f * (r__1 = work[wbegin + k - 1], dabs(r__1)); /* Fudge errors */ werr[wbegin + k - 1] += fudge; /* Gaps are not fudged. Provided that WERR is small */ /* when eigenvalues are close, a zero gap indicates */ /* that a new representation is needed for resolving */ /* the cluster. A fudge could lead to a wrong decision */ /* of judging eigenvalues 'separated' which in */ /* reality are not. This could have a negative impact */ /* on the orthogonality of the computed eigenvectors. */ /* L116: */ } ++nclus; k = newcls + (nclus << 1); iwork[k - 1] = newfst; iwork[k] = newlst; } else { *info = -2; return 0; } } else { /* Compute eigenvector of singleton */ iter = 0; tol = log((real) in) * 4.f * eps; k = newfst; windex = wbegin + k - 1; /* Computing MAX */ i__4 = windex - 1; windmn = max(i__4,1); /* Computing MIN */ i__4 = windex + 1; windpl = min(i__4,*m); lambda = work[windex]; ++done; /* Check if eigenvector computation is to be skipped */ if (windex < *dol || windex > *dou) { eskip = TRUE_; goto L125; } else { eskip = FALSE_; } left = work[windex] - werr[windex]; right = work[windex] + werr[windex]; indeig = indexw[windex]; /* Note that since we compute the eigenpairs for a child, */ /* all eigenvalue approximations are w.r.t the same shift. */ /* In this case, the entries in WORK should be used for */ /* computing the gaps since they exhibit even very small */ /* differences in the eigenvalues, as opposed to the */ /* entries in W which might "look" the same. */ if (k == 1) { /* In the case RANGE='I' and with not much initial */ /* accuracy in LAMBDA and VL, the formula */ /* LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA ) */ /* can lead to an overestimation of the left gap and */ /* thus to inadequately early RQI 'convergence'. */ /* Prevent this by forcing a small left gap. */ /* Computing MAX */ r__1 = dabs(left), r__2 = dabs(right); lgap = eps * dmax(r__1,r__2); } else { lgap = wgap[windmn]; } if (k == im) { /* In the case RANGE='I' and with not much initial */ /* accuracy in LAMBDA and VU, the formula */ /* can lead to an overestimation of the right gap and */ /* thus to inadequately early RQI 'convergence'. */ /* Prevent this by forcing a small right gap. */ /* Computing MAX */ r__1 = dabs(left), r__2 = dabs(right); rgap = eps * dmax(r__1,r__2); } else { rgap = wgap[windex]; } gap = dmin(lgap,rgap); if (k == 1 || k == im) { /* The eigenvector support can become wrong */ /* because significant entries could be cut off due to a */ /* large GAPTOL parameter in LAR1V. Prevent this. */ gaptol = 0.f; } else { gaptol = gap * eps; } isupmn = in; isupmx = 1; /* Update WGAP so that it holds the minimum gap */ /* to the left or the right. This is crucial in the */ /* case where bisection is used to ensure that the */ /* eigenvalue is refined up to the required precision. */ /* The correct value is restored afterwards. */ savgap = wgap[windex]; wgap[windex] = gap; /* We want to use the Rayleigh Quotient Correction */ /* as often as possible since it converges quadratically */ /* when we are close enough to the desired eigenvalue. */ /* However, the Rayleigh Quotient can have the wrong sign */ /* and lead us away from the desired eigenvalue. In this */ /* case, the best we can do is to use bisection. */ usedbs = FALSE_; usedrq = FALSE_; /* Bisection is initially turned off unless it is forced */ needbs = ! tryrqc; L120: /* Check if bisection should be used to refine eigenvalue */ if (needbs) { /* Take the bisection as new iterate */ usedbs = TRUE_; itmp1 = iwork[iindr + windex]; offset = indexw[wbegin] - 1; r__1 = eps * 2.f; slarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &indeig, &indeig, &c_b5, &r__1, & offset, &work[wbegin], &wgap[wbegin], & werr[wbegin], &work[indwrk], &iwork[ iindwk], pivmin, &spdiam, &itmp1, &iinfo); if (iinfo != 0) { *info = -3; return 0; } lambda = work[windex]; /* Reset twist index from inaccurate LAMBDA to */ /* force computation of true MINGMA */ iwork[iindr + windex] = 0; } /* Given LAMBDA, compute the eigenvector. */ L__1 = ! usedbs; slar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], &l[ ibegin], &work[indld + ibegin - 1], &work[ indlld + ibegin - 1], pivmin, &gaptol, &z__[ ibegin + windex * z_dim1], &L__1, &negcnt, & ztz, &mingma, &iwork[iindr + windex], &isuppz[ (windex << 1) - 1], &nrminv, &resid, &rqcorr, &work[indwrk]); if (iter == 0) { bstres = resid; bstw = lambda; } else if (resid < bstres) { bstres = resid; bstw = lambda; } /* Computing MIN */ i__4 = isupmn, i__5 = isuppz[(windex << 1) - 1]; isupmn = min(i__4,i__5); /* Computing MAX */ i__4 = isupmx, i__5 = isuppz[windex * 2]; isupmx = max(i__4,i__5); ++iter; /* sin alpha <= |resid|/gap */ /* Note that both the residual and the gap are */ /* proportional to the matrix, so ||T|| doesn't play */ /* a role in the quotient */ /* Convergence test for Rayleigh-Quotient iteration */ /* (omitted when Bisection has been used) */ if (resid > tol * gap && dabs(rqcorr) > rqtol * dabs( lambda) && ! usedbs) { /* We need to check that the RQCORR update doesn't */ /* move the eigenvalue away from the desired one and */ /* towards a neighbor. -> protection with bisection */ if (indeig <= negcnt) { /* The wanted eigenvalue lies to the left */ sgndef = -1.f; } else { /* The wanted eigenvalue lies to the right */ sgndef = 1.f; } /* We only use the RQCORR if it improves the */ /* the iterate reasonably. */ if (rqcorr * sgndef >= 0.f && lambda + rqcorr <= right && lambda + rqcorr >= left) { usedrq = TRUE_; /* Store new midpoint of bisection interval in WORK */ if (sgndef == 1.f) { /* The current LAMBDA is on the left of the true */ /* eigenvalue */ left = lambda; /* We prefer to assume that the error estimate */ /* is correct. We could make the interval not */ /* as a bracket but to be modified if the RQCORR */ /* chooses to. In this case, the RIGHT side should */ /* be modified as follows: */ /* RIGHT = MAX(RIGHT, LAMBDA + RQCORR) */ } else { /* The current LAMBDA is on the right of the true */ /* eigenvalue */ right = lambda; /* See comment about assuming the error estimate is */ /* correct above. */ /* LEFT = MIN(LEFT, LAMBDA + RQCORR) */ } work[windex] = (right + left) * .5f; /* Take RQCORR since it has the correct sign and */ /* improves the iterate reasonably */ lambda += rqcorr; /* Update width of error interval */ werr[windex] = (right - left) * .5f; } else { needbs = TRUE_; } if (right - left < rqtol * dabs(lambda)) { /* The eigenvalue is computed to bisection accuracy */ /* compute eigenvector and stop */ usedbs = TRUE_; goto L120; } else if (iter < 10) { goto L120; } else if (iter == 10) { needbs = TRUE_; goto L120; } else { *info = 5; return 0; } } else { stp2ii = FALSE_; if (usedrq && usedbs && bstres <= resid) { lambda = bstw; stp2ii = TRUE_; } if (stp2ii) { /* improve error angle by second step */ L__1 = ! usedbs; slar1v_(&in, &c__1, &in, &lambda, &d__[ibegin] , &l[ibegin], &work[indld + ibegin - 1], &work[indlld + ibegin - 1], pivmin, &gaptol, &z__[ibegin + windex * z_dim1], &L__1, &negcnt, &ztz, & mingma, &iwork[iindr + windex], & isuppz[(windex << 1) - 1], &nrminv, & resid, &rqcorr, &work[indwrk]); } work[windex] = lambda; } /* Compute FP-vector support w.r.t. whole matrix */ isuppz[(windex << 1) - 1] += oldien; isuppz[windex * 2] += oldien; zfrom = isuppz[(windex << 1) - 1]; zto = isuppz[windex * 2]; isupmn += oldien; isupmx += oldien; /* Ensure vector is ok if support in the RQI has changed */ if (isupmn < zfrom) { i__4 = zfrom - 1; for (ii = isupmn; ii <= i__4; ++ii) { z__[ii + windex * z_dim1] = 0.f; /* L122: */ } } if (isupmx > zto) { i__4 = isupmx; for (ii = zto + 1; ii <= i__4; ++ii) { z__[ii + windex * z_dim1] = 0.f; /* L123: */ } } i__4 = zto - zfrom + 1; sscal_(&i__4, &nrminv, &z__[zfrom + windex * z_dim1], &c__1); L125: /* Update W */ w[windex] = lambda + sigma; /* Recompute the gaps on the left and right */ /* But only allow them to become larger and not */ /* smaller (which can only happen through "bad" */ /* cancellation and doesn't reflect the theory */ /* where the initial gaps are underestimated due */ /* to WERR being too crude.) */ if (! eskip) { if (k > 1) { /* Computing MAX */ r__1 = wgap[windmn], r__2 = w[windex] - werr[ windex] - w[windmn] - werr[windmn]; wgap[windmn] = dmax(r__1,r__2); } if (windex < wend) { /* Computing MAX */ r__1 = savgap, r__2 = w[windpl] - werr[windpl] - w[windex] - werr[windex]; wgap[windex] = dmax(r__1,r__2); } } ++idone; } /* here ends the code for the current child */ L139: /* Proceed to any remaining child nodes */ newfst = j + 1; L140: ; } /* L150: */ } ++ndepth; goto L40; } ibegin = iend + 1; wbegin = wend + 1; L170: ; } return 0; /* End of SLARRV */ } /* slarrv_ */
/* Subroutine */ int slarrv_(integer *n, real *d__, real *l, integer *isplit, integer *m, real *w, integer *iblock, real *gersch, real *tol, real * z__, integer *ldz, integer *isuppz, real *work, integer *iwork, integer *info) { /* System generated locals */ integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5, i__6; real r__1, r__2; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ static integer iend, jblk, iter, temp[1]; extern doublereal sdot_(integer *, real *, integer *, real *, integer *); static integer ktot, itmp1, itmp2; extern doublereal snrm2_(integer *, real *, integer *); static integer i__, j, k, p, q, indld; static real sigma; static integer ndone, iinfo, iindr; static real resid; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); static integer nclus; extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, integer *), saxpy_(integer *, real *, real *, integer *, real *, integer *); static integer iindc1, iindc2; extern /* Subroutine */ int slar1v_(integer *, integer *, integer *, real *, real *, real *, real *, real *, real *, real *, real *, real *, integer *, integer *, real *); static real lambda; static integer im, in, ibegin, indgap, indlld; extern doublereal slamch_(char *); static real mingma; static integer oldien, oldncl; static real relgap; static integer oldcls, ndepth, inderr, iindwk; extern /* Subroutine */ int slarrb_(integer *, real *, real *, real *, real *, integer *, integer *, real *, real *, real *, real *, real *, real *, integer *, integer *); static logical mgscls; static integer lsbdpt; extern /* Subroutine */ int slarrf_(integer *, real *, real *, real *, real *, integer *, integer *, real *, real *, real *, real *, integer *, integer *); static integer newcls, oldfst; static real minrgp; static integer indwrk; extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, real *, real *, integer *); static integer oldlst; static real reltol; static integer maxitr, newfrs, newftt; static real mgstol; static integer nsplit; static real nrminv; static integer newlst; static real rqcorr; static integer newsiz; extern /* Subroutine */ int sstein_(integer *, real *, real *, integer *, real *, integer *, integer *, real *, integer *, real *, integer * , integer *, integer *); static real gap, eps, ztz, tmp1; #define z___ref(a_1,a_2) z__[(a_2)*z_dim1 + a_1] /* -- LAPACK auxiliary routine (instru to count ops, version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University June 30, 1999 Common block to return operation count Purpose ======= SLARRV computes the eigenvectors of the tridiagonal matrix T = L D L^T given L, D and the eigenvalues of L D L^T. The input eigenvalues should have high relative accuracy with respect to the entries of L and D. The desired accuracy of the output can be specified by the input parameter TOL. Arguments ========= N (input) INTEGER The order of the matrix. N >= 0. D (input/output) REAL array, dimension (N) On entry, the n diagonal elements of the diagonal matrix D. On exit, D may be overwritten. L (input/output) REAL array, dimension (N-1) On entry, the (n-1) subdiagonal elements of the unit bidiagonal matrix L in elements 1 to N-1 of L. L(N) need not be set. On exit, L is overwritten. ISPLIT (input) INTEGER array, dimension (N) The splitting points, at which T breaks up into submatrices. The first submatrix consists of rows/columns 1 to ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 through ISPLIT( 2 ), etc. TOL (input) REAL The absolute error tolerance for the eigenvalues/eigenvectors. Errors in the input eigenvalues must be bounded by TOL. The eigenvectors output have residual norms bounded by TOL, and the dot products between different eigenvectors are bounded by TOL. TOL must be at least N*EPS*|T|, where EPS is the machine precision and |T| is the 1-norm of the tridiagonal matrix. M (input) INTEGER The total number of eigenvalues found. 0 <= M <= N. If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. W (input) REAL array, dimension (N) The first M elements of W contain the eigenvalues for which eigenvectors are to be computed. The eigenvalues should be grouped by split-off block and ordered from smallest to largest within the block ( The output array W from SLARRE is expected here ). Errors in W must be bounded by TOL (see above). IBLOCK (input) INTEGER array, dimension (N) The submatrix indices associated with the corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to the first submatrix from the top, =2 if W(i) belongs to the second submatrix, etc. Z (output) REAL array, dimension (LDZ, max(1,M) ) If JOBZ = 'V', then if INFO = 0, the first M columns of Z contain the orthonormal eigenvectors of the matrix T corresponding to the selected eigenvalues, with the i-th column of Z holding the eigenvector associated with W(i). If JOBZ = 'N', then Z is not referenced. Note: the user must ensure that at least max(1,M) columns are supplied in the array Z; if RANGE = 'V', the exact value of M is not known in advance and an upper bound must be used. LDZ (input) INTEGER The leading dimension of the array Z. LDZ >= 1, and if JOBZ = 'V', LDZ >= max(1,N). ISUPPZ (output) INTEGER ARRAY, dimension ( 2*max(1,M) ) The support of the eigenvectors in Z, i.e., the indices indicating the nonzero elements in Z. The i-th eigenvector is nonzero only in elements ISUPPZ( 2*i-1 ) through ISUPPZ( 2*i ). WORK (workspace) REAL array, dimension (13*N) IWORK (workspace) INTEGER array, dimension (6*N) INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = 1, internal error in SLARRB if INFO = 2, internal error in SSTEIN Further Details =============== Based on contributions by Inderjit Dhillon, IBM Almaden, USA Osni Marques, LBNL/NERSC, USA Ken Stanley, Computer Science Division, University of California at Berkeley, USA ===================================================================== Test the input parameters. Parameter adjustments */ --d__; --l; --isplit; --w; --iblock; --gersch; z_dim1 = *ldz; z_offset = 1 + z_dim1 * 1; z__ -= z_offset; --isuppz; --work; --iwork; /* Function Body */ inderr = *n + 1; indld = *n << 1; indlld = *n * 3; indgap = *n << 2; indwrk = *n * 5 + 1; iindr = *n; iindc1 = *n << 1; iindc2 = *n * 3; iindwk = (*n << 2) + 1; eps = slamch_("Precision"); i__1 = *n << 1; for (i__ = 1; i__ <= i__1; ++i__) { iwork[i__] = 0; /* L10: */ } latime_1.ops += (real) (*m + 1); i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { work[inderr + i__ - 1] = eps * (r__1 = w[i__], dabs(r__1)); /* L20: */ } slaset_("Full", n, n, &c_b6, &c_b6, &z__[z_offset], ldz); mgstol = eps * 5.f; nsplit = iblock[*m]; ibegin = 1; i__1 = nsplit; for (jblk = 1; jblk <= i__1; ++jblk) { iend = isplit[jblk]; /* Find the eigenvectors of the submatrix indexed IBEGIN through IEND. */ if (ibegin == iend) { z___ref(ibegin, ibegin) = 1.f; isuppz[(ibegin << 1) - 1] = ibegin; isuppz[ibegin * 2] = ibegin; ibegin = iend + 1; goto L170; } oldien = ibegin - 1; in = iend - oldien; latime_1.ops += 1.f; /* Computing MIN */ r__1 = .01f, r__2 = 1.f / (real) in; reltol = dmin(r__1,r__2); im = in; scopy_(&im, &w[ibegin], &c__1, &work[1], &c__1); latime_1.ops += (real) (in - 1); i__2 = in - 1; for (i__ = 1; i__ <= i__2; ++i__) { work[indgap + i__] = work[i__ + 1] - work[i__]; /* L30: */ } /* Computing MAX */ r__2 = (r__1 = work[in], dabs(r__1)); work[indgap + in] = dmax(r__2,eps); ndone = 0; ndepth = 0; lsbdpt = 1; nclus = 1; iwork[iindc1 + 1] = 1; iwork[iindc1 + 2] = in; /* While( NDONE.LT.IM ) do */ L40: if (ndone < im) { oldncl = nclus; nclus = 0; lsbdpt = 1 - lsbdpt; i__2 = oldncl; for (i__ = 1; i__ <= i__2; ++i__) { if (lsbdpt == 0) { oldcls = iindc1; newcls = iindc2; } else { oldcls = iindc2; newcls = iindc1; } /* If NDEPTH > 1, retrieve the relatively robust representation (RRR) and perform limited bisection (if necessary) to get approximate eigenvalues. */ j = oldcls + (i__ << 1); oldfst = iwork[j - 1]; oldlst = iwork[j]; if (ndepth > 0) { j = oldien + oldfst; scopy_(&in, &z___ref(ibegin, j), &c__1, &d__[ibegin], & c__1); scopy_(&in, &z___ref(ibegin, j + 1), &c__1, &l[ibegin], & c__1); sigma = l[iend]; } k = ibegin; latime_1.ops += (real) (in - 1 << 1); i__3 = in - 1; for (j = 1; j <= i__3; ++j) { work[indld + j] = d__[k] * l[k]; work[indlld + j] = work[indld + j] * l[k]; ++k; /* L50: */ } if (ndepth > 0) { slarrb_(&in, &d__[ibegin], &l[ibegin], &work[indld + 1], & work[indlld + 1], &oldfst, &oldlst, &sigma, & reltol, &work[1], &work[indgap + 1], &work[inderr] , &work[indwrk], &iwork[iindwk], &iinfo); if (iinfo != 0) { *info = 1; return 0; } } /* Classify eigenvalues of the current representation (RRR) as (i) isolated, (ii) loosely clustered or (iii) tightly clustered */ newfrs = oldfst; i__3 = oldlst; for (j = oldfst; j <= i__3; ++j) { latime_1.ops += 1.f; if (j == oldlst || work[indgap + j] >= reltol * (r__1 = work[j], dabs(r__1))) { newlst = j; } else { /* continue (to the next loop) */ latime_1.ops += 1.f; relgap = work[indgap + j] / (r__1 = work[j], dabs( r__1)); if (j == newfrs) { minrgp = relgap; } else { minrgp = dmin(minrgp,relgap); } goto L140; } newsiz = newlst - newfrs + 1; maxitr = 10; newftt = oldien + newfrs; if (newsiz > 1) { mgscls = newsiz <= 20 && minrgp >= mgstol; if (! mgscls) { slarrf_(&in, &d__[ibegin], &l[ibegin], &work[ indld + 1], &work[indlld + 1], &newfrs, & newlst, &work[1], &z___ref(ibegin, newftt) , &z___ref(ibegin, newftt + 1), &work[ indwrk], &iwork[iindwk], info); if (*info == 0) { ++nclus; k = newcls + (nclus << 1); iwork[k - 1] = newfrs; iwork[k] = newlst; } else { *info = 0; if (minrgp >= mgstol) { mgscls = TRUE_; } else { /* Call SSTEIN to process this tight cluster. This happens only if MINRGP <= MGSTOL and SLARRF returns INFO = 1. The latter means that a new RRR to "break" the cluster could not be found. */ work[indwrk] = d__[ibegin]; latime_1.ops += (real) (in - 1); i__4 = in - 1; for (k = 1; k <= i__4; ++k) { work[indwrk + k] = d__[ibegin + k] + work[indlld + k]; /* L60: */ } i__4 = newsiz; for (k = 1; k <= i__4; ++k) { iwork[iindwk + k - 1] = 1; /* L70: */ } i__4 = newlst; for (k = newfrs; k <= i__4; ++k) { isuppz[(ibegin + k << 1) - 3] = 1; isuppz[(ibegin + k << 1) - 2] = in; /* L80: */ } temp[0] = in; sstein_(&in, &work[indwrk], &work[indld + 1], &newsiz, &work[newfrs], & iwork[iindwk], temp, &z___ref( ibegin, newftt), ldz, &work[ indwrk + in], &iwork[iindwk + in], &iwork[iindwk + (in << 1)], & iinfo); if (iinfo != 0) { *info = 2; return 0; } ndone += newsiz; } } } } else { mgscls = FALSE_; } if (newsiz == 1 || mgscls) { ktot = newftt; i__4 = newlst; for (k = newfrs; k <= i__4; ++k) { iter = 0; L90: lambda = work[k]; slar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], & l[ibegin], &work[indld + 1], &work[indlld + 1], &gersch[(oldien << 1) + 1], & z___ref(ibegin, ktot), &ztz, &mingma, & iwork[iindr + ktot], &isuppz[(ktot << 1) - 1], &work[indwrk]); latime_1.ops += 4.f; tmp1 = 1.f / ztz; nrminv = sqrt(tmp1); resid = dabs(mingma) * nrminv; rqcorr = mingma * tmp1; if (k == in) { gap = work[indgap + k - 1]; } else if (k == 1) { gap = work[indgap + k]; } else { /* Computing MIN */ r__1 = work[indgap + k - 1], r__2 = work[ indgap + k]; gap = dmin(r__1,r__2); } ++iter; latime_1.ops += 3.f; if (resid > *tol * gap && dabs(rqcorr) > eps * 4.f * dabs(lambda)) { latime_1.ops += 1.f; work[k] = lambda + rqcorr; if (iter < maxitr) { goto L90; } } iwork[ktot] = 1; if (newsiz == 1) { ++ndone; } latime_1.ops += (real) in; sscal_(&in, &nrminv, &z___ref(ibegin, ktot), & c__1); ++ktot; /* L100: */ } if (newsiz > 1) { itmp1 = isuppz[(newftt << 1) - 1]; itmp2 = isuppz[newftt * 2]; ktot = oldien + newlst; i__4 = ktot; for (p = newftt + 1; p <= i__4; ++p) { i__5 = p - 1; for (q = newftt; q <= i__5; ++q) { latime_1.ops += (real) (in << 2); tmp1 = -sdot_(&in, &z___ref(ibegin, p), & c__1, &z___ref(ibegin, q), &c__1); saxpy_(&in, &tmp1, &z___ref(ibegin, q), & c__1, &z___ref(ibegin, p), &c__1); /* L110: */ } latime_1.ops += (real) (in * 3 + 1); tmp1 = 1.f / snrm2_(&in, &z___ref(ibegin, p), &c__1); sscal_(&in, &tmp1, &z___ref(ibegin, p), &c__1) ; /* Computing MIN */ i__5 = itmp1, i__6 = isuppz[(p << 1) - 1]; itmp1 = min(i__5,i__6); /* Computing MAX */ i__5 = itmp2, i__6 = isuppz[p * 2]; itmp2 = max(i__5,i__6); /* L120: */ } i__4 = ktot; for (p = newftt; p <= i__4; ++p) { isuppz[(p << 1) - 1] = itmp1; isuppz[p * 2] = itmp2; /* L130: */ } ndone += newsiz; } } newfrs = j + 1; L140: ; } /* L150: */ } ++ndepth; goto L40; } j = ibegin << 1; i__2 = iend; for (i__ = ibegin; i__ <= i__2; ++i__) { isuppz[j - 1] += oldien; isuppz[j] += oldien; j += 2; /* L160: */ } ibegin = iend + 1; L170: ; } return 0; /* End of SLARRV */ } /* slarrv_ */