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