1 *> \brief <b> SSTEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SSTEVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstevx.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstevx.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstevx.f">
21 * SUBROUTINE SSTEVX( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
22 * M, W, Z, LDZ, WORK, IWORK, IFAIL, INFO )
24 * .. Scalar Arguments ..
25 * CHARACTER JOBZ, RANGE
26 * INTEGER IL, INFO, IU, LDZ, M, N
29 * .. Array Arguments ..
30 * INTEGER IFAIL( * ), IWORK( * )
31 * REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
40 *> SSTEVX computes selected eigenvalues and, optionally, eigenvectors
41 *> of a real symmetric tridiagonal matrix A. Eigenvalues and
42 *> eigenvectors can be selected by specifying either a range of values
43 *> or a range of indices for the desired eigenvalues.
51 *> JOBZ is CHARACTER*1
52 *> = 'N': Compute eigenvalues only;
53 *> = 'V': Compute eigenvalues and eigenvectors.
58 *> RANGE is CHARACTER*1
59 *> = 'A': all eigenvalues will be found.
60 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
62 *> = 'I': the IL-th through IU-th eigenvalues will be found.
68 *> The order of the matrix. N >= 0.
73 *> D is REAL array, dimension (N)
74 *> On entry, the n diagonal elements of the tridiagonal matrix
76 *> On exit, D may be multiplied by a constant factor chosen
77 *> to avoid over/underflow in computing the eigenvalues.
82 *> E is REAL array, dimension (max(1,N-1))
83 *> On entry, the (n-1) subdiagonal elements of the tridiagonal
84 *> matrix A in elements 1 to N-1 of E.
85 *> On exit, E may be multiplied by a constant factor chosen
86 *> to avoid over/underflow in computing the eigenvalues.
92 *> If RANGE='V', the lower bound of the interval to
93 *> be searched for eigenvalues. VL < VU.
94 *> Not referenced if RANGE = 'A' or 'I'.
100 *> If RANGE='V', the upper bound of the interval to
101 *> be searched for eigenvalues. VL < VU.
102 *> Not referenced if RANGE = 'A' or 'I'.
108 *> If RANGE='I', the index of the
109 *> smallest eigenvalue to be returned.
110 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
111 *> Not referenced if RANGE = 'A' or 'V'.
117 *> If RANGE='I', the index of the
118 *> largest eigenvalue to be returned.
119 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
120 *> Not referenced if RANGE = 'A' or 'V'.
126 *> The absolute error tolerance for the eigenvalues.
127 *> An approximate eigenvalue is accepted as converged
128 *> when it is determined to lie in an interval [a,b]
129 *> of width less than or equal to
131 *> ABSTOL + EPS * max( |a|,|b| ) ,
133 *> where EPS is the machine precision. If ABSTOL is less
134 *> than or equal to zero, then EPS*|T| will be used in
135 *> its place, where |T| is the 1-norm of the tridiagonal
138 *> Eigenvalues will be computed most accurately when ABSTOL is
139 *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
140 *> If this routine returns with INFO>0, indicating that some
141 *> eigenvectors did not converge, try setting ABSTOL to
144 *> See "Computing Small Singular Values of Bidiagonal Matrices
145 *> with Guaranteed High Relative Accuracy," by Demmel and
146 *> Kahan, LAPACK Working Note #3.
152 *> The total number of eigenvalues found. 0 <= M <= N.
153 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
158 *> W is REAL array, dimension (N)
159 *> The first M elements contain the selected eigenvalues in
165 *> Z is REAL array, dimension (LDZ, max(1,M) )
166 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
167 *> contain the orthonormal eigenvectors of the matrix A
168 *> corresponding to the selected eigenvalues, with the i-th
169 *> column of Z holding the eigenvector associated with W(i).
170 *> If an eigenvector fails to converge (INFO > 0), then that
171 *> column of Z contains the latest approximation to the
172 *> eigenvector, and the index of the eigenvector is returned
173 *> in IFAIL. If JOBZ = 'N', then Z is not referenced.
174 *> Note: the user must ensure that at least max(1,M) columns are
175 *> supplied in the array Z; if RANGE = 'V', the exact value of M
176 *> is not known in advance and an upper bound must be used.
182 *> The leading dimension of the array Z. LDZ >= 1, and if
183 *> JOBZ = 'V', LDZ >= max(1,N).
188 *> WORK is REAL array, dimension (5*N)
193 *> IWORK is INTEGER array, dimension (5*N)
198 *> IFAIL is INTEGER array, dimension (N)
199 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
200 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
201 *> indices of the eigenvectors that failed to converge.
202 *> If JOBZ = 'N', then IFAIL is not referenced.
208 *> = 0: successful exit
209 *> < 0: if INFO = -i, the i-th argument had an illegal value
210 *> > 0: if INFO = i, then i eigenvectors failed to converge.
211 *> Their indices are stored in array IFAIL.
217 *> \author Univ. of Tennessee
218 *> \author Univ. of California Berkeley
219 *> \author Univ. of Colorado Denver
224 *> \ingroup realOTHEReigen
226 * =====================================================================
227 SUBROUTINE SSTEVX( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
228 $ M, W, Z, LDZ, WORK, IWORK, IFAIL, INFO )
230 * -- LAPACK driver routine (version 3.6.1) --
231 * -- LAPACK is a software package provided by Univ. of Tennessee, --
232 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
235 * .. Scalar Arguments ..
236 CHARACTER JOBZ, RANGE
237 INTEGER IL, INFO, IU, LDZ, M, N
240 * .. Array Arguments ..
241 INTEGER IFAIL( * ), IWORK( * )
242 REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
245 * =====================================================================
249 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
251 * .. Local Scalars ..
252 LOGICAL ALLEIG, INDEIG, TEST, VALEIG, WANTZ
254 INTEGER I, IMAX, INDIBL, INDISP, INDIWO, INDWRK,
255 $ ISCALE, ITMP1, J, JJ, NSPLIT
256 REAL BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
257 $ TMP1, TNRM, VLL, VUU
259 * .. External Functions ..
262 EXTERNAL LSAME, SLAMCH, SLANST
264 * .. External Subroutines ..
265 EXTERNAL SCOPY, SSCAL, SSTEBZ, SSTEIN, SSTEQR, SSTERF,
268 * .. Intrinsic Functions ..
269 INTRINSIC MAX, MIN, SQRT
271 * .. Executable Statements ..
273 * Test the input parameters.
275 WANTZ = LSAME( JOBZ, 'V' )
276 ALLEIG = LSAME( RANGE, 'A' )
277 VALEIG = LSAME( RANGE, 'V' )
278 INDEIG = LSAME( RANGE, 'I' )
281 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
283 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
285 ELSE IF( N.LT.0 ) THEN
289 IF( N.GT.0 .AND. VU.LE.VL )
291 ELSE IF( INDEIG ) THEN
292 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
294 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
300 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
305 CALL XERBLA( 'SSTEVX', -INFO )
309 * Quick return if possible
316 IF( ALLEIG .OR. INDEIG ) THEN
320 IF( VL.LT.D( 1 ) .AND. VU.GE.D( 1 ) ) THEN
330 * Get machine constants.
332 SAFMIN = SLAMCH( 'Safe minimum' )
333 EPS = SLAMCH( 'Precision' )
334 SMLNUM = SAFMIN / EPS
335 BIGNUM = ONE / SMLNUM
336 RMIN = SQRT( SMLNUM )
337 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
339 * Scale matrix to allowable range, if necessary.
349 TNRM = SLANST( 'M', N, D, E )
350 IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
353 ELSE IF( TNRM.GT.RMAX ) THEN
357 IF( ISCALE.EQ.1 ) THEN
358 CALL SSCAL( N, SIGMA, D, 1 )
359 CALL SSCAL( N-1, SIGMA, E( 1 ), 1 )
366 * If all eigenvalues are desired and ABSTOL is less than zero, then
367 * call SSTERF or SSTEQR. If this fails for some eigenvalue, then
372 IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
376 IF( ( ALLEIG .OR. TEST ) .AND. ( ABSTOL.LE.ZERO ) ) THEN
377 CALL SCOPY( N, D, 1, W, 1 )
378 CALL SCOPY( N-1, E( 1 ), 1, WORK( 1 ), 1 )
380 IF( .NOT.WANTZ ) THEN
381 CALL SSTERF( N, W, WORK, INFO )
383 CALL SSTEQR( 'I', N, W, WORK, Z, LDZ, WORK( INDWRK ), INFO )
397 * Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
408 CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTOL, D, E, M,
409 $ NSPLIT, W, IWORK( INDIBL ), IWORK( INDISP ),
410 $ WORK( INDWRK ), IWORK( INDIWO ), INFO )
413 CALL SSTEIN( N, D, E, M, W, IWORK( INDIBL ), IWORK( INDISP ),
414 $ Z, LDZ, WORK( INDWRK ), IWORK( INDIWO ), IFAIL,
418 * If matrix was scaled, then rescale eigenvalues appropriately.
421 IF( ISCALE.EQ.1 ) THEN
427 CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
430 * If eigenvalues are not in order, then sort them, along with
438 IF( W( JJ ).LT.TMP1 ) THEN
445 ITMP1 = IWORK( INDIBL+I-1 )
447 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
449 IWORK( INDIBL+J-1 ) = ITMP1
450 CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
453 IFAIL( I ) = IFAIL( J )