![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SSTEMR 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SSTEMR + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstemr.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstemr.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstemr.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SSTEMR( 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 * REAL VL, VU 00030 * .. 00031 * .. Array Arguments .. 00032 * INTEGER ISUPPZ( * ), IWORK( * ) 00033 * REAL D( * ), E( * ), W( * ), WORK( * ) 00034 * REAL Z( LDZ, * ) 00035 * .. 00036 * 00037 * 00038 *> \par Purpose: 00039 * ============= 00040 *> 00041 *> \verbatim 00042 *> 00043 *> SSTEMR 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.SSTEMR 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 REAL 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 REAL 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 REAL 00139 *> \endverbatim 00140 *> 00141 *> \param[in] VU 00142 *> \verbatim 00143 *> VU is REAL 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 REAL 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 REAL 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 REAL 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 SLARRE, 00283 *> if INFO = 2X, internal error in SLARRV. 00284 *> Here, the digit X = ABS( IINFO ) < 10, where IINFO is 00285 *> the nonzero error code returned by SLARRE or 00286 *> SLARRV, 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 realOTHERcomputational 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 SSTEMR( 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 REAL VL, VU 00325 * .. 00326 * .. Array Arguments .. 00327 INTEGER ISUPPZ( * ), IWORK( * ) 00328 REAL D( * ), E( * ), W( * ), WORK( * ) 00329 REAL Z( LDZ, * ) 00330 * .. 00331 * 00332 * ===================================================================== 00333 * 00334 * .. Parameters .. 00335 REAL ZERO, ONE, FOUR, MINRGP 00336 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, 00337 $ FOUR = 4.0E0, 00338 $ MINRGP = 3.0E-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 REAL 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 REAL SLAMCH, SLANST 00355 EXTERNAL LSAME, SLAMCH, SLANST 00356 * .. 00357 * .. External Subroutines .. 00358 EXTERNAL SCOPY, SLAE2, SLAEV2, SLARRC, SLARRE, SLARRJ, 00359 $ SLARRR, SLARRV, SLASRT, SSCAL, SSWAP, XERBLA 00360 * .. 00361 * .. Intrinsic Functions .. 00362 INTRINSIC MAX, MIN, SQRT 00363 * .. 00364 * .. Executable Statements .. 00365 * 00366 * Test the input parameters. 00367 * 00368 WANTZ = LSAME( JOBZ, 'V' ) 00369 ALLEIG = LSAME( RANGE, 'A' ) 00370 VALEIG = LSAME( RANGE, 'V' ) 00371 INDEIG = LSAME( RANGE, 'I' ) 00372 * 00373 LQUERY = ( ( LWORK.EQ.-1 ).OR.( LIWORK.EQ.-1 ) ) 00374 ZQUERY = ( NZC.EQ.-1 ) 00375 00376 * SSTEMR needs WORK of size 6*N, IWORK of size 3*N. 00377 * In addition, SLARRE needs WORK of size 6*N, IWORK of size 5*N. 00378 * Furthermore, SLARRV needs WORK of size 12*N, IWORK of size 7*N. 00379 IF( WANTZ ) THEN 00380 LWMIN = 18*N 00381 LIWMIN = 10*N 00382 ELSE 00383 * need less workspace if only the eigenvalues are wanted 00384 LWMIN = 12*N 00385 LIWMIN = 8*N 00386 ENDIF 00387 00388 WL = ZERO 00389 WU = ZERO 00390 IIL = 0 00391 IIU = 0 00392 00393 IF( VALEIG ) THEN 00394 * We do not reference VL, VU in the cases RANGE = 'I','A' 00395 * The interval (WL, WU] contains all the wanted eigenvalues. 00396 * It is either given by the user or computed in SLARRE. 00397 WL = VL 00398 WU = VU 00399 ELSEIF( INDEIG ) THEN 00400 * We do not reference IL, IU in the cases RANGE = 'V','A' 00401 IIL = IL 00402 IIU = IU 00403 ENDIF 00404 * 00405 INFO = 0 00406 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00407 INFO = -1 00408 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN 00409 INFO = -2 00410 ELSE IF( N.LT.0 ) THEN 00411 INFO = -3 00412 ELSE IF( VALEIG .AND. N.GT.0 .AND. WU.LE.WL ) THEN 00413 INFO = -7 00414 ELSE IF( INDEIG .AND. ( IIL.LT.1 .OR. IIL.GT.N ) ) THEN 00415 INFO = -8 00416 ELSE IF( INDEIG .AND. ( IIU.LT.IIL .OR. IIU.GT.N ) ) THEN 00417 INFO = -9 00418 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00419 INFO = -13 00420 ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00421 INFO = -17 00422 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00423 INFO = -19 00424 END IF 00425 * 00426 * Get machine constants. 00427 * 00428 SAFMIN = SLAMCH( 'Safe minimum' ) 00429 EPS = SLAMCH( 'Precision' ) 00430 SMLNUM = SAFMIN / EPS 00431 BIGNUM = ONE / SMLNUM 00432 RMIN = SQRT( SMLNUM ) 00433 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) ) 00434 * 00435 IF( INFO.EQ.0 ) THEN 00436 WORK( 1 ) = LWMIN 00437 IWORK( 1 ) = LIWMIN 00438 * 00439 IF( WANTZ .AND. ALLEIG ) THEN 00440 NZCMIN = N 00441 ELSE IF( WANTZ .AND. VALEIG ) THEN 00442 CALL SLARRC( 'T', N, VL, VU, D, E, SAFMIN, 00443 $ NZCMIN, ITMP, ITMP2, INFO ) 00444 ELSE IF( WANTZ .AND. INDEIG ) THEN 00445 NZCMIN = IIU-IIL+1 00446 ELSE 00447 * WANTZ .EQ. FALSE. 00448 NZCMIN = 0 00449 ENDIF 00450 IF( ZQUERY .AND. INFO.EQ.0 ) THEN 00451 Z( 1,1 ) = NZCMIN 00452 ELSE IF( NZC.LT.NZCMIN .AND. .NOT.ZQUERY ) THEN 00453 INFO = -14 00454 END IF 00455 END IF 00456 00457 IF( INFO.NE.0 ) THEN 00458 * 00459 CALL XERBLA( 'SSTEMR', -INFO ) 00460 * 00461 RETURN 00462 ELSE IF( LQUERY .OR. ZQUERY ) THEN 00463 RETURN 00464 END IF 00465 * 00466 * Handle N = 0, 1, and 2 cases immediately 00467 * 00468 M = 0 00469 IF( N.EQ.0 ) 00470 $ RETURN 00471 * 00472 IF( N.EQ.1 ) THEN 00473 IF( ALLEIG .OR. INDEIG ) THEN 00474 M = 1 00475 W( 1 ) = D( 1 ) 00476 ELSE 00477 IF( WL.LT.D( 1 ) .AND. WU.GE.D( 1 ) ) THEN 00478 M = 1 00479 W( 1 ) = D( 1 ) 00480 END IF 00481 END IF 00482 IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN 00483 Z( 1, 1 ) = ONE 00484 ISUPPZ(1) = 1 00485 ISUPPZ(2) = 1 00486 END IF 00487 RETURN 00488 END IF 00489 * 00490 IF( N.EQ.2 ) THEN 00491 IF( .NOT.WANTZ ) THEN 00492 CALL SLAE2( D(1), E(1), D(2), R1, R2 ) 00493 ELSE IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN 00494 CALL SLAEV2( D(1), E(1), D(2), R1, R2, CS, SN ) 00495 END IF 00496 IF( ALLEIG.OR. 00497 $ (VALEIG.AND.(R2.GT.WL).AND. 00498 $ (R2.LE.WU)).OR. 00499 $ (INDEIG.AND.(IIL.EQ.1)) ) THEN 00500 M = M+1 00501 W( M ) = R2 00502 IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN 00503 Z( 1, M ) = -SN 00504 Z( 2, M ) = CS 00505 * Note: At most one of SN and CS can be zero. 00506 IF (SN.NE.ZERO) THEN 00507 IF (CS.NE.ZERO) THEN 00508 ISUPPZ(2*M-1) = 1 00509 ISUPPZ(2*M) = 2 00510 ELSE 00511 ISUPPZ(2*M-1) = 1 00512 ISUPPZ(2*M) = 1 00513 END IF 00514 ELSE 00515 ISUPPZ(2*M-1) = 2 00516 ISUPPZ(2*M) = 2 00517 END IF 00518 ENDIF 00519 ENDIF 00520 IF( ALLEIG.OR. 00521 $ (VALEIG.AND.(R1.GT.WL).AND. 00522 $ (R1.LE.WU)).OR. 00523 $ (INDEIG.AND.(IIU.EQ.2)) ) THEN 00524 M = M+1 00525 W( M ) = R1 00526 IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN 00527 Z( 1, M ) = CS 00528 Z( 2, M ) = SN 00529 * Note: At most one of SN and CS can be zero. 00530 IF (SN.NE.ZERO) THEN 00531 IF (CS.NE.ZERO) THEN 00532 ISUPPZ(2*M-1) = 1 00533 ISUPPZ(2*M) = 2 00534 ELSE 00535 ISUPPZ(2*M-1) = 1 00536 ISUPPZ(2*M) = 1 00537 END IF 00538 ELSE 00539 ISUPPZ(2*M-1) = 2 00540 ISUPPZ(2*M) = 2 00541 END IF 00542 ENDIF 00543 ENDIF 00544 RETURN 00545 END IF 00546 00547 * Continue with general N 00548 00549 INDGRS = 1 00550 INDERR = 2*N + 1 00551 INDGP = 3*N + 1 00552 INDD = 4*N + 1 00553 INDE2 = 5*N + 1 00554 INDWRK = 6*N + 1 00555 * 00556 IINSPL = 1 00557 IINDBL = N + 1 00558 IINDW = 2*N + 1 00559 IINDWK = 3*N + 1 00560 * 00561 * Scale matrix to allowable range, if necessary. 00562 * The allowable range is related to the PIVMIN parameter; see the 00563 * comments in SLARRD. The preference for scaling small values 00564 * up is heuristic; we expect users' matrices not to be close to the 00565 * RMAX threshold. 00566 * 00567 SCALE = ONE 00568 TNRM = SLANST( 'M', N, D, E ) 00569 IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN 00570 SCALE = RMIN / TNRM 00571 ELSE IF( TNRM.GT.RMAX ) THEN 00572 SCALE = RMAX / TNRM 00573 END IF 00574 IF( SCALE.NE.ONE ) THEN 00575 CALL SSCAL( N, SCALE, D, 1 ) 00576 CALL SSCAL( N-1, SCALE, E, 1 ) 00577 TNRM = TNRM*SCALE 00578 IF( VALEIG ) THEN 00579 * If eigenvalues in interval have to be found, 00580 * scale (WL, WU] accordingly 00581 WL = WL*SCALE 00582 WU = WU*SCALE 00583 ENDIF 00584 END IF 00585 * 00586 * Compute the desired eigenvalues of the tridiagonal after splitting 00587 * into smaller subblocks if the corresponding off-diagonal elements 00588 * are small 00589 * THRESH is the splitting parameter for SLARRE 00590 * A negative THRESH forces the old splitting criterion based on the 00591 * size of the off-diagonal. A positive THRESH switches to splitting 00592 * which preserves relative accuracy. 00593 * 00594 IF( TRYRAC ) THEN 00595 * Test whether the matrix warrants the more expensive relative approach. 00596 CALL SLARRR( N, D, E, IINFO ) 00597 ELSE 00598 * The user does not care about relative accurately eigenvalues 00599 IINFO = -1 00600 ENDIF 00601 * Set the splitting criterion 00602 IF (IINFO.EQ.0) THEN 00603 THRESH = EPS 00604 ELSE 00605 THRESH = -EPS 00606 * relative accuracy is desired but T does not guarantee it 00607 TRYRAC = .FALSE. 00608 ENDIF 00609 * 00610 IF( TRYRAC ) THEN 00611 * Copy original diagonal, needed to guarantee relative accuracy 00612 CALL SCOPY(N,D,1,WORK(INDD),1) 00613 ENDIF 00614 * Store the squares of the offdiagonal values of T 00615 DO 5 J = 1, N-1 00616 WORK( INDE2+J-1 ) = E(J)**2 00617 5 CONTINUE 00618 00619 * Set the tolerance parameters for bisection 00620 IF( .NOT.WANTZ ) THEN 00621 * SLARRE computes the eigenvalues to full precision. 00622 RTOL1 = FOUR * EPS 00623 RTOL2 = FOUR * EPS 00624 ELSE 00625 * SLARRE computes the eigenvalues to less than full precision. 00626 * SLARRV will refine the eigenvalue approximations, and we can 00627 * need less accurate initial bisection in SLARRE. 00628 * Note: these settings do only affect the subset case and SLARRE 00629 RTOL1 = MAX( SQRT(EPS)*5.0E-2, FOUR * EPS ) 00630 RTOL2 = MAX( SQRT(EPS)*5.0E-3, FOUR * EPS ) 00631 ENDIF 00632 CALL SLARRE( RANGE, N, WL, WU, IIL, IIU, D, E, 00633 $ WORK(INDE2), RTOL1, RTOL2, THRESH, NSPLIT, 00634 $ IWORK( IINSPL ), M, W, WORK( INDERR ), 00635 $ WORK( INDGP ), IWORK( IINDBL ), 00636 $ IWORK( IINDW ), WORK( INDGRS ), PIVMIN, 00637 $ WORK( INDWRK ), IWORK( IINDWK ), IINFO ) 00638 IF( IINFO.NE.0 ) THEN 00639 INFO = 10 + ABS( IINFO ) 00640 RETURN 00641 END IF 00642 * Note that if RANGE .NE. 'V', SLARRE computes bounds on the desired 00643 * part of the spectrum. All desired eigenvalues are contained in 00644 * (WL,WU] 00645 00646 00647 IF( WANTZ ) THEN 00648 * 00649 * Compute the desired eigenvectors corresponding to the computed 00650 * eigenvalues 00651 * 00652 CALL SLARRV( N, WL, WU, D, E, 00653 $ PIVMIN, IWORK( IINSPL ), M, 00654 $ 1, M, MINRGP, RTOL1, RTOL2, 00655 $ W, WORK( INDERR ), WORK( INDGP ), IWORK( IINDBL ), 00656 $ IWORK( IINDW ), WORK( INDGRS ), Z, LDZ, 00657 $ ISUPPZ, WORK( INDWRK ), IWORK( IINDWK ), IINFO ) 00658 IF( IINFO.NE.0 ) THEN 00659 INFO = 20 + ABS( IINFO ) 00660 RETURN 00661 END IF 00662 ELSE 00663 * SLARRE computes eigenvalues of the (shifted) root representation 00664 * SLARRV returns the eigenvalues of the unshifted matrix. 00665 * However, if the eigenvectors are not desired by the user, we need 00666 * to apply the corresponding shifts from SLARRE to obtain the 00667 * eigenvalues of the original matrix. 00668 DO 20 J = 1, M 00669 ITMP = IWORK( IINDBL+J-1 ) 00670 W( J ) = W( J ) + E( IWORK( IINSPL+ITMP-1 ) ) 00671 20 CONTINUE 00672 END IF 00673 * 00674 00675 IF ( TRYRAC ) THEN 00676 * Refine computed eigenvalues so that they are relatively accurate 00677 * with respect to the original matrix T. 00678 IBEGIN = 1 00679 WBEGIN = 1 00680 DO 39 JBLK = 1, IWORK( IINDBL+M-1 ) 00681 IEND = IWORK( IINSPL+JBLK-1 ) 00682 IN = IEND - IBEGIN + 1 00683 WEND = WBEGIN - 1 00684 * check if any eigenvalues have to be refined in this block 00685 36 CONTINUE 00686 IF( WEND.LT.M ) THEN 00687 IF( IWORK( IINDBL+WEND ).EQ.JBLK ) THEN 00688 WEND = WEND + 1 00689 GO TO 36 00690 END IF 00691 END IF 00692 IF( WEND.LT.WBEGIN ) THEN 00693 IBEGIN = IEND + 1 00694 GO TO 39 00695 END IF 00696 00697 OFFSET = IWORK(IINDW+WBEGIN-1)-1 00698 IFIRST = IWORK(IINDW+WBEGIN-1) 00699 ILAST = IWORK(IINDW+WEND-1) 00700 RTOL2 = FOUR * EPS 00701 CALL SLARRJ( IN, 00702 $ WORK(INDD+IBEGIN-1), WORK(INDE2+IBEGIN-1), 00703 $ IFIRST, ILAST, RTOL2, OFFSET, W(WBEGIN), 00704 $ WORK( INDERR+WBEGIN-1 ), 00705 $ WORK( INDWRK ), IWORK( IINDWK ), PIVMIN, 00706 $ TNRM, IINFO ) 00707 IBEGIN = IEND + 1 00708 WBEGIN = WEND + 1 00709 39 CONTINUE 00710 ENDIF 00711 * 00712 * If matrix was scaled, then rescale eigenvalues appropriately. 00713 * 00714 IF( SCALE.NE.ONE ) THEN 00715 CALL SSCAL( M, ONE / SCALE, W, 1 ) 00716 END IF 00717 * 00718 * If eigenvalues are not in increasing order, then sort them, 00719 * possibly along with eigenvectors. 00720 * 00721 IF( NSPLIT.GT.1 ) THEN 00722 IF( .NOT. WANTZ ) THEN 00723 CALL SLASRT( 'I', M, W, IINFO ) 00724 IF( IINFO.NE.0 ) THEN 00725 INFO = 3 00726 RETURN 00727 END IF 00728 ELSE 00729 DO 60 J = 1, M - 1 00730 I = 0 00731 TMP = W( J ) 00732 DO 50 JJ = J + 1, M 00733 IF( W( JJ ).LT.TMP ) THEN 00734 I = JJ 00735 TMP = W( JJ ) 00736 END IF 00737 50 CONTINUE 00738 IF( I.NE.0 ) THEN 00739 W( I ) = W( J ) 00740 W( J ) = TMP 00741 IF( WANTZ ) THEN 00742 CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 ) 00743 ITMP = ISUPPZ( 2*I-1 ) 00744 ISUPPZ( 2*I-1 ) = ISUPPZ( 2*J-1 ) 00745 ISUPPZ( 2*J-1 ) = ITMP 00746 ITMP = ISUPPZ( 2*I ) 00747 ISUPPZ( 2*I ) = ISUPPZ( 2*J ) 00748 ISUPPZ( 2*J ) = ITMP 00749 END IF 00750 END IF 00751 60 CONTINUE 00752 END IF 00753 ENDIF 00754 * 00755 * 00756 WORK( 1 ) = LWMIN 00757 IWORK( 1 ) = LIWMIN 00758 RETURN 00759 * 00760 * End of SSTEMR 00761 * 00762 END