LAPACK 3.3.0

zstemr.f

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