LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
ssyevr.f
Go to the documentation of this file.
00001 *> \brief <b> SSYEVR computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SSYEVR + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssyevr.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssyevr.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssyevr.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SSYEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
00022 *                          ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK, LWORK,
00023 *                          IWORK, LIWORK, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          JOBZ, RANGE, UPLO
00027 *       INTEGER            IL, INFO, IU, LDA, LDZ, LIWORK, LWORK, M, N
00028 *       REAL               ABSTOL, VL, VU
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            ISUPPZ( * ), IWORK( * )
00032 *       REAL               A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
00033 *       ..
00034 *  
00035 *
00036 *> \par Purpose:
00037 *  =============
00038 *>
00039 *> \verbatim
00040 *>
00041 *> SSYEVR computes selected eigenvalues and, optionally, eigenvectors
00042 *> of a real symmetric matrix A.  Eigenvalues and eigenvectors can be
00043 *> selected by specifying either a range of values or a range of
00044 *> indices for the desired eigenvalues.
00045 *>
00046 *> SSYEVR first reduces the matrix A to tridiagonal form T with a call
00047 *> to SSYTRD.  Then, whenever possible, SSYEVR calls SSTEMR to compute
00048 *> the eigenspectrum using Relatively Robust Representations.  SSTEMR
00049 *> computes eigenvalues by the dqds algorithm, while orthogonal
00050 *> eigenvectors are computed from various "good" L D L^T representations
00051 *> (also known as Relatively Robust Representations). Gram-Schmidt
00052 *> orthogonalization is avoided as far as possible. More specifically,
00053 *> the various steps of the algorithm are as follows.
00054 *>
00055 *> For each unreduced block (submatrix) of T,
00056 *>    (a) Compute T - sigma I  = L D L^T, so that L and D
00057 *>        define all the wanted eigenvalues to high relative accuracy.
00058 *>        This means that small relative changes in the entries of D and L
00059 *>        cause only small relative changes in the eigenvalues and
00060 *>        eigenvectors. The standard (unfactored) representation of the
00061 *>        tridiagonal matrix T does not have this property in general.
00062 *>    (b) Compute the eigenvalues to suitable accuracy.
00063 *>        If the eigenvectors are desired, the algorithm attains full
00064 *>        accuracy of the computed eigenvalues only right before
00065 *>        the corresponding vectors have to be computed, see steps c) and d).
00066 *>    (c) For each cluster of close eigenvalues, select a new
00067 *>        shift close to the cluster, find a new factorization, and refine
00068 *>        the shifted eigenvalues to suitable accuracy.
00069 *>    (d) For each eigenvalue with a large enough relative separation compute
00070 *>        the corresponding eigenvector by forming a rank revealing twisted
00071 *>        factorization. Go back to (c) for any clusters that remain.
00072 *>
00073 *> The desired accuracy of the output can be specified by the input
00074 *> parameter ABSTOL.
00075 *>
00076 *> For more details, see SSTEMR's documentation and:
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 *>
00089 *> Note 1 : SSYEVR calls SSTEMR when the full spectrum is requested
00090 *> on machines which conform to the ieee-754 floating point standard.
00091 *> SSYEVR calls SSTEBZ and SSTEIN on non-ieee machines and
00092 *> when partial spectrum requests are made.
00093 *>
00094 *> Normal execution of SSTEMR may create NaNs and infinities and
00095 *> hence may abort due to a floating point exception in environments
00096 *> which do not handle NaNs and infinities in the ieee standard default
00097 *> manner.
00098 *> \endverbatim
00099 *
00100 *  Arguments:
00101 *  ==========
00102 *
00103 *> \param[in] JOBZ
00104 *> \verbatim
00105 *>          JOBZ is CHARACTER*1
00106 *>          = 'N':  Compute eigenvalues only;
00107 *>          = 'V':  Compute eigenvalues and eigenvectors.
00108 *> \endverbatim
00109 *>
00110 *> \param[in] RANGE
00111 *> \verbatim
00112 *>          RANGE is CHARACTER*1
00113 *>          = 'A': all eigenvalues will be found.
00114 *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
00115 *>                 will be found.
00116 *>          = 'I': the IL-th through IU-th eigenvalues will be found.
00117 *>          For RANGE = 'V' or 'I' and IU - IL < N - 1, SSTEBZ and
00118 *>          SSTEIN are called
00119 *> \endverbatim
00120 *>
00121 *> \param[in] UPLO
00122 *> \verbatim
00123 *>          UPLO is CHARACTER*1
00124 *>          = 'U':  Upper triangle of A is stored;
00125 *>          = 'L':  Lower triangle of A is stored.
00126 *> \endverbatim
00127 *>
00128 *> \param[in] N
00129 *> \verbatim
00130 *>          N is INTEGER
00131 *>          The order of the matrix A.  N >= 0.
00132 *> \endverbatim
00133 *>
00134 *> \param[in,out] A
00135 *> \verbatim
00136 *>          A is REAL array, dimension (LDA, N)
00137 *>          On entry, the symmetric matrix A.  If UPLO = 'U', the
00138 *>          leading N-by-N upper triangular part of A contains the
00139 *>          upper triangular part of the matrix A.  If UPLO = 'L',
00140 *>          the leading N-by-N lower triangular part of A contains
00141 *>          the lower triangular part of the matrix A.
00142 *>          On exit, the lower triangle (if UPLO='L') or the upper
00143 *>          triangle (if UPLO='U') of A, including the diagonal, is
00144 *>          destroyed.
00145 *> \endverbatim
00146 *>
00147 *> \param[in] LDA
00148 *> \verbatim
00149 *>          LDA is INTEGER
00150 *>          The leading dimension of the array A.  LDA >= max(1,N).
00151 *> \endverbatim
00152 *>
00153 *> \param[in] VL
00154 *> \verbatim
00155 *>          VL is REAL
00156 *> \endverbatim
00157 *>
00158 *> \param[in] VU
00159 *> \verbatim
00160 *>          VU is REAL
00161 *>          If RANGE='V', the lower and upper bounds of the interval to
00162 *>          be searched for eigenvalues. VL < VU.
00163 *>          Not referenced if RANGE = 'A' or 'I'.
00164 *> \endverbatim
00165 *>
00166 *> \param[in] IL
00167 *> \verbatim
00168 *>          IL is INTEGER
00169 *> \endverbatim
00170 *>
00171 *> \param[in] IU
00172 *> \verbatim
00173 *>          IU is INTEGER
00174 *>          If RANGE='I', the indices (in ascending order) of the
00175 *>          smallest and largest eigenvalues to be returned.
00176 *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00177 *>          Not referenced if RANGE = 'A' or 'V'.
00178 *> \endverbatim
00179 *>
00180 *> \param[in] ABSTOL
00181 *> \verbatim
00182 *>          ABSTOL is REAL
00183 *>          The absolute error tolerance for the eigenvalues.
00184 *>          An approximate eigenvalue is accepted as converged
00185 *>          when it is determined to lie in an interval [a,b]
00186 *>          of width less than or equal to
00187 *>
00188 *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
00189 *>
00190 *>          where EPS is the machine precision.  If ABSTOL is less than
00191 *>          or equal to zero, then  EPS*|T|  will be used in its place,
00192 *>          where |T| is the 1-norm of the tridiagonal matrix obtained
00193 *>          by reducing A to tridiagonal form.
00194 *>
00195 *>          See "Computing Small Singular Values of Bidiagonal Matrices
00196 *>          with Guaranteed High Relative Accuracy," by Demmel and
00197 *>          Kahan, LAPACK Working Note #3.
00198 *>
00199 *>          If high relative accuracy is important, set ABSTOL to
00200 *>          SLAMCH( 'Safe minimum' ).  Doing so will guarantee that
00201 *>          eigenvalues are computed to high relative accuracy when
00202 *>          possible in future releases.  The current code does not
00203 *>          make any guarantees about high relative accuracy, but
00204 *>          future releases will. See J. Barlow and J. Demmel,
00205 *>          "Computing Accurate Eigensystems of Scaled Diagonally
00206 *>          Dominant Matrices", LAPACK Working Note #7, for a discussion
00207 *>          of which matrices define their eigenvalues to high relative
00208 *>          accuracy.
00209 *> \endverbatim
00210 *>
00211 *> \param[out] M
00212 *> \verbatim
00213 *>          M is INTEGER
00214 *>          The total number of eigenvalues found.  0 <= M <= N.
00215 *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00216 *> \endverbatim
00217 *>
00218 *> \param[out] W
00219 *> \verbatim
00220 *>          W is REAL array, dimension (N)
00221 *>          The first M elements contain the selected eigenvalues in
00222 *>          ascending order.
00223 *> \endverbatim
00224 *>
00225 *> \param[out] Z
00226 *> \verbatim
00227 *>          Z is REAL array, dimension (LDZ, max(1,M))
00228 *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00229 *>          contain the orthonormal eigenvectors of the matrix A
00230 *>          corresponding to the selected eigenvalues, with the i-th
00231 *>          column of Z holding the eigenvector associated with W(i).
00232 *>          If JOBZ = 'N', then Z is not referenced.
00233 *>          Note: the user must ensure that at least max(1,M) columns are
00234 *>          supplied in the array Z; if RANGE = 'V', the exact value of M
00235 *>          is not known in advance and an upper bound must be used.
00236 *>          Supplying N columns is always safe.
00237 *> \endverbatim
00238 *>
00239 *> \param[in] LDZ
00240 *> \verbatim
00241 *>          LDZ is INTEGER
00242 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00243 *>          JOBZ = 'V', LDZ >= max(1,N).
00244 *> \endverbatim
00245 *>
00246 *> \param[out] ISUPPZ
00247 *> \verbatim
00248 *>          ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
00249 *>          The support of the eigenvectors in Z, i.e., the indices
00250 *>          indicating the nonzero elements in Z. The i-th eigenvector
00251 *>          is nonzero only in elements ISUPPZ( 2*i-1 ) through
00252 *>          ISUPPZ( 2*i ).
00253 *>          Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
00254 *> \endverbatim
00255 *>
00256 *> \param[out] WORK
00257 *> \verbatim
00258 *>          WORK is REAL array, dimension (MAX(1,LWORK))
00259 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00260 *> \endverbatim
00261 *>
00262 *> \param[in] LWORK
00263 *> \verbatim
00264 *>          LWORK is INTEGER
00265 *>          The dimension of the array WORK.  LWORK >= max(1,26*N).
00266 *>          For optimal efficiency, LWORK >= (NB+6)*N,
00267 *>          where NB is the max of the blocksize for SSYTRD and SORMTR
00268 *>          returned by ILAENV.
00269 *>
00270 *>          If LWORK = -1, then a workspace query is assumed; the routine
00271 *>          only calculates the optimal sizes of the WORK and IWORK
00272 *>          arrays, returns these values as the first entries of the WORK
00273 *>          and IWORK arrays, and no error message related to LWORK or
00274 *>          LIWORK is issued by XERBLA.
00275 *> \endverbatim
00276 *>
00277 *> \param[out] IWORK
00278 *> \verbatim
00279 *>          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
00280 *>          On exit, if INFO = 0, IWORK(1) returns the optimal LWORK.
00281 *> \endverbatim
00282 *>
00283 *> \param[in] LIWORK
00284 *> \verbatim
00285 *>          LIWORK is INTEGER
00286 *>          The dimension of the array IWORK.  LIWORK >= max(1,10*N).
00287 *>
00288 *>          If LIWORK = -1, then a workspace query is assumed; the
00289 *>          routine only calculates the optimal sizes of the WORK and
00290 *>          IWORK arrays, returns these values as the first entries of
00291 *>          the WORK and IWORK arrays, and no error message related to
00292 *>          LWORK or LIWORK is issued by XERBLA.
00293 *> \endverbatim
00294 *>
00295 *> \param[out] INFO
00296 *> \verbatim
00297 *>          INFO is INTEGER
00298 *>          = 0:  successful exit
00299 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00300 *>          > 0:  Internal error
00301 *> \endverbatim
00302 *
00303 *  Authors:
00304 *  ========
00305 *
00306 *> \author Univ. of Tennessee 
00307 *> \author Univ. of California Berkeley 
00308 *> \author Univ. of Colorado Denver 
00309 *> \author NAG Ltd. 
00310 *
00311 *> \date November 2011
00312 *
00313 *> \ingroup realSYeigen
00314 *
00315 *> \par Contributors:
00316 *  ==================
00317 *>
00318 *>     Inderjit Dhillon, IBM Almaden, USA \n
00319 *>     Osni Marques, LBNL/NERSC, USA \n
00320 *>     Ken Stanley, Computer Science Division, University of
00321 *>       California at Berkeley, USA \n
00322 *>     Jason Riedy, Computer Science Division, University of
00323 *>       California at Berkeley, USA \n
00324 *>
00325 *  =====================================================================
00326       SUBROUTINE SSYEVR( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
00327      $                   ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK, LWORK,
00328      $                   IWORK, LIWORK, INFO )
00329 *
00330 *  -- LAPACK driver routine (version 3.4.0) --
00331 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00332 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00333 *     November 2011
00334 *
00335 *     .. Scalar Arguments ..
00336       CHARACTER          JOBZ, RANGE, UPLO
00337       INTEGER            IL, INFO, IU, LDA, LDZ, LIWORK, LWORK, M, N
00338       REAL               ABSTOL, VL, VU
00339 *     ..
00340 *     .. Array Arguments ..
00341       INTEGER            ISUPPZ( * ), IWORK( * )
00342       REAL               A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
00343 *     ..
00344 *
00345 * =====================================================================
00346 *
00347 *     .. Parameters ..
00348       REAL               ZERO, ONE, TWO
00349       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
00350 *     ..
00351 *     .. Local Scalars ..
00352       LOGICAL            ALLEIG, INDEIG, LOWER, LQUERY, TEST, VALEIG,
00353      $                   WANTZ, TRYRAC
00354       CHARACTER          ORDER
00355       INTEGER            I, IEEEOK, IINFO, IMAX, INDD, INDDD, INDE,
00356      $                   INDEE, INDIBL, INDIFL, INDISP, INDIWO, INDTAU,
00357      $                   INDWK, INDWKN, ISCALE, J, JJ, LIWMIN,
00358      $                   LLWORK, LLWRKN, LWKOPT, LWMIN, NB, NSPLIT
00359       REAL               ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
00360      $                   SIGMA, SMLNUM, TMP1, VLL, VUU
00361 *     ..
00362 *     .. External Functions ..
00363       LOGICAL            LSAME
00364       INTEGER            ILAENV
00365       REAL               SLAMCH, SLANSY
00366       EXTERNAL           LSAME, ILAENV, SLAMCH, SLANSY
00367 *     ..
00368 *     .. External Subroutines ..
00369       EXTERNAL           SCOPY, SORMTR, SSCAL, SSTEBZ, SSTEMR, SSTEIN,
00370      $                   SSTERF, SSWAP, SSYTRD, XERBLA
00371 *     ..
00372 *     .. Intrinsic Functions ..
00373       INTRINSIC          MAX, MIN, SQRT
00374 *     ..
00375 *     .. Executable Statements ..
00376 *
00377 *     Test the input parameters.
00378 *
00379       IEEEOK = ILAENV( 10, 'SSYEVR', 'N', 1, 2, 3, 4 )
00380 *
00381       LOWER = LSAME( UPLO, 'L' )
00382       WANTZ = LSAME( JOBZ, 'V' )
00383       ALLEIG = LSAME( RANGE, 'A' )
00384       VALEIG = LSAME( RANGE, 'V' )
00385       INDEIG = LSAME( RANGE, 'I' )
00386 *
00387       LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
00388 *
00389       LWMIN = MAX( 1, 26*N )
00390       LIWMIN = MAX( 1, 10*N )
00391 *
00392       INFO = 0
00393       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00394          INFO = -1
00395       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00396          INFO = -2
00397       ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
00398          INFO = -3
00399       ELSE IF( N.LT.0 ) THEN
00400          INFO = -4
00401       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00402          INFO = -6
00403       ELSE
00404          IF( VALEIG ) THEN
00405             IF( N.GT.0 .AND. VU.LE.VL )
00406      $         INFO = -8
00407          ELSE IF( INDEIG ) THEN
00408             IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
00409                INFO = -9
00410             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00411                INFO = -10
00412             END IF
00413          END IF
00414       END IF
00415       IF( INFO.EQ.0 ) THEN
00416          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00417             INFO = -15
00418          END IF
00419       END IF
00420 *
00421       IF( INFO.EQ.0 ) THEN
00422          NB = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 )
00423          NB = MAX( NB, ILAENV( 1, 'SORMTR', UPLO, N, -1, -1, -1 ) )
00424          LWKOPT = MAX( ( NB+1 )*N, LWMIN )
00425          WORK( 1 ) = LWKOPT
00426          IWORK( 1 ) = LIWMIN
00427 *
00428          IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
00429             INFO = -18
00430          ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
00431             INFO = -20
00432          END IF
00433       END IF
00434 *
00435       IF( INFO.NE.0 ) THEN
00436          CALL XERBLA( 'SSYEVR', -INFO )
00437          RETURN
00438       ELSE IF( LQUERY ) THEN
00439          RETURN
00440       END IF
00441 *
00442 *     Quick return if possible
00443 *
00444       M = 0
00445       IF( N.EQ.0 ) THEN
00446          WORK( 1 ) = 1
00447          RETURN
00448       END IF
00449 *
00450       IF( N.EQ.1 ) THEN
00451          WORK( 1 ) = 26
00452          IF( ALLEIG .OR. INDEIG ) THEN
00453             M = 1
00454             W( 1 ) = A( 1, 1 )
00455          ELSE
00456             IF( VL.LT.A( 1, 1 ) .AND. VU.GE.A( 1, 1 ) ) THEN
00457                M = 1
00458                W( 1 ) = A( 1, 1 )
00459             END IF
00460          END IF
00461          IF( WANTZ ) THEN
00462             Z( 1, 1 ) = ONE
00463             ISUPPZ( 1 ) = 1
00464             ISUPPZ( 2 ) = 1
00465          END IF
00466          RETURN
00467       END IF
00468 *
00469 *     Get machine constants.
00470 *
00471       SAFMIN = SLAMCH( 'Safe minimum' )
00472       EPS = SLAMCH( 'Precision' )
00473       SMLNUM = SAFMIN / EPS
00474       BIGNUM = ONE / SMLNUM
00475       RMIN = SQRT( SMLNUM )
00476       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
00477 *
00478 *     Scale matrix to allowable range, if necessary.
00479 *
00480       ISCALE = 0
00481       ABSTLL = ABSTOL
00482       IF (VALEIG) THEN
00483          VLL = VL
00484          VUU = VU
00485       END IF
00486       ANRM = SLANSY( 'M', UPLO, N, A, LDA, WORK )
00487       IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
00488          ISCALE = 1
00489          SIGMA = RMIN / ANRM
00490       ELSE IF( ANRM.GT.RMAX ) THEN
00491          ISCALE = 1
00492          SIGMA = RMAX / ANRM
00493       END IF
00494       IF( ISCALE.EQ.1 ) THEN
00495          IF( LOWER ) THEN
00496             DO 10 J = 1, N
00497                CALL SSCAL( N-J+1, SIGMA, A( J, J ), 1 )
00498    10       CONTINUE
00499          ELSE
00500             DO 20 J = 1, N
00501                CALL SSCAL( J, SIGMA, A( 1, J ), 1 )
00502    20       CONTINUE
00503          END IF
00504          IF( ABSTOL.GT.0 )
00505      $      ABSTLL = ABSTOL*SIGMA
00506          IF( VALEIG ) THEN
00507             VLL = VL*SIGMA
00508             VUU = VU*SIGMA
00509          END IF
00510       END IF
00511 
00512 *     Initialize indices into workspaces.  Note: The IWORK indices are
00513 *     used only if SSTERF or SSTEMR fail.
00514 
00515 *     WORK(INDTAU:INDTAU+N-1) stores the scalar factors of the
00516 *     elementary reflectors used in SSYTRD.
00517       INDTAU = 1
00518 *     WORK(INDD:INDD+N-1) stores the tridiagonal's diagonal entries.
00519       INDD = INDTAU + N
00520 *     WORK(INDE:INDE+N-1) stores the off-diagonal entries of the
00521 *     tridiagonal matrix from SSYTRD.
00522       INDE = INDD + N
00523 *     WORK(INDDD:INDDD+N-1) is a copy of the diagonal entries over
00524 *     -written by SSTEMR (the SSTERF path copies the diagonal to W).
00525       INDDD = INDE + N
00526 *     WORK(INDEE:INDEE+N-1) is a copy of the off-diagonal entries over
00527 *     -written while computing the eigenvalues in SSTERF and SSTEMR.
00528       INDEE = INDDD + N
00529 *     INDWK is the starting offset of the left-over workspace, and
00530 *     LLWORK is the remaining workspace size.
00531       INDWK = INDEE + N
00532       LLWORK = LWORK - INDWK + 1
00533 
00534 *     IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in SSTEBZ and
00535 *     stores the block indices of each of the M<=N eigenvalues.
00536       INDIBL = 1
00537 *     IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in SSTEBZ and
00538 *     stores the starting and finishing indices of each block.
00539       INDISP = INDIBL + N
00540 *     IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
00541 *     that corresponding to eigenvectors that fail to converge in
00542 *     SSTEIN.  This information is discarded; if any fail, the driver
00543 *     returns INFO > 0.
00544       INDIFL = INDISP + N
00545 *     INDIWO is the offset of the remaining integer workspace.
00546       INDIWO = INDISP + N
00547 
00548 *
00549 *     Call SSYTRD to reduce symmetric matrix to tridiagonal form.
00550 *
00551       CALL SSYTRD( UPLO, N, A, LDA, WORK( INDD ), WORK( INDE ),
00552      $             WORK( INDTAU ), WORK( INDWK ), LLWORK, IINFO )
00553 *
00554 *     If all eigenvalues are desired
00555 *     then call SSTERF or SSTEMR and SORMTR.
00556 *
00557       TEST = .FALSE.
00558       IF( INDEIG ) THEN
00559          IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
00560             TEST = .TRUE.
00561          END IF
00562       END IF
00563       IF( ( ALLEIG.OR.TEST ) .AND. ( IEEEOK.EQ.1 ) ) THEN
00564          IF( .NOT.WANTZ ) THEN
00565             CALL SCOPY( N, WORK( INDD ), 1, W, 1 )
00566             CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
00567             CALL SSTERF( N, W, WORK( INDEE ), INFO )
00568          ELSE
00569             CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
00570             CALL SCOPY( N, WORK( INDD ), 1, WORK( INDDD ), 1 )
00571 *
00572             IF (ABSTOL .LE. TWO*N*EPS) THEN
00573                TRYRAC = .TRUE.
00574             ELSE
00575                TRYRAC = .FALSE.
00576             END IF
00577             CALL SSTEMR( JOBZ, 'A', N, WORK( INDDD ), WORK( INDEE ),
00578      $                   VL, VU, IL, IU, M, W, Z, LDZ, N, ISUPPZ,
00579      $                   TRYRAC, WORK( INDWK ), LWORK, IWORK, LIWORK,
00580      $                   INFO )
00581 *
00582 *
00583 *
00584 *        Apply orthogonal matrix used in reduction to tridiagonal
00585 *        form to eigenvectors returned by SSTEIN.
00586 *
00587             IF( WANTZ .AND. INFO.EQ.0 ) THEN
00588                INDWKN = INDE
00589                LLWRKN = LWORK - INDWKN + 1
00590                CALL SORMTR( 'L', UPLO, 'N', N, M, A, LDA,
00591      $                      WORK( INDTAU ), Z, LDZ, WORK( INDWKN ),
00592      $                      LLWRKN, IINFO )
00593             END IF
00594          END IF
00595 *
00596 *
00597          IF( INFO.EQ.0 ) THEN
00598 *           Everything worked.  Skip SSTEBZ/SSTEIN.  IWORK(:) are
00599 *           undefined.
00600             M = N
00601             GO TO 30
00602          END IF
00603          INFO = 0
00604       END IF
00605 *
00606 *     Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
00607 *     Also call SSTEBZ and SSTEIN if SSTEMR fails.
00608 *
00609       IF( WANTZ ) THEN
00610          ORDER = 'B'
00611       ELSE
00612          ORDER = 'E'
00613       END IF
00614 
00615       CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
00616      $             WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
00617      $             IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWK ),
00618      $             IWORK( INDIWO ), INFO )
00619 *
00620       IF( WANTZ ) THEN
00621          CALL SSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
00622      $                IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
00623      $                WORK( INDWK ), IWORK( INDIWO ), IWORK( INDIFL ),
00624      $                INFO )
00625 *
00626 *        Apply orthogonal matrix used in reduction to tridiagonal
00627 *        form to eigenvectors returned by SSTEIN.
00628 *
00629          INDWKN = INDE
00630          LLWRKN = LWORK - INDWKN + 1
00631          CALL SORMTR( 'L', UPLO, 'N', N, M, A, LDA, WORK( INDTAU ), Z,
00632      $                LDZ, WORK( INDWKN ), LLWRKN, IINFO )
00633       END IF
00634 *
00635 *     If matrix was scaled, then rescale eigenvalues appropriately.
00636 *
00637 *  Jump here if SSTEMR/SSTEIN succeeded.
00638    30 CONTINUE
00639       IF( ISCALE.EQ.1 ) THEN
00640          IF( INFO.EQ.0 ) THEN
00641             IMAX = M
00642          ELSE
00643             IMAX = INFO - 1
00644          END IF
00645          CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
00646       END IF
00647 *
00648 *     If eigenvalues are not in order, then sort them, along with
00649 *     eigenvectors.  Note: We do not sort the IFAIL portion of IWORK.
00650 *     It may not be initialized (if SSTEMR/SSTEIN succeeded), and we do
00651 *     not return this detailed information to the user.
00652 *
00653       IF( WANTZ ) THEN
00654          DO 50 J = 1, M - 1
00655             I = 0
00656             TMP1 = W( J )
00657             DO 40 JJ = J + 1, M
00658                IF( W( JJ ).LT.TMP1 ) THEN
00659                   I = JJ
00660                   TMP1 = W( JJ )
00661                END IF
00662    40       CONTINUE
00663 *
00664             IF( I.NE.0 ) THEN
00665                W( I ) = W( J )
00666                W( J ) = TMP1
00667                CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
00668             END IF
00669    50    CONTINUE
00670       END IF
00671 *
00672 *     Set WORK(1) to optimal workspace size.
00673 *
00674       WORK( 1 ) = LWKOPT
00675       IWORK( 1 ) = LIWMIN
00676 *
00677       RETURN
00678 *
00679 *     End of SSYEVR
00680 *
00681       END
 All Files Functions