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