LAPACK 3.3.0

sstemr.f

Go to the documentation of this file.
00001       SUBROUTINE SSTEMR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,
00002      $                   M, W, Z, LDZ, NZC, ISUPPZ, TRYRAC, WORK, LWORK,
00003      $                   IWORK, LIWORK, INFO )
00004       IMPLICIT NONE
00005 *
00006 *  -- LAPACK computational routine (version 3.2.2)                                  --
00007 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00008 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00009 *  -- June 2010                                                       --
00010 *
00011 *     .. Scalar Arguments ..
00012       CHARACTER          JOBZ, RANGE
00013       LOGICAL            TRYRAC
00014       INTEGER            IL, INFO, IU, LDZ, NZC, LIWORK, LWORK, M, N
00015       REAL               VL, VU
00016 *     ..
00017 *     .. Array Arguments ..
00018       INTEGER            ISUPPZ( * ), IWORK( * )
00019       REAL               D( * ), E( * ), W( * ), WORK( * )
00020       REAL               Z( LDZ, * )
00021 *     ..
00022 *
00023 *  Purpose
00024 *  =======
00025 *
00026 *  SSTEMR computes selected eigenvalues and, optionally, eigenvectors
00027 *  of a real symmetric tridiagonal matrix T. Any such unreduced matrix has
00028 *  a well defined set of pairwise different real eigenvalues, the corresponding
00029 *  real eigenvectors are pairwise orthogonal.
00030 *
00031 *  The spectrum may be computed either completely or partially by specifying
00032 *  either an interval (VL,VU] or a range of indices IL:IU for the desired
00033 *  eigenvalues.
00034 *
00035 *  Depending on the number of desired eigenvalues, these are computed either
00036 *  by bisection or the dqds algorithm. Numerically orthogonal eigenvectors are
00037 *  computed by the use of various suitable L D L^T factorizations near clusters
00038 *  of close eigenvalues (referred to as RRRs, Relatively Robust
00039 *  Representations). An informal sketch of the algorithm follows.
00040 *
00041 *  For each unreduced block (submatrix) of T,
00042 *     (a) Compute T - sigma I  = L D L^T, so that L and D
00043 *         define all the wanted eigenvalues to high relative accuracy.
00044 *         This means that small relative changes in the entries of D and L
00045 *         cause only small relative changes in the eigenvalues and
00046 *         eigenvectors. The standard (unfactored) representation of the
00047 *         tridiagonal matrix T does not have this property in general.
00048 *     (b) Compute the eigenvalues to suitable accuracy.
00049 *         If the eigenvectors are desired, the algorithm attains full
00050 *         accuracy of the computed eigenvalues only right before
00051 *         the corresponding vectors have to be computed, see steps c) and d).
00052 *     (c) For each cluster of close eigenvalues, select a new
00053 *         shift close to the cluster, find a new factorization, and refine
00054 *         the shifted eigenvalues to suitable accuracy.
00055 *     (d) For each eigenvalue with a large enough relative separation compute
00056 *         the corresponding eigenvector by forming a rank revealing twisted
00057 *         factorization. Go back to (c) for any clusters that remain.
00058 *
00059 *  For more details, see:
00060 *  - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations
00061 *    to compute orthogonal eigenvectors of symmetric tridiagonal matrices,"
00062 *    Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004.
00063 *  - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and
00064 *    Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25,
00065 *    2004.  Also LAPACK Working Note 154.
00066 *  - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric
00067 *    tridiagonal eigenvalue/eigenvector problem",
00068 *    Computer Science Division Technical Report No. UCB/CSD-97-971,
00069 *    UC Berkeley, May 1997.
00070 *
00071 *  Further Details
00072 *  1.SSTEMR works only on machines which follow IEEE-754
00073 *  floating-point standard in their handling of infinities and NaNs.
00074 *  This permits the use of efficient inner loops avoiding a check for
00075 *  zero divisors.
00076 *
00077 *  Arguments
00078 *  =========
00079 *
00080 *  JOBZ    (input) CHARACTER*1
00081 *          = 'N':  Compute eigenvalues only;
00082 *          = 'V':  Compute eigenvalues and eigenvectors.
00083 *
00084 *  RANGE   (input) CHARACTER*1
00085 *          = 'A': all eigenvalues will be found.
00086 *          = 'V': all eigenvalues in the half-open interval (VL,VU]
00087 *                 will be found.
00088 *          = 'I': the IL-th through IU-th eigenvalues will be found.
00089 *
00090 *  N       (input) INTEGER
00091 *          The order of the matrix.  N >= 0.
00092 *
00093 *  D       (input/output) REAL array, dimension (N)
00094 *          On entry, the N diagonal elements of the tridiagonal matrix
00095 *          T. On exit, D is overwritten.
00096 *
00097 *  E       (input/output) REAL array, dimension (N)
00098 *          On entry, the (N-1) subdiagonal elements of the tridiagonal
00099 *          matrix T in elements 1 to N-1 of E. E(N) need not be set on
00100 *          input, but is used internally as workspace.
00101 *          On exit, E is overwritten.
00102 *
00103 *  VL      (input) REAL
00104 *  VU      (input) REAL
00105 *          If RANGE='V', the lower and upper bounds of the interval to
00106 *          be searched for eigenvalues. VL < VU.
00107 *          Not referenced if RANGE = 'A' or 'I'.
00108 *
00109 *  IL      (input) INTEGER
00110 *  IU      (input) INTEGER
00111 *          If RANGE='I', the indices (in ascending order) of the
00112 *          smallest and largest eigenvalues to be returned.
00113 *          1 <= IL <= IU <= N, if N > 0.
00114 *          Not referenced if RANGE = 'A' or 'V'.
00115 *
00116 *  M       (output) INTEGER
00117 *          The total number of eigenvalues found.  0 <= M <= N.
00118 *          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00119 *
00120 *  W       (output) REAL array, dimension (N)
00121 *          The first M elements contain the selected eigenvalues in
00122 *          ascending order.
00123 *
00124 *  Z       (output) REAL array, dimension (LDZ, max(1,M) )
00125 *          If JOBZ = 'V', and if INFO = 0, then the first M columns of Z
00126 *          contain the orthonormal eigenvectors of the matrix T
00127 *          corresponding to the selected eigenvalues, with the i-th
00128 *          column of Z holding the eigenvector associated with W(i).
00129 *          If JOBZ = 'N', then Z is not referenced.
00130 *          Note: the user must ensure that at least max(1,M) columns are
00131 *          supplied in the array Z; if RANGE = 'V', the exact value of M
00132 *          is not known in advance and can be computed with a workspace
00133 *          query by setting NZC = -1, see below.
00134 *
00135 *  LDZ     (input) INTEGER
00136 *          The leading dimension of the array Z.  LDZ >= 1, and if
00137 *          JOBZ = 'V', then LDZ >= max(1,N).
00138 *
00139 *  NZC     (input) INTEGER
00140 *          The number of eigenvectors to be held in the array Z.
00141 *          If RANGE = 'A', then NZC >= max(1,N).
00142 *          If RANGE = 'V', then NZC >= the number of eigenvalues in (VL,VU].
00143 *          If RANGE = 'I', then NZC >= IU-IL+1.
00144 *          If NZC = -1, then a workspace query is assumed; the
00145 *          routine calculates the number of columns of the array Z that
00146 *          are needed to hold the eigenvectors.
00147 *          This value is returned as the first entry of the Z array, and
00148 *          no error message related to NZC is issued by XERBLA.
00149 *
00150 *  ISUPPZ  (output) INTEGER ARRAY, dimension ( 2*max(1,M) )
00151 *          The support of the eigenvectors in Z, i.e., the indices
00152 *          indicating the nonzero elements in Z. The i-th computed eigenvector
00153 *          is nonzero only in elements ISUPPZ( 2*i-1 ) through
00154 *          ISUPPZ( 2*i ). This is relevant in the case when the matrix
00155 *          is split. ISUPPZ is only accessed when JOBZ is 'V' and N > 0.
00156 *
00157 *  TRYRAC  (input/output) LOGICAL
00158 *          If TRYRAC.EQ..TRUE., indicates that the code should check whether
00159 *          the tridiagonal matrix defines its eigenvalues to high relative
00160 *          accuracy.  If so, the code uses relative-accuracy preserving
00161 *          algorithms that might be (a bit) slower depending on the matrix.
00162 *          If the matrix does not define its eigenvalues to high relative
00163 *          accuracy, the code can uses possibly faster algorithms.
00164 *          If TRYRAC.EQ..FALSE., the code is not required to guarantee
00165 *          relatively accurate eigenvalues and can use the fastest possible
00166 *          techniques.
00167 *          On exit, a .TRUE. TRYRAC will be set to .FALSE. if the matrix
00168 *          does not define its eigenvalues to high relative accuracy.
00169 *
00170 *  WORK    (workspace/output) REAL array, dimension (LWORK)
00171 *          On exit, if INFO = 0, WORK(1) returns the optimal
00172 *          (and minimal) LWORK.
00173 *
00174 *  LWORK   (input) INTEGER
00175 *          The dimension of the array WORK. LWORK >= max(1,18*N)
00176 *          if JOBZ = 'V', and LWORK >= max(1,12*N) if JOBZ = 'N'.
00177 *          If LWORK = -1, then a workspace query is assumed; the routine
00178 *          only calculates the optimal size of the WORK array, returns
00179 *          this value as the first entry of the WORK array, and no error
00180 *          message related to LWORK is issued by XERBLA.
00181 *
00182 *  IWORK   (workspace/output) INTEGER array, dimension (LIWORK)
00183 *          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
00184 *
00185 *  LIWORK  (input) INTEGER
00186 *          The dimension of the array IWORK.  LIWORK >= max(1,10*N)
00187 *          if the eigenvectors are desired, and LIWORK >= max(1,8*N)
00188 *          if only the eigenvalues are to be computed.
00189 *          If LIWORK = -1, then a workspace query is assumed; the
00190 *          routine only calculates the optimal size of the IWORK array,
00191 *          returns this value as the first entry of the IWORK array, and
00192 *          no error message related to LIWORK is issued by XERBLA.
00193 *
00194 *  INFO    (output) INTEGER
00195 *          On exit, INFO
00196 *          = 0:  successful exit
00197 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00198 *          > 0:  if INFO = 1X, internal error in SLARRE,
00199 *                if INFO = 2X, internal error in SLARRV.
00200 *                Here, the digit X = ABS( IINFO ) < 10, where IINFO is
00201 *                the nonzero error code returned by SLARRE or
00202 *                SLARRV, respectively.
00203 *
00204 *
00205 *  Further Details
00206 *  ===============
00207 *
00208 *  Based on contributions by
00209 *     Beresford Parlett, University of California, Berkeley, USA
00210 *     Jim Demmel, University of California, Berkeley, USA
00211 *     Inderjit Dhillon, University of Texas, Austin, USA
00212 *     Osni Marques, LBNL/NERSC, USA
00213 *     Christof Voemel, University of California, Berkeley, USA
00214 *
00215 *  =====================================================================
00216 *
00217 *     .. Parameters ..
00218       REAL               ZERO, ONE, FOUR, MINRGP
00219       PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0,
00220      $                     FOUR = 4.0E0,
00221      $                     MINRGP = 3.0E-3 )
00222 *     ..
00223 *     .. Local Scalars ..
00224       LOGICAL            ALLEIG, INDEIG, LQUERY, VALEIG, WANTZ, ZQUERY
00225       INTEGER            I, IBEGIN, IEND, IFIRST, IIL, IINDBL, IINDW,
00226      $                   IINDWK, IINFO, IINSPL, IIU, ILAST, IN, INDD,
00227      $                   INDE2, INDERR, INDGP, INDGRS, INDWRK, ITMP,
00228      $                   ITMP2, J, JBLK, JJ, LIWMIN, LWMIN, NSPLIT,
00229      $                   NZCMIN, OFFSET, WBEGIN, WEND
00230       REAL               BIGNUM, CS, EPS, PIVMIN, R1, R2, RMAX, RMIN,
00231      $                   RTOL1, RTOL2, SAFMIN, SCALE, SMLNUM, SN,
00232      $                   THRESH, TMP, TNRM, WL, WU
00233 *     ..
00234 *     ..
00235 *     .. External Functions ..
00236       LOGICAL            LSAME
00237       REAL               SLAMCH, SLANST
00238       EXTERNAL           LSAME, SLAMCH, SLANST
00239 *     ..
00240 *     .. External Subroutines ..
00241       EXTERNAL           SCOPY, SLAE2, SLAEV2, SLARRC, SLARRE, SLARRJ,
00242      $                   SLARRR, SLARRV, SLASRT, SSCAL, SSWAP, XERBLA
00243 *     ..
00244 *     .. Intrinsic Functions ..
00245       INTRINSIC          MAX, MIN, SQRT
00246 *     ..
00247 *     .. Executable Statements ..
00248 *
00249 *     Test the input parameters.
00250 *
00251       WANTZ = LSAME( JOBZ, 'V' )
00252       ALLEIG = LSAME( RANGE, 'A' )
00253       VALEIG = LSAME( RANGE, 'V' )
00254       INDEIG = LSAME( RANGE, 'I' )
00255 *
00256       LQUERY = ( ( LWORK.EQ.-1 ).OR.( LIWORK.EQ.-1 ) )
00257       ZQUERY = ( NZC.EQ.-1 )
00258 
00259 *     SSTEMR needs WORK of size 6*N, IWORK of size 3*N.
00260 *     In addition, SLARRE needs WORK of size 6*N, IWORK of size 5*N.
00261 *     Furthermore, SLARRV needs WORK of size 12*N, IWORK of size 7*N.
00262       IF( WANTZ ) THEN
00263          LWMIN = 18*N
00264          LIWMIN = 10*N
00265       ELSE
00266 *        need less workspace if only the eigenvalues are wanted
00267          LWMIN = 12*N
00268          LIWMIN = 8*N
00269       ENDIF
00270 
00271       WL = ZERO
00272       WU = ZERO
00273       IIL = 0
00274       IIU = 0
00275 
00276       IF( VALEIG ) THEN
00277 *        We do not reference VL, VU in the cases RANGE = 'I','A'
00278 *        The interval (WL, WU] contains all the wanted eigenvalues.
00279 *        It is either given by the user or computed in SLARRE.
00280          WL = VL
00281          WU = VU
00282       ELSEIF( INDEIG ) THEN
00283 *        We do not reference IL, IU in the cases RANGE = 'V','A'
00284          IIL = IL
00285          IIU = IU
00286       ENDIF
00287 *
00288       INFO = 0
00289       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00290          INFO = -1
00291       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00292          INFO = -2
00293       ELSE IF( N.LT.0 ) THEN
00294          INFO = -3
00295       ELSE IF( VALEIG .AND. N.GT.0 .AND. WU.LE.WL ) THEN
00296          INFO = -7
00297       ELSE IF( INDEIG .AND. ( IIL.LT.1 .OR. IIL.GT.N ) ) THEN
00298          INFO = -8
00299       ELSE IF( INDEIG .AND. ( IIU.LT.IIL .OR. IIU.GT.N ) ) THEN
00300          INFO = -9
00301       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00302          INFO = -13
00303       ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
00304          INFO = -17
00305       ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
00306          INFO = -19
00307       END IF
00308 *
00309 *     Get machine constants.
00310 *
00311       SAFMIN = SLAMCH( 'Safe minimum' )
00312       EPS = SLAMCH( 'Precision' )
00313       SMLNUM = SAFMIN / EPS
00314       BIGNUM = ONE / SMLNUM
00315       RMIN = SQRT( SMLNUM )
00316       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
00317 *
00318       IF( INFO.EQ.0 ) THEN
00319          WORK( 1 ) = LWMIN
00320          IWORK( 1 ) = LIWMIN
00321 *
00322          IF( WANTZ .AND. ALLEIG ) THEN
00323             NZCMIN = N
00324          ELSE IF( WANTZ .AND. VALEIG ) THEN
00325             CALL SLARRC( 'T', N, VL, VU, D, E, SAFMIN,
00326      $                            NZCMIN, ITMP, ITMP2, INFO )
00327          ELSE IF( WANTZ .AND. INDEIG ) THEN
00328             NZCMIN = IIU-IIL+1
00329          ELSE
00330 *           WANTZ .EQ. FALSE.
00331             NZCMIN = 0
00332          ENDIF
00333          IF( ZQUERY .AND. INFO.EQ.0 ) THEN
00334             Z( 1,1 ) = NZCMIN
00335          ELSE IF( NZC.LT.NZCMIN .AND. .NOT.ZQUERY ) THEN
00336             INFO = -14
00337          END IF
00338       END IF
00339 
00340       IF( INFO.NE.0 ) THEN
00341 *
00342          CALL XERBLA( 'SSTEMR', -INFO )
00343 *
00344          RETURN
00345       ELSE IF( LQUERY .OR. ZQUERY ) THEN
00346          RETURN
00347       END IF
00348 *
00349 *     Handle N = 0, 1, and 2 cases immediately
00350 *
00351       M = 0
00352       IF( N.EQ.0 )
00353      $   RETURN
00354 *
00355       IF( N.EQ.1 ) THEN
00356          IF( ALLEIG .OR. INDEIG ) THEN
00357             M = 1
00358             W( 1 ) = D( 1 )
00359          ELSE
00360             IF( WL.LT.D( 1 ) .AND. WU.GE.D( 1 ) ) THEN
00361                M = 1
00362                W( 1 ) = D( 1 )
00363             END IF
00364          END IF
00365          IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
00366             Z( 1, 1 ) = ONE
00367             ISUPPZ(1) = 1
00368             ISUPPZ(2) = 1
00369          END IF
00370          RETURN
00371       END IF
00372 *
00373       IF( N.EQ.2 ) THEN
00374          IF( .NOT.WANTZ ) THEN
00375             CALL SLAE2( D(1), E(1), D(2), R1, R2 )
00376          ELSE IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
00377             CALL SLAEV2( D(1), E(1), D(2), R1, R2, CS, SN )
00378          END IF
00379          IF( ALLEIG.OR.
00380      $      (VALEIG.AND.(R2.GT.WL).AND.
00381      $                  (R2.LE.WU)).OR.
00382      $      (INDEIG.AND.(IIL.EQ.1)) ) THEN
00383             M = M+1
00384             W( M ) = R2
00385             IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
00386                Z( 1, M ) = -SN
00387                Z( 2, M ) = CS
00388 *              Note: At most one of SN and CS can be zero.
00389                IF (SN.NE.ZERO) THEN
00390                   IF (CS.NE.ZERO) THEN
00391                      ISUPPZ(2*M-1) = 1
00392                      ISUPPZ(2*M) = 2
00393                   ELSE
00394                      ISUPPZ(2*M-1) = 1
00395                      ISUPPZ(2*M) = 1
00396                   END IF
00397                ELSE
00398                   ISUPPZ(2*M-1) = 2
00399                   ISUPPZ(2*M) = 2
00400                END IF
00401             ENDIF
00402          ENDIF
00403          IF( ALLEIG.OR.
00404      $      (VALEIG.AND.(R1.GT.WL).AND.
00405      $                  (R1.LE.WU)).OR.
00406      $      (INDEIG.AND.(IIU.EQ.2)) ) THEN
00407             M = M+1
00408             W( M ) = R1
00409             IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
00410                Z( 1, M ) = CS
00411                Z( 2, M ) = SN
00412 *              Note: At most one of SN and CS can be zero.
00413                IF (SN.NE.ZERO) THEN
00414                   IF (CS.NE.ZERO) THEN
00415                      ISUPPZ(2*M-1) = 1
00416                      ISUPPZ(2*M) = 2
00417                   ELSE
00418                      ISUPPZ(2*M-1) = 1
00419                      ISUPPZ(2*M) = 1
00420                   END IF
00421                ELSE
00422                   ISUPPZ(2*M-1) = 2
00423                   ISUPPZ(2*M) = 2
00424                END IF
00425             ENDIF
00426          ENDIF
00427          RETURN
00428       END IF
00429 
00430 *     Continue with general N
00431 
00432       INDGRS = 1
00433       INDERR = 2*N + 1
00434       INDGP = 3*N + 1
00435       INDD = 4*N + 1
00436       INDE2 = 5*N + 1
00437       INDWRK = 6*N + 1
00438 *
00439       IINSPL = 1
00440       IINDBL = N + 1
00441       IINDW = 2*N + 1
00442       IINDWK = 3*N + 1
00443 *
00444 *     Scale matrix to allowable range, if necessary.
00445 *     The allowable range is related to the PIVMIN parameter; see the
00446 *     comments in SLARRD.  The preference for scaling small values
00447 *     up is heuristic; we expect users' matrices not to be close to the
00448 *     RMAX threshold.
00449 *
00450       SCALE = ONE
00451       TNRM = SLANST( 'M', N, D, E )
00452       IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
00453          SCALE = RMIN / TNRM
00454       ELSE IF( TNRM.GT.RMAX ) THEN
00455          SCALE = RMAX / TNRM
00456       END IF
00457       IF( SCALE.NE.ONE ) THEN
00458          CALL SSCAL( N, SCALE, D, 1 )
00459          CALL SSCAL( N-1, SCALE, E, 1 )
00460          TNRM = TNRM*SCALE
00461          IF( VALEIG ) THEN
00462 *           If eigenvalues in interval have to be found,
00463 *           scale (WL, WU] accordingly
00464             WL = WL*SCALE
00465             WU = WU*SCALE
00466          ENDIF
00467       END IF
00468 *
00469 *     Compute the desired eigenvalues of the tridiagonal after splitting
00470 *     into smaller subblocks if the corresponding off-diagonal elements
00471 *     are small
00472 *     THRESH is the splitting parameter for SLARRE
00473 *     A negative THRESH forces the old splitting criterion based on the
00474 *     size of the off-diagonal. A positive THRESH switches to splitting
00475 *     which preserves relative accuracy.
00476 *
00477       IF( TRYRAC ) THEN
00478 *        Test whether the matrix warrants the more expensive relative approach.
00479          CALL SLARRR( N, D, E, IINFO )
00480       ELSE
00481 *        The user does not care about relative accurately eigenvalues
00482          IINFO = -1
00483       ENDIF
00484 *     Set the splitting criterion
00485       IF (IINFO.EQ.0) THEN
00486          THRESH = EPS
00487       ELSE
00488          THRESH = -EPS
00489 *        relative accuracy is desired but T does not guarantee it
00490          TRYRAC = .FALSE.
00491       ENDIF
00492 *
00493       IF( TRYRAC ) THEN
00494 *        Copy original diagonal, needed to guarantee relative accuracy
00495          CALL SCOPY(N,D,1,WORK(INDD),1)
00496       ENDIF
00497 *     Store the squares of the offdiagonal values of T
00498       DO 5 J = 1, N-1
00499          WORK( INDE2+J-1 ) = E(J)**2
00500  5    CONTINUE
00501 
00502 *     Set the tolerance parameters for bisection
00503       IF( .NOT.WANTZ ) THEN
00504 *        SLARRE computes the eigenvalues to full precision.
00505          RTOL1 = FOUR * EPS
00506          RTOL2 = FOUR * EPS
00507       ELSE
00508 *        SLARRE computes the eigenvalues to less than full precision.
00509 *        SLARRV will refine the eigenvalue approximations, and we can
00510 *        need less accurate initial bisection in SLARRE.
00511 *        Note: these settings do only affect the subset case and SLARRE
00512          RTOL1 = MAX( SQRT(EPS)*5.0E-2, FOUR * EPS )
00513          RTOL2 = MAX( SQRT(EPS)*5.0E-3, FOUR * EPS )
00514       ENDIF
00515       CALL SLARRE( RANGE, N, WL, WU, IIL, IIU, D, E,
00516      $             WORK(INDE2), RTOL1, RTOL2, THRESH, NSPLIT,
00517      $             IWORK( IINSPL ), M, W, WORK( INDERR ),
00518      $             WORK( INDGP ), IWORK( IINDBL ),
00519      $             IWORK( IINDW ), WORK( INDGRS ), PIVMIN,
00520      $             WORK( INDWRK ), IWORK( IINDWK ), IINFO )
00521       IF( IINFO.NE.0 ) THEN
00522          INFO = 10 + ABS( IINFO )
00523          RETURN
00524       END IF
00525 *     Note that if RANGE .NE. 'V', SLARRE computes bounds on the desired
00526 *     part of the spectrum. All desired eigenvalues are contained in
00527 *     (WL,WU]
00528 
00529 
00530       IF( WANTZ ) THEN
00531 *
00532 *        Compute the desired eigenvectors corresponding to the computed
00533 *        eigenvalues
00534 *
00535          CALL SLARRV( N, WL, WU, D, E,
00536      $                PIVMIN, IWORK( IINSPL ), M,
00537      $                1, M, MINRGP, RTOL1, RTOL2,
00538      $                W, WORK( INDERR ), WORK( INDGP ), IWORK( IINDBL ),
00539      $                IWORK( IINDW ), WORK( INDGRS ), Z, LDZ,
00540      $                ISUPPZ, WORK( INDWRK ), IWORK( IINDWK ), IINFO )
00541          IF( IINFO.NE.0 ) THEN
00542             INFO = 20 + ABS( IINFO )
00543             RETURN
00544          END IF
00545       ELSE
00546 *        SLARRE computes eigenvalues of the (shifted) root representation
00547 *        SLARRV returns the eigenvalues of the unshifted matrix.
00548 *        However, if the eigenvectors are not desired by the user, we need
00549 *        to apply the corresponding shifts from SLARRE to obtain the
00550 *        eigenvalues of the original matrix.
00551          DO 20 J = 1, M
00552             ITMP = IWORK( IINDBL+J-1 )
00553             W( J ) = W( J ) + E( IWORK( IINSPL+ITMP-1 ) )
00554  20      CONTINUE
00555       END IF
00556 *
00557 
00558       IF ( TRYRAC ) THEN
00559 *        Refine computed eigenvalues so that they are relatively accurate
00560 *        with respect to the original matrix T.
00561          IBEGIN = 1
00562          WBEGIN = 1
00563          DO 39  JBLK = 1, IWORK( IINDBL+M-1 )
00564             IEND = IWORK( IINSPL+JBLK-1 )
00565             IN = IEND - IBEGIN + 1
00566             WEND = WBEGIN - 1
00567 *           check if any eigenvalues have to be refined in this block
00568  36         CONTINUE
00569             IF( WEND.LT.M ) THEN
00570                IF( IWORK( IINDBL+WEND ).EQ.JBLK ) THEN
00571                   WEND = WEND + 1
00572                   GO TO 36
00573                END IF
00574             END IF
00575             IF( WEND.LT.WBEGIN ) THEN
00576                IBEGIN = IEND + 1
00577                GO TO 39
00578             END IF
00579 
00580             OFFSET = IWORK(IINDW+WBEGIN-1)-1
00581             IFIRST = IWORK(IINDW+WBEGIN-1)
00582             ILAST = IWORK(IINDW+WEND-1)
00583             RTOL2 = FOUR * EPS
00584             CALL SLARRJ( IN,
00585      $                   WORK(INDD+IBEGIN-1), WORK(INDE2+IBEGIN-1),
00586      $                   IFIRST, ILAST, RTOL2, OFFSET, W(WBEGIN),
00587      $                   WORK( INDERR+WBEGIN-1 ),
00588      $                   WORK( INDWRK ), IWORK( IINDWK ), PIVMIN,
00589      $                   TNRM, IINFO )
00590             IBEGIN = IEND + 1
00591             WBEGIN = WEND + 1
00592  39      CONTINUE
00593       ENDIF
00594 *
00595 *     If matrix was scaled, then rescale eigenvalues appropriately.
00596 *
00597       IF( SCALE.NE.ONE ) THEN
00598          CALL SSCAL( M, ONE / SCALE, W, 1 )
00599       END IF
00600 *
00601 *     If eigenvalues are not in increasing order, then sort them,
00602 *     possibly along with eigenvectors.
00603 *
00604       IF( NSPLIT.GT.1 ) THEN
00605          IF( .NOT. WANTZ ) THEN
00606             CALL SLASRT( 'I', M, W, IINFO )
00607             IF( IINFO.NE.0 ) THEN
00608                INFO = 3
00609                RETURN
00610             END IF
00611          ELSE
00612             DO 60 J = 1, M - 1
00613                I = 0
00614                TMP = W( J )
00615                DO 50 JJ = J + 1, M
00616                   IF( W( JJ ).LT.TMP ) THEN
00617                      I = JJ
00618                      TMP = W( JJ )
00619                   END IF
00620  50            CONTINUE
00621                IF( I.NE.0 ) THEN
00622                   W( I ) = W( J )
00623                   W( J ) = TMP
00624                   IF( WANTZ ) THEN
00625                      CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
00626                      ITMP = ISUPPZ( 2*I-1 )
00627                      ISUPPZ( 2*I-1 ) = ISUPPZ( 2*J-1 )
00628                      ISUPPZ( 2*J-1 ) = ITMP
00629                      ITMP = ISUPPZ( 2*I )
00630                      ISUPPZ( 2*I ) = ISUPPZ( 2*J )
00631                      ISUPPZ( 2*J ) = ITMP
00632                   END IF
00633                END IF
00634  60         CONTINUE
00635          END IF
00636       ENDIF
00637 *
00638 *
00639       WORK( 1 ) = LWMIN
00640       IWORK( 1 ) = LIWMIN
00641       RETURN
00642 *
00643 *     End of SSTEMR
00644 *
00645       END
 All Files Functions