LAPACK 3.3.1 Linear Algebra PACKage

# dlarrv.f

Go to the documentation of this file.
```00001       SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
00002      \$                   ISPLIT, M, DOL, DOU, MINRGP,
00003      \$                   RTOL1, RTOL2, W, WERR, WGAP,
00004      \$                   IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ,
00005      \$                   WORK, IWORK, INFO )
00006 *
00007 *  -- LAPACK auxiliary routine (version 3.3.1) --
00008 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00009 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00010 *  -- April 2011                                                      --
00011 *
00012 *     .. Scalar Arguments ..
00013       INTEGER            DOL, DOU, INFO, LDZ, M, N
00014       DOUBLE PRECISION   MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU
00015 *     ..
00016 *     .. Array Arguments ..
00017       INTEGER            IBLOCK( * ), INDEXW( * ), ISPLIT( * ),
00018      \$                   ISUPPZ( * ), IWORK( * )
00019       DOUBLE PRECISION   D( * ), GERS( * ), L( * ), W( * ), WERR( * ),
00020      \$                   WGAP( * ), WORK( * )
00021       DOUBLE PRECISION  Z( LDZ, * )
00022 *     ..
00023 *
00024 *  Purpose
00025 *  =======
00026 *
00027 *  DLARRV computes the eigenvectors of the tridiagonal matrix
00028 *  T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T.
00029 *  The input eigenvalues should have been computed by DLARRE.
00030 *
00031 *  Arguments
00032 *  =========
00033 *
00034 *  N       (input) INTEGER
00035 *          The order of the matrix.  N >= 0.
00036 *
00037 *  VL      (input) DOUBLE PRECISION
00038 *  VU      (input) DOUBLE PRECISION
00039 *          Lower and upper bounds of the interval that contains the desired
00040 *          eigenvalues. VL < VU. Needed to compute gaps on the left or right
00041 *          end of the extremal eigenvalues in the desired RANGE.
00042 *
00043 *  D       (input/output) DOUBLE PRECISION array, dimension (N)
00044 *          On entry, the N diagonal elements of the diagonal matrix D.
00045 *          On exit, D may be overwritten.
00046 *
00047 *  L       (input/output) DOUBLE PRECISION array, dimension (N)
00048 *          On entry, the (N-1) subdiagonal elements of the unit
00049 *          bidiagonal matrix L are in elements 1 to N-1 of L
00050 *          (if the matrix is not splitted.) At the end of each block
00051 *          is stored the corresponding shift as given by DLARRE.
00052 *          On exit, L is overwritten.
00053 *
00054 *  PIVMIN  (input) DOUBLE PRECISION
00055 *          The minimum pivot allowed in the Sturm sequence.
00056 *
00057 *  ISPLIT  (input) INTEGER array, dimension (N)
00058 *          The splitting points, at which T breaks up into blocks.
00059 *          The first block consists of rows/columns 1 to
00060 *          ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
00061 *          through ISPLIT( 2 ), etc.
00062 *
00063 *  M       (input) INTEGER
00064 *          The total number of input eigenvalues.  0 <= M <= N.
00065 *
00066 *  DOL     (input) INTEGER
00067 *  DOU     (input) INTEGER
00068 *          If the user wants to compute only selected eigenvectors from all
00069 *          the eigenvalues supplied, he can specify an index range DOL:DOU.
00070 *          Or else the setting DOL=1, DOU=M should be applied.
00071 *          Note that DOL and DOU refer to the order in which the eigenvalues
00072 *          are stored in W.
00073 *          If the user wants to compute only selected eigenpairs, then
00074 *          the columns DOL-1 to DOU+1 of the eigenvector space Z contain the
00075 *          computed eigenvectors. All other columns of Z are set to zero.
00076 *
00077 *  MINRGP  (input) DOUBLE PRECISION
00078 *
00079 *  RTOL1   (input) DOUBLE PRECISION
00080 *  RTOL2   (input) DOUBLE PRECISION
00081 *           Parameters for bisection.
00082 *           An interval [LEFT,RIGHT] has converged if
00083 *           RIGHT-LEFT.LT.MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) )
00084 *
00085 *  W       (input/output) DOUBLE PRECISION array, dimension (N)
00086 *          The first M elements of W contain the APPROXIMATE eigenvalues for
00087 *          which eigenvectors are to be computed.  The eigenvalues
00088 *          should be grouped by split-off block and ordered from
00089 *          smallest to largest within the block ( The output array
00090 *          W from DLARRE is expected here ). Furthermore, they are with
00091 *          respect to the shift of the corresponding root representation
00092 *          for their block. On exit, W holds the eigenvalues of the
00093 *          UNshifted matrix.
00094 *
00095 *  WERR    (input/output) DOUBLE PRECISION array, dimension (N)
00096 *          The first M elements contain the semiwidth of the uncertainty
00097 *          interval of the corresponding eigenvalue in W
00098 *
00099 *  WGAP    (input/output) DOUBLE PRECISION array, dimension (N)
00100 *          The separation from the right neighbor eigenvalue in W.
00101 *
00102 *  IBLOCK  (input) INTEGER array, dimension (N)
00103 *          The indices of the blocks (submatrices) associated with the
00104 *          corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue
00105 *          W(i) belongs to the first block from the top, =2 if W(i)
00106 *          belongs to the second block, etc.
00107 *
00108 *  INDEXW  (input) INTEGER array, dimension (N)
00109 *          The indices of the eigenvalues within each block (submatrix);
00110 *          for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the
00111 *          i-th eigenvalue W(i) is the 10-th eigenvalue in the second block.
00112 *
00113 *  GERS    (input) DOUBLE PRECISION array, dimension (2*N)
00114 *          The N Gerschgorin intervals (the i-th Gerschgorin interval
00115 *          is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should
00116 *          be computed from the original UNshifted matrix.
00117 *
00118 *  Z       (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
00119 *          If INFO = 0, the first M columns of Z contain the
00120 *          orthonormal eigenvectors of the matrix T
00121 *          corresponding to the input eigenvalues, with the i-th
00122 *          column of Z holding the eigenvector associated with W(i).
00123 *          Note: the user must ensure that at least max(1,M) columns are
00124 *          supplied in the array Z.
00125 *
00126 *  LDZ     (input) INTEGER
00127 *          The leading dimension of the array Z.  LDZ >= 1, and if
00128 *          JOBZ = 'V', LDZ >= max(1,N).
00129 *
00130 *  ISUPPZ  (output) INTEGER array, dimension ( 2*max(1,M) )
00131 *          The support of the eigenvectors in Z, i.e., the indices
00132 *          indicating the nonzero elements in Z. The I-th eigenvector
00133 *          is nonzero only in elements ISUPPZ( 2*I-1 ) through
00134 *          ISUPPZ( 2*I ).
00135 *
00136 *  WORK    (workspace) DOUBLE PRECISION array, dimension (12*N)
00137 *
00138 *  IWORK   (workspace) INTEGER array, dimension (7*N)
00139 *
00140 *  INFO    (output) INTEGER
00141 *          = 0:  successful exit
00142 *
00143 *          > 0:  A problem occured in DLARRV.
00144 *          < 0:  One of the called subroutines signaled an internal problem.
00145 *                Needs inspection of the corresponding parameter IINFO
00146 *                for further information.
00147 *
00148 *          =-1:  Problem in DLARRB when refining a child's eigenvalues.
00149 *          =-2:  Problem in DLARRF when computing the RRR of a child.
00150 *                When a child is inside a tight cluster, it can be difficult
00151 *                to find an RRR. A partial remedy from the user's point of
00152 *                view is to make the parameter MINRGP smaller and recompile.
00153 *                However, as the orthogonality of the computed vectors is
00154 *                proportional to 1/MINRGP, the user should be aware that
00155 *                he might be trading in precision when he decreases MINRGP.
00156 *          =-3:  Problem in DLARRB when refining a single eigenvalue
00157 *                after the Rayleigh correction was rejected.
00158 *          = 5:  The Rayleigh Quotient Iteration failed to converge to
00159 *                full accuracy in MAXITR steps.
00160 *
00161 *  Further Details
00162 *  ===============
00163 *
00164 *  Based on contributions by
00165 *     Beresford Parlett, University of California, Berkeley, USA
00166 *     Jim Demmel, University of California, Berkeley, USA
00167 *     Inderjit Dhillon, University of Texas, Austin, USA
00168 *     Osni Marques, LBNL/NERSC, USA
00169 *     Christof Voemel, University of California, Berkeley, USA
00170 *
00171 *  =====================================================================
00172 *
00173 *     .. Parameters ..
00174       INTEGER            MAXITR
00175       PARAMETER          ( MAXITR = 10 )
00176       DOUBLE PRECISION   ZERO, ONE, TWO, THREE, FOUR, HALF
00177       PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0,
00178      \$                     TWO = 2.0D0, THREE = 3.0D0,
00179      \$                     FOUR = 4.0D0, HALF = 0.5D0)
00180 *     ..
00181 *     .. Local Scalars ..
00182       LOGICAL            ESKIP, NEEDBS, STP2II, TRYRQC, USEDBS, USEDRQ
00183       INTEGER            DONE, I, IBEGIN, IDONE, IEND, II, IINDC1,
00184      \$                   IINDC2, IINDR, IINDWK, IINFO, IM, IN, INDEIG,
00185      \$                   INDLD, INDLLD, INDWRK, ISUPMN, ISUPMX, ITER,
00186      \$                   ITMP1, J, JBLK, K, MINIWSIZE, MINWSIZE, NCLUS,
00187      \$                   NDEPTH, NEGCNT, NEWCLS, NEWFST, NEWFTT, NEWLST,
00188      \$                   NEWSIZ, OFFSET, OLDCLS, OLDFST, OLDIEN, OLDLST,
00189      \$                   OLDNCL, P, PARITY, Q, WBEGIN, WEND, WINDEX,
00190      \$                   WINDMN, WINDPL, ZFROM, ZTO, ZUSEDL, ZUSEDU,
00191      \$                   ZUSEDW
00192       DOUBLE PRECISION   BSTRES, BSTW, EPS, FUDGE, GAP, GAPTOL, GL, GU,
00193      \$                   LAMBDA, LEFT, LGAP, MINGMA, NRMINV, RESID,
00194      \$                   RGAP, RIGHT, RQCORR, RQTOL, SAVGAP, SGNDEF,
00195      \$                   SIGMA, SPDIAM, SSIGMA, TAU, TMP, TOL, ZTZ
00196 *     ..
00197 *     .. External Functions ..
00198       DOUBLE PRECISION   DLAMCH
00199       EXTERNAL           DLAMCH
00200 *     ..
00201 *     .. External Subroutines ..
00202       EXTERNAL           DCOPY, DLAR1V, DLARRB, DLARRF, DLASET,
00203      \$                   DSCAL
00204 *     ..
00205 *     .. Intrinsic Functions ..
00206       INTRINSIC ABS, DBLE, MAX, MIN
00207 *     ..
00208 *     .. Executable Statements ..
00209 *     ..
00210
00211 *     The first N entries of WORK are reserved for the eigenvalues
00212       INDLD = N+1
00213       INDLLD= 2*N+1
00214       INDWRK= 3*N+1
00215       MINWSIZE = 12 * N
00216
00217       DO 5 I= 1,MINWSIZE
00218          WORK( I ) = ZERO
00219  5    CONTINUE
00220
00221 *     IWORK(IINDR+1:IINDR+N) hold the twist indices R for the
00222 *     factorization used to compute the FP vector
00223       IINDR = 0
00224 *     IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current
00225 *     layer and the one above.
00226       IINDC1 = N
00227       IINDC2 = 2*N
00228       IINDWK = 3*N + 1
00229
00230       MINIWSIZE = 7 * N
00231       DO 10 I= 1,MINIWSIZE
00232          IWORK( I ) = 0
00233  10   CONTINUE
00234
00235       ZUSEDL = 1
00236       IF(DOL.GT.1) THEN
00237 *        Set lower bound for use of Z
00238          ZUSEDL = DOL-1
00239       ENDIF
00240       ZUSEDU = M
00241       IF(DOU.LT.M) THEN
00242 *        Set lower bound for use of Z
00243          ZUSEDU = DOU+1
00244       ENDIF
00245 *     The width of the part of Z that is used
00246       ZUSEDW = ZUSEDU - ZUSEDL + 1
00247
00248
00249       CALL DLASET( 'Full', N, ZUSEDW, ZERO, ZERO,
00250      \$                    Z(1,ZUSEDL), LDZ )
00251
00252       EPS = DLAMCH( 'Precision' )
00253       RQTOL = TWO * EPS
00254 *
00255 *     Set expert flags for standard code.
00256       TRYRQC = .TRUE.
00257
00258       IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
00259       ELSE
00260 *        Only selected eigenpairs are computed. Since the other evalues
00261 *        are not refined by RQ iteration, bisection has to compute to full
00262 *        accuracy.
00263          RTOL1 = FOUR * EPS
00264          RTOL2 = FOUR * EPS
00265       ENDIF
00266
00267 *     The entries WBEGIN:WEND in W, WERR, WGAP correspond to the
00268 *     desired eigenvalues. The support of the nonzero eigenvector
00269 *     entries is contained in the interval IBEGIN:IEND.
00270 *     Remark that if k eigenpairs are desired, then the eigenvectors
00271 *     are stored in k contiguous columns of Z.
00272
00273 *     DONE is the number of eigenvectors already computed
00274       DONE = 0
00275       IBEGIN = 1
00276       WBEGIN = 1
00277       DO 170 JBLK = 1, IBLOCK( M )
00278          IEND = ISPLIT( JBLK )
00279          SIGMA = L( IEND )
00280 *        Find the eigenvectors of the submatrix indexed IBEGIN
00281 *        through IEND.
00282          WEND = WBEGIN - 1
00283  15      CONTINUE
00284          IF( WEND.LT.M ) THEN
00285             IF( IBLOCK( WEND+1 ).EQ.JBLK ) THEN
00286                WEND = WEND + 1
00287                GO TO 15
00288             END IF
00289          END IF
00290          IF( WEND.LT.WBEGIN ) THEN
00291             IBEGIN = IEND + 1
00292             GO TO 170
00293          ELSEIF( (WEND.LT.DOL).OR.(WBEGIN.GT.DOU) ) THEN
00294             IBEGIN = IEND + 1
00295             WBEGIN = WEND + 1
00296             GO TO 170
00297          END IF
00298
00299 *        Find local spectral diameter of the block
00300          GL = GERS( 2*IBEGIN-1 )
00301          GU = GERS( 2*IBEGIN )
00302          DO 20 I = IBEGIN+1 , IEND
00303             GL = MIN( GERS( 2*I-1 ), GL )
00304             GU = MAX( GERS( 2*I ), GU )
00305  20      CONTINUE
00306          SPDIAM = GU - GL
00307
00308 *        OLDIEN is the last index of the previous block
00309          OLDIEN = IBEGIN - 1
00310 *        Calculate the size of the current block
00311          IN = IEND - IBEGIN + 1
00312 *        The number of eigenvalues in the current block
00313          IM = WEND - WBEGIN + 1
00314
00315 *        This is for a 1x1 block
00316          IF( IBEGIN.EQ.IEND ) THEN
00317             DONE = DONE+1
00318             Z( IBEGIN, WBEGIN ) = ONE
00319             ISUPPZ( 2*WBEGIN-1 ) = IBEGIN
00320             ISUPPZ( 2*WBEGIN ) = IBEGIN
00321             W( WBEGIN ) = W( WBEGIN ) + SIGMA
00322             WORK( WBEGIN ) = W( WBEGIN )
00323             IBEGIN = IEND + 1
00324             WBEGIN = WBEGIN + 1
00325             GO TO 170
00326          END IF
00327
00328 *        The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND)
00329 *        Note that these can be approximations, in this case, the corresp.
00330 *        entries of WERR give the size of the uncertainty interval.
00331 *        The eigenvalue approximations will be refined when necessary as
00332 *        high relative accuracy is required for the computation of the
00333 *        corresponding eigenvectors.
00334          CALL DCOPY( IM, W( WBEGIN ), 1,
00335      \$                   WORK( WBEGIN ), 1 )
00336
00337 *        We store in W the eigenvalue approximations w.r.t. the original
00338 *        matrix T.
00339          DO 30 I=1,IM
00340             W(WBEGIN+I-1) = W(WBEGIN+I-1)+SIGMA
00341  30      CONTINUE
00342
00343
00344 *        NDEPTH is the current depth of the representation tree
00345          NDEPTH = 0
00346 *        PARITY is either 1 or 0
00347          PARITY = 1
00348 *        NCLUS is the number of clusters for the next level of the
00349 *        representation tree, we start with NCLUS = 1 for the root
00350          NCLUS = 1
00351          IWORK( IINDC1+1 ) = 1
00352          IWORK( IINDC1+2 ) = IM
00353
00354 *        IDONE is the number of eigenvectors already computed in the current
00355 *        block
00356          IDONE = 0
00357 *        loop while( IDONE.LT.IM )
00358 *        generate the representation tree for the current block and
00359 *        compute the eigenvectors
00360    40    CONTINUE
00361          IF( IDONE.LT.IM ) THEN
00362 *           This is a crude protection against infinitely deep trees
00363             IF( NDEPTH.GT.M ) THEN
00364                INFO = -2
00365                RETURN
00366             ENDIF
00367 *           breadth first processing of the current level of the representation
00368 *           tree: OLDNCL = number of clusters on current level
00369             OLDNCL = NCLUS
00370 *           reset NCLUS to count the number of child clusters
00371             NCLUS = 0
00372 *
00373             PARITY = 1 - PARITY
00374             IF( PARITY.EQ.0 ) THEN
00375                OLDCLS = IINDC1
00376                NEWCLS = IINDC2
00377             ELSE
00378                OLDCLS = IINDC2
00379                NEWCLS = IINDC1
00380             END IF
00381 *           Process the clusters on the current level
00382             DO 150 I = 1, OLDNCL
00383                J = OLDCLS + 2*I
00384 *              OLDFST, OLDLST = first, last index of current cluster.
00386 *                               to WBEGIN when accessing W, WGAP, WERR, Z
00387                OLDFST = IWORK( J-1 )
00388                OLDLST = IWORK( J )
00389                IF( NDEPTH.GT.0 ) THEN
00390 *                 Retrieve relatively robust representation (RRR) of cluster
00391 *                 that has been computed at the previous level
00392 *                 The RRR is stored in Z and overwritten once the eigenvectors
00393 *                 have been computed or when the cluster is refined
00394
00395                   IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
00396 *                    Get representation from location of the leftmost evalue
00397 *                    of the cluster
00398                      J = WBEGIN + OLDFST - 1
00399                   ELSE
00400                      IF(WBEGIN+OLDFST-1.LT.DOL) THEN
00401 *                       Get representation from the left end of Z array
00402                         J = DOL - 1
00403                      ELSEIF(WBEGIN+OLDFST-1.GT.DOU) THEN
00404 *                       Get representation from the right end of Z array
00405                         J = DOU
00406                      ELSE
00407                         J = WBEGIN + OLDFST - 1
00408                      ENDIF
00409                   ENDIF
00410                   CALL DCOPY( IN, Z( IBEGIN, J ), 1, D( IBEGIN ), 1 )
00411                   CALL DCOPY( IN-1, Z( IBEGIN, J+1 ), 1, L( IBEGIN ),
00412      \$               1 )
00413                   SIGMA = Z( IEND, J+1 )
00414
00415 *                 Set the corresponding entries in Z to zero
00416                   CALL DLASET( 'Full', IN, 2, ZERO, ZERO,
00417      \$                         Z( IBEGIN, J), LDZ )
00418                END IF
00419
00420 *              Compute DL and DLL of current RRR
00421                DO 50 J = IBEGIN, IEND-1
00422                   TMP = D( J )*L( J )
00423                   WORK( INDLD-1+J ) = TMP
00424                   WORK( INDLLD-1+J ) = TMP*L( J )
00425    50          CONTINUE
00426
00427                IF( NDEPTH.GT.0 ) THEN
00428 *                 P and Q are index of the first and last eigenvalue to compute
00429 *                 within the current block
00430                   P = INDEXW( WBEGIN-1+OLDFST )
00431                   Q = INDEXW( WBEGIN-1+OLDLST )
00432 *                 Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET
00433 *                 through the Q-OFFSET elements of these arrays are to be used.
00434 *                  OFFSET = P-OLDFST
00435                   OFFSET = INDEXW( WBEGIN ) - 1
00436 *                 perform limited bisection (if necessary) to get approximate
00437 *                 eigenvalues to the precision needed.
00438                   CALL DLARRB( IN, D( IBEGIN ),
00439      \$                         WORK(INDLLD+IBEGIN-1),
00440      \$                         P, Q, RTOL1, RTOL2, OFFSET,
00441      \$                         WORK(WBEGIN),WGAP(WBEGIN),WERR(WBEGIN),
00442      \$                         WORK( INDWRK ), IWORK( IINDWK ),
00443      \$                         PIVMIN, SPDIAM, IN, IINFO )
00444                   IF( IINFO.NE.0 ) THEN
00445                      INFO = -1
00446                      RETURN
00447                   ENDIF
00448 *                 We also recompute the extremal gaps. W holds all eigenvalues
00449 *                 of the unshifted matrix and must be used for computation
00450 *                 of WGAP, the entries of WORK might stem from RRRs with
00451 *                 different shifts. The gaps from WBEGIN-1+OLDFST to
00452 *                 WBEGIN-1+OLDLST are correctly computed in DLARRB.
00453 *                 However, we only allow the gaps to become greater since
00454 *                 this is what should happen when we decrease WERR
00455                   IF( OLDFST.GT.1) THEN
00456                      WGAP( WBEGIN+OLDFST-2 ) =
00457      \$             MAX(WGAP(WBEGIN+OLDFST-2),
00458      \$                 W(WBEGIN+OLDFST-1)-WERR(WBEGIN+OLDFST-1)
00459      \$                 - W(WBEGIN+OLDFST-2)-WERR(WBEGIN+OLDFST-2) )
00460                   ENDIF
00461                   IF( WBEGIN + OLDLST -1 .LT. WEND ) THEN
00462                      WGAP( WBEGIN+OLDLST-1 ) =
00463      \$               MAX(WGAP(WBEGIN+OLDLST-1),
00464      \$                   W(WBEGIN+OLDLST)-WERR(WBEGIN+OLDLST)
00465      \$                   - W(WBEGIN+OLDLST-1)-WERR(WBEGIN+OLDLST-1) )
00466                   ENDIF
00467 *                 Each time the eigenvalues in WORK get refined, we store
00468 *                 the newly found approximation with all shifts applied in W
00469                   DO 53 J=OLDFST,OLDLST
00470                      W(WBEGIN+J-1) = WORK(WBEGIN+J-1)+SIGMA
00471  53               CONTINUE
00472                END IF
00473
00474 *              Process the current node.
00475                NEWFST = OLDFST
00476                DO 140 J = OLDFST, OLDLST
00477                   IF( J.EQ.OLDLST ) THEN
00478 *                    we are at the right end of the cluster, this is also the
00479 *                    boundary of the child cluster
00480                      NEWLST = J
00481                   ELSE IF ( WGAP( WBEGIN + J -1).GE.
00482      \$                    MINRGP* ABS( WORK(WBEGIN + J -1) ) ) THEN
00483 *                    the right relative gap is big enough, the child cluster
00484 *                    (NEWFST,..,NEWLST) is well separated from the following
00485                      NEWLST = J
00486                    ELSE
00487 *                    inside a child cluster, the relative gap is not
00488 *                    big enough.
00489                      GOTO 140
00490                   END IF
00491
00492 *                 Compute size of child cluster found
00493                   NEWSIZ = NEWLST - NEWFST + 1
00494
00495 *                 NEWFTT is the place in Z where the new RRR or the computed
00496 *                 eigenvector is to be stored
00497                   IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
00498 *                    Store representation at location of the leftmost evalue
00499 *                    of the cluster
00500                      NEWFTT = WBEGIN + NEWFST - 1
00501                   ELSE
00502                      IF(WBEGIN+NEWFST-1.LT.DOL) THEN
00503 *                       Store representation at the left end of Z array
00504                         NEWFTT = DOL - 1
00505                      ELSEIF(WBEGIN+NEWFST-1.GT.DOU) THEN
00506 *                       Store representation at the right end of Z array
00507                         NEWFTT = DOU
00508                      ELSE
00509                         NEWFTT = WBEGIN + NEWFST - 1
00510                      ENDIF
00511                   ENDIF
00512
00513                   IF( NEWSIZ.GT.1) THEN
00514 *
00515 *                    Current child is not a singleton but a cluster.
00516 *                    Compute and store new representation of child.
00517 *
00518 *
00519 *                    Compute left and right cluster gap.
00520 *
00521 *                    LGAP and RGAP are not computed from WORK because
00522 *                    the eigenvalue approximations may stem from RRRs
00523 *                    different shifts. However, W hold all eigenvalues
00524 *                    of the unshifted matrix. Still, the entries in WGAP
00525 *                    have to be computed from WORK since the entries
00526 *                    in W might be of the same order so that gaps are not
00527 *                    exhibited correctly for very close eigenvalues.
00528                      IF( NEWFST.EQ.1 ) THEN
00529                         LGAP = MAX( ZERO,
00530      \$                       W(WBEGIN)-WERR(WBEGIN) - VL )
00531                     ELSE
00532                         LGAP = WGAP( WBEGIN+NEWFST-2 )
00533                      ENDIF
00534                      RGAP = WGAP( WBEGIN+NEWLST-1 )
00535 *
00536 *                    Compute left- and rightmost eigenvalue of child
00537 *                    to high precision in order to shift as close
00538 *                    as possible and obtain as large relative gaps
00539 *                    as possible
00540 *
00541                      DO 55 K =1,2
00542                         IF(K.EQ.1) THEN
00543                            P = INDEXW( WBEGIN-1+NEWFST )
00544                         ELSE
00545                            P = INDEXW( WBEGIN-1+NEWLST )
00546                         ENDIF
00547                         OFFSET = INDEXW( WBEGIN ) - 1
00548                         CALL DLARRB( IN, D(IBEGIN),
00549      \$                       WORK( INDLLD+IBEGIN-1 ),P,P,
00550      \$                       RQTOL, RQTOL, OFFSET,
00551      \$                       WORK(WBEGIN),WGAP(WBEGIN),
00552      \$                       WERR(WBEGIN),WORK( INDWRK ),
00553      \$                       IWORK( IINDWK ), PIVMIN, SPDIAM,
00554      \$                       IN, IINFO )
00555  55                  CONTINUE
00556 *
00557                      IF((WBEGIN+NEWLST-1.LT.DOL).OR.
00558      \$                  (WBEGIN+NEWFST-1.GT.DOU)) THEN
00559 *                       if the cluster contains no desired eigenvalues
00560 *                       skip the computation of that branch of the rep. tree
00561 *
00562 *                       We could skip before the refinement of the extremal
00563 *                       eigenvalues of the child, but then the representation
00564 *                       tree could be different from the one when nothing is
00565 *                       skipped. For this reason we skip at this place.
00566                         IDONE = IDONE + NEWLST - NEWFST + 1
00567                         GOTO 139
00568                      ENDIF
00569 *
00570 *                    Compute RRR of child cluster.
00571 *                    Note that the new RRR is stored in Z
00572 *
00573 *                    DLARRF needs LWORK = 2*N
00574                      CALL DLARRF( IN, D( IBEGIN ), L( IBEGIN ),
00575      \$                         WORK(INDLD+IBEGIN-1),
00576      \$                         NEWFST, NEWLST, WORK(WBEGIN),
00577      \$                         WGAP(WBEGIN), WERR(WBEGIN),
00578      \$                         SPDIAM, LGAP, RGAP, PIVMIN, TAU,
00579      \$                         Z(IBEGIN, NEWFTT),Z(IBEGIN, NEWFTT+1),
00580      \$                         WORK( INDWRK ), IINFO )
00581                      IF( IINFO.EQ.0 ) THEN
00582 *                       a new RRR for the cluster was found by DLARRF
00583 *                       update shift and store it
00584                         SSIGMA = SIGMA + TAU
00585                         Z( IEND, NEWFTT+1 ) = SSIGMA
00586 *                       WORK() are the midpoints and WERR() the semi-width
00587 *                       Note that the entries in W are unchanged.
00588                         DO 116 K = NEWFST, NEWLST
00589                            FUDGE =
00590      \$                          THREE*EPS*ABS(WORK(WBEGIN+K-1))
00591                            WORK( WBEGIN + K - 1 ) =
00592      \$                          WORK( WBEGIN + K - 1) - TAU
00593                            FUDGE = FUDGE +
00594      \$                          FOUR*EPS*ABS(WORK(WBEGIN+K-1))
00595 *                          Fudge errors
00596                            WERR( WBEGIN + K - 1 ) =
00597      \$                          WERR( WBEGIN + K - 1 ) + FUDGE
00598 *                          Gaps are not fudged. Provided that WERR is small
00599 *                          when eigenvalues are close, a zero gap indicates
00600 *                          that a new representation is needed for resolving
00601 *                          the cluster. A fudge could lead to a wrong decision
00602 *                          of judging eigenvalues 'separated' which in
00603 *                          reality are not. This could have a negative impact
00604 *                          on the orthogonality of the computed eigenvectors.
00605  116                    CONTINUE
00606
00607                         NCLUS = NCLUS + 1
00608                         K = NEWCLS + 2*NCLUS
00609                         IWORK( K-1 ) = NEWFST
00610                         IWORK( K ) = NEWLST
00611                      ELSE
00612                         INFO = -2
00613                         RETURN
00614                      ENDIF
00615                   ELSE
00616 *
00617 *                    Compute eigenvector of singleton
00618 *
00619                      ITER = 0
00620 *
00621                      TOL = FOUR * LOG(DBLE(IN)) * EPS
00622 *
00623                      K = NEWFST
00624                      WINDEX = WBEGIN + K - 1
00625                      WINDMN = MAX(WINDEX - 1,1)
00626                      WINDPL = MIN(WINDEX + 1,M)
00627                      LAMBDA = WORK( WINDEX )
00628                      DONE = DONE + 1
00629 *                    Check if eigenvector computation is to be skipped
00630                      IF((WINDEX.LT.DOL).OR.
00631      \$                  (WINDEX.GT.DOU)) THEN
00632                         ESKIP = .TRUE.
00633                         GOTO 125
00634                      ELSE
00635                         ESKIP = .FALSE.
00636                      ENDIF
00637                      LEFT = WORK( WINDEX ) - WERR( WINDEX )
00638                      RIGHT = WORK( WINDEX ) + WERR( WINDEX )
00639                      INDEIG = INDEXW( WINDEX )
00640 *                    Note that since we compute the eigenpairs for a child,
00641 *                    all eigenvalue approximations are w.r.t the same shift.
00642 *                    In this case, the entries in WORK should be used for
00643 *                    computing the gaps since they exhibit even very small
00644 *                    differences in the eigenvalues, as opposed to the
00645 *                    entries in W which might "look" the same.
00646
00647                      IF( K .EQ. 1) THEN
00648 *                       In the case RANGE='I' and with not much initial
00649 *                       accuracy in LAMBDA and VL, the formula
00650 *                       LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA )
00651 *                       can lead to an overestimation of the left gap and
00652 *                       thus to inadequately early RQI 'convergence'.
00653 *                       Prevent this by forcing a small left gap.
00654                         LGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
00655                      ELSE
00656                         LGAP = WGAP(WINDMN)
00657                      ENDIF
00658                      IF( K .EQ. IM) THEN
00659 *                       In the case RANGE='I' and with not much initial
00660 *                       accuracy in LAMBDA and VU, the formula
00661 *                       can lead to an overestimation of the right gap and
00662 *                       thus to inadequately early RQI 'convergence'.
00663 *                       Prevent this by forcing a small right gap.
00664                         RGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
00665                      ELSE
00666                         RGAP = WGAP(WINDEX)
00667                      ENDIF
00668                      GAP = MIN( LGAP, RGAP )
00669                      IF(( K .EQ. 1).OR.(K .EQ. IM)) THEN
00670 *                       The eigenvector support can become wrong
00671 *                       because significant entries could be cut off due to a
00672 *                       large GAPTOL parameter in LAR1V. Prevent this.
00673                         GAPTOL = ZERO
00674                      ELSE
00675                         GAPTOL = GAP * EPS
00676                      ENDIF
00677                      ISUPMN = IN
00678                      ISUPMX = 1
00679 *                    Update WGAP so that it holds the minimum gap
00680 *                    to the left or the right. This is crucial in the
00681 *                    case where bisection is used to ensure that the
00682 *                    eigenvalue is refined up to the required precision.
00683 *                    The correct value is restored afterwards.
00684                      SAVGAP = WGAP(WINDEX)
00685                      WGAP(WINDEX) = GAP
00686 *                    We want to use the Rayleigh Quotient Correction
00687 *                    as often as possible since it converges quadratically
00688 *                    when we are close enough to the desired eigenvalue.
00689 *                    However, the Rayleigh Quotient can have the wrong sign
00690 *                    and lead us away from the desired eigenvalue. In this
00691 *                    case, the best we can do is to use bisection.
00692                      USEDBS = .FALSE.
00693                      USEDRQ = .FALSE.
00694 *                    Bisection is initially turned off unless it is forced
00695                      NEEDBS =  .NOT.TRYRQC
00696  120                 CONTINUE
00697 *                    Check if bisection should be used to refine eigenvalue
00698                      IF(NEEDBS) THEN
00699 *                       Take the bisection as new iterate
00700                         USEDBS = .TRUE.
00701                         ITMP1 = IWORK( IINDR+WINDEX )
00702                         OFFSET = INDEXW( WBEGIN ) - 1
00703                         CALL DLARRB( IN, D(IBEGIN),
00704      \$                       WORK(INDLLD+IBEGIN-1),INDEIG,INDEIG,
00705      \$                       ZERO, TWO*EPS, OFFSET,
00706      \$                       WORK(WBEGIN),WGAP(WBEGIN),
00707      \$                       WERR(WBEGIN),WORK( INDWRK ),
00708      \$                       IWORK( IINDWK ), PIVMIN, SPDIAM,
00709      \$                       ITMP1, IINFO )
00710                         IF( IINFO.NE.0 ) THEN
00711                            INFO = -3
00712                            RETURN
00713                         ENDIF
00714                         LAMBDA = WORK( WINDEX )
00715 *                       Reset twist index from inaccurate LAMBDA to
00716 *                       force computation of true MINGMA
00717                         IWORK( IINDR+WINDEX ) = 0
00718                      ENDIF
00719 *                    Given LAMBDA, compute the eigenvector.
00720                      CALL DLAR1V( IN, 1, IN, LAMBDA, D( IBEGIN ),
00721      \$                    L( IBEGIN ), WORK(INDLD+IBEGIN-1),
00722      \$                    WORK(INDLLD+IBEGIN-1),
00723      \$                    PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
00724      \$                    .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
00725      \$                    IWORK( IINDR+WINDEX ), ISUPPZ( 2*WINDEX-1 ),
00726      \$                    NRMINV, RESID, RQCORR, WORK( INDWRK ) )
00727                      IF(ITER .EQ. 0) THEN
00728                         BSTRES = RESID
00729                         BSTW = LAMBDA
00730                      ELSEIF(RESID.LT.BSTRES) THEN
00731                         BSTRES = RESID
00732                         BSTW = LAMBDA
00733                      ENDIF
00734                      ISUPMN = MIN(ISUPMN,ISUPPZ( 2*WINDEX-1 ))
00735                      ISUPMX = MAX(ISUPMX,ISUPPZ( 2*WINDEX ))
00736                      ITER = ITER + 1
00737
00738 *                    sin alpha <= |resid|/gap
00739 *                    Note that both the residual and the gap are
00740 *                    proportional to the matrix, so ||T|| doesn't play
00741 *                    a role in the quotient
00742
00743 *
00744 *                    Convergence test for Rayleigh-Quotient iteration
00745 *                    (omitted when Bisection has been used)
00746 *
00747                      IF( RESID.GT.TOL*GAP .AND. ABS( RQCORR ).GT.
00748      \$                    RQTOL*ABS( LAMBDA ) .AND. .NOT. USEDBS)
00749      \$                    THEN
00750 *                       We need to check that the RQCORR update doesn't
00751 *                       move the eigenvalue away from the desired one and
00752 *                       towards a neighbor. -> protection with bisection
00753                         IF(INDEIG.LE.NEGCNT) THEN
00754 *                          The wanted eigenvalue lies to the left
00755                            SGNDEF = -ONE
00756                         ELSE
00757 *                          The wanted eigenvalue lies to the right
00758                            SGNDEF = ONE
00759                         ENDIF
00760 *                       We only use the RQCORR if it improves the
00761 *                       the iterate reasonably.
00762                         IF( ( RQCORR*SGNDEF.GE.ZERO )
00763      \$                       .AND.( LAMBDA + RQCORR.LE. RIGHT)
00764      \$                       .AND.( LAMBDA + RQCORR.GE. LEFT)
00765      \$                       ) THEN
00766                            USEDRQ = .TRUE.
00767 *                          Store new midpoint of bisection interval in WORK
00768                            IF(SGNDEF.EQ.ONE) THEN
00769 *                             The current LAMBDA is on the left of the true
00770 *                             eigenvalue
00771                               LEFT = LAMBDA
00772 *                             We prefer to assume that the error estimate
00773 *                             is correct. We could make the interval not
00774 *                             as a bracket but to be modified if the RQCORR
00775 *                             chooses to. In this case, the RIGHT side should
00776 *                             be modified as follows:
00777 *                              RIGHT = MAX(RIGHT, LAMBDA + RQCORR)
00778                            ELSE
00779 *                             The current LAMBDA is on the right of the true
00780 *                             eigenvalue
00781                               RIGHT = LAMBDA
00782 *                             See comment about assuming the error estimate is
00783 *                             correct above.
00784 *                              LEFT = MIN(LEFT, LAMBDA + RQCORR)
00785                            ENDIF
00786                            WORK( WINDEX ) =
00787      \$                       HALF * (RIGHT + LEFT)
00788 *                          Take RQCORR since it has the correct sign and
00789 *                          improves the iterate reasonably
00790                            LAMBDA = LAMBDA + RQCORR
00791 *                          Update width of error interval
00792                            WERR( WINDEX ) =
00793      \$                             HALF * (RIGHT-LEFT)
00794                         ELSE
00795                            NEEDBS = .TRUE.
00796                         ENDIF
00797                         IF(RIGHT-LEFT.LT.RQTOL*ABS(LAMBDA)) THEN
00798 *                             The eigenvalue is computed to bisection accuracy
00799 *                             compute eigenvector and stop
00800                            USEDBS = .TRUE.
00801                            GOTO 120
00802                         ELSEIF( ITER.LT.MAXITR ) THEN
00803                            GOTO 120
00804                         ELSEIF( ITER.EQ.MAXITR ) THEN
00805                            NEEDBS = .TRUE.
00806                            GOTO 120
00807                         ELSE
00808                            INFO = 5
00809                            RETURN
00810                         END IF
00811                      ELSE
00812                         STP2II = .FALSE.
00813         IF(USEDRQ .AND. USEDBS .AND.
00814      \$                     BSTRES.LE.RESID) THEN
00815                            LAMBDA = BSTW
00816                            STP2II = .TRUE.
00817                         ENDIF
00818                         IF (STP2II) THEN
00819 *                          improve error angle by second step
00820                            CALL DLAR1V( IN, 1, IN, LAMBDA,
00821      \$                          D( IBEGIN ), L( IBEGIN ),
00822      \$                          WORK(INDLD+IBEGIN-1),
00823      \$                          WORK(INDLLD+IBEGIN-1),
00824      \$                          PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
00825      \$                          .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
00826      \$                          IWORK( IINDR+WINDEX ),
00827      \$                          ISUPPZ( 2*WINDEX-1 ),
00828      \$                          NRMINV, RESID, RQCORR, WORK( INDWRK ) )
00829                         ENDIF
00830                         WORK( WINDEX ) = LAMBDA
00831                      END IF
00832 *
00833 *                    Compute FP-vector support w.r.t. whole matrix
00834 *
00835                      ISUPPZ( 2*WINDEX-1 ) = ISUPPZ( 2*WINDEX-1 )+OLDIEN
00836                      ISUPPZ( 2*WINDEX ) = ISUPPZ( 2*WINDEX )+OLDIEN
00837                      ZFROM = ISUPPZ( 2*WINDEX-1 )
00838                      ZTO = ISUPPZ( 2*WINDEX )
00839                      ISUPMN = ISUPMN + OLDIEN
00840                      ISUPMX = ISUPMX + OLDIEN
00841 *                    Ensure vector is ok if support in the RQI has changed
00842                      IF(ISUPMN.LT.ZFROM) THEN
00843                         DO 122 II = ISUPMN,ZFROM-1
00844                            Z( II, WINDEX ) = ZERO
00845  122                    CONTINUE
00846                      ENDIF
00847                      IF(ISUPMX.GT.ZTO) THEN
00848                         DO 123 II = ZTO+1,ISUPMX
00849                            Z( II, WINDEX ) = ZERO
00850  123                    CONTINUE
00851                      ENDIF
00852                      CALL DSCAL( ZTO-ZFROM+1, NRMINV,
00853      \$                       Z( ZFROM, WINDEX ), 1 )
00854  125                 CONTINUE
00855 *                    Update W
00856                      W( WINDEX ) = LAMBDA+SIGMA
00857 *                    Recompute the gaps on the left and right
00858 *                    But only allow them to become larger and not
00859 *                    smaller (which can only happen through "bad"
00860 *                    cancellation and doesn't reflect the theory
00861 *                    where the initial gaps are underestimated due
00862 *                    to WERR being too crude.)
00863                      IF(.NOT.ESKIP) THEN
00864                         IF( K.GT.1) THEN
00865                            WGAP( WINDMN ) = MAX( WGAP(WINDMN),
00866      \$                          W(WINDEX)-WERR(WINDEX)
00867      \$                          - W(WINDMN)-WERR(WINDMN) )
00868                         ENDIF
00869                         IF( WINDEX.LT.WEND ) THEN
00870                            WGAP( WINDEX ) = MAX( SAVGAP,
00871      \$                          W( WINDPL )-WERR( WINDPL )
00872      \$                          - W( WINDEX )-WERR( WINDEX) )
00873                         ENDIF
00874                      ENDIF
00875                      IDONE = IDONE + 1
00876                   ENDIF
00877 *                 here ends the code for the current child
00878 *
00879  139              CONTINUE
00880 *                 Proceed to any remaining child nodes
00881                   NEWFST = J + 1
00882  140           CONTINUE
00883  150        CONTINUE
00884             NDEPTH = NDEPTH + 1
00885             GO TO 40
00886          END IF
00887          IBEGIN = IEND + 1
00888          WBEGIN = WEND + 1
00889  170  CONTINUE
00890 *
00891
00892       RETURN
00893 *
00894 *     End of DLARRV
00895 *
00896       END
```