1 *> \brief <b> DSPEVX 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 DSPEVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspevx.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspevx.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspevx.f">
21 * SUBROUTINE DSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
22 * ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
25 * .. Scalar Arguments ..
26 * CHARACTER JOBZ, RANGE, UPLO
27 * INTEGER IL, INFO, IU, LDZ, M, N
28 * DOUBLE PRECISION ABSTOL, VL, VU
30 * .. Array Arguments ..
31 * INTEGER IFAIL( * ), IWORK( * )
32 * DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * )
41 *> DSPEVX computes selected eigenvalues and, optionally, eigenvectors
42 *> of a real symmetric matrix A in packed storage. Eigenvalues/vectors
43 *> can be selected by specifying either a range of values or a range of
44 *> indices for the desired eigenvalues.
52 *> JOBZ is CHARACTER*1
53 *> = 'N': Compute eigenvalues only;
54 *> = 'V': Compute eigenvalues and eigenvectors.
59 *> RANGE is CHARACTER*1
60 *> = 'A': all eigenvalues will be found;
61 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
63 *> = 'I': the IL-th through IU-th eigenvalues will be found.
68 *> UPLO is CHARACTER*1
69 *> = 'U': Upper triangle of A is stored;
70 *> = 'L': Lower triangle of A is stored.
76 *> The order of the matrix A. N >= 0.
81 *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
82 *> On entry, the upper or lower triangle of the symmetric matrix
83 *> A, packed columnwise in a linear array. The j-th column of A
84 *> is stored in the array AP as follows:
85 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
86 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
88 *> On exit, AP is overwritten by values generated during the
89 *> reduction to tridiagonal form. If UPLO = 'U', the diagonal
90 *> and first superdiagonal of the tridiagonal matrix T overwrite
91 *> the corresponding elements of A, and if UPLO = 'L', the
92 *> diagonal and first subdiagonal of T overwrite the
93 *> corresponding elements of A.
98 *> VL is DOUBLE PRECISION
99 *> If RANGE='V', the lower bound of the interval to
100 *> be searched for eigenvalues. VL < VU.
101 *> Not referenced if RANGE = 'A' or 'I'.
106 *> VU is DOUBLE PRECISION
107 *> If RANGE='V', the upper bound of the interval to
108 *> be searched for eigenvalues. VL < VU.
109 *> Not referenced if RANGE = 'A' or 'I'.
115 *> If RANGE='I', the index of the
116 *> smallest eigenvalue to be returned.
117 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
118 *> Not referenced if RANGE = 'A' or 'V'.
124 *> If RANGE='I', the index of the
125 *> largest eigenvalue to be returned.
126 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
127 *> Not referenced if RANGE = 'A' or 'V'.
132 *> ABSTOL is DOUBLE PRECISION
133 *> The absolute error tolerance for the eigenvalues.
134 *> An approximate eigenvalue is accepted as converged
135 *> when it is determined to lie in an interval [a,b]
136 *> of width less than or equal to
138 *> ABSTOL + EPS * max( |a|,|b| ) ,
140 *> where EPS is the machine precision. If ABSTOL is less than
141 *> or equal to zero, then EPS*|T| will be used in its place,
142 *> where |T| is the 1-norm of the tridiagonal matrix obtained
143 *> by reducing AP to tridiagonal form.
145 *> Eigenvalues will be computed most accurately when ABSTOL is
146 *> set to twice the underflow threshold 2*DLAMCH('S'), not zero.
147 *> If this routine returns with INFO>0, indicating that some
148 *> eigenvectors did not converge, try setting ABSTOL to
151 *> See "Computing Small Singular Values of Bidiagonal Matrices
152 *> with Guaranteed High Relative Accuracy," by Demmel and
153 *> Kahan, LAPACK Working Note #3.
159 *> The total number of eigenvalues found. 0 <= M <= N.
160 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
165 *> W is DOUBLE PRECISION array, dimension (N)
166 *> If INFO = 0, the selected eigenvalues in ascending order.
171 *> Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M))
172 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
173 *> contain the orthonormal eigenvectors of the matrix A
174 *> corresponding to the selected eigenvalues, with the i-th
175 *> column of Z holding the eigenvector associated with W(i).
176 *> If an eigenvector fails to converge, then that column of Z
177 *> contains the latest approximation to the eigenvector, and the
178 *> index of the eigenvector is returned in IFAIL.
179 *> If JOBZ = 'N', then Z is not referenced.
180 *> Note: the user must ensure that at least max(1,M) columns are
181 *> supplied in the array Z; if RANGE = 'V', the exact value of M
182 *> is not known in advance and an upper bound must be used.
188 *> The leading dimension of the array Z. LDZ >= 1, and if
189 *> JOBZ = 'V', LDZ >= max(1,N).
194 *> WORK is DOUBLE PRECISION array, dimension (8*N)
199 *> IWORK is INTEGER array, dimension (5*N)
204 *> IFAIL is INTEGER array, dimension (N)
205 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
206 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
207 *> indices of the eigenvectors that failed to converge.
208 *> If JOBZ = 'N', then IFAIL is not referenced.
214 *> = 0: successful exit
215 *> < 0: if INFO = -i, the i-th argument had an illegal value
216 *> > 0: if INFO = i, then i eigenvectors failed to converge.
217 *> Their indices are stored in array IFAIL.
223 *> \author Univ. of Tennessee
224 *> \author Univ. of California Berkeley
225 *> \author Univ. of Colorado Denver
230 *> \ingroup doubleOTHEReigen
232 * =====================================================================
233 SUBROUTINE DSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
234 $ ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
237 * -- LAPACK driver routine (version 3.6.1) --
238 * -- LAPACK is a software package provided by Univ. of Tennessee, --
239 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
242 * .. Scalar Arguments ..
243 CHARACTER JOBZ, RANGE, UPLO
244 INTEGER IL, INFO, IU, LDZ, M, N
245 DOUBLE PRECISION ABSTOL, VL, VU
247 * .. Array Arguments ..
248 INTEGER IFAIL( * ), IWORK( * )
249 DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * )
252 * =====================================================================
255 DOUBLE PRECISION ZERO, ONE
256 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
258 * .. Local Scalars ..
259 LOGICAL ALLEIG, INDEIG, TEST, VALEIG, WANTZ
261 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
262 $ INDISP, INDIWO, INDTAU, INDWRK, ISCALE, ITMP1,
264 DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
265 $ SIGMA, SMLNUM, TMP1, VLL, VUU
267 * .. External Functions ..
269 DOUBLE PRECISION DLAMCH, DLANSP
270 EXTERNAL LSAME, DLAMCH, DLANSP
272 * .. External Subroutines ..
273 EXTERNAL DCOPY, DOPGTR, DOPMTR, DSCAL, DSPTRD, DSTEBZ,
274 $ DSTEIN, DSTEQR, DSTERF, DSWAP, XERBLA
276 * .. Intrinsic Functions ..
277 INTRINSIC MAX, MIN, SQRT
279 * .. Executable Statements ..
281 * Test the input parameters.
283 WANTZ = LSAME( JOBZ, 'V' )
284 ALLEIG = LSAME( RANGE, 'A' )
285 VALEIG = LSAME( RANGE, 'V' )
286 INDEIG = LSAME( RANGE, 'I' )
289 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
291 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
293 ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) )
296 ELSE IF( N.LT.0 ) THEN
300 IF( N.GT.0 .AND. VU.LE.VL )
302 ELSE IF( INDEIG ) THEN
303 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
305 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
311 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
316 CALL XERBLA( 'DSPEVX', -INFO )
320 * Quick return if possible
327 IF( ALLEIG .OR. INDEIG ) THEN
331 IF( VL.LT.AP( 1 ) .AND. VU.GE.AP( 1 ) ) THEN
341 * Get machine constants.
343 SAFMIN = DLAMCH( 'Safe minimum' )
344 EPS = DLAMCH( 'Precision' )
345 SMLNUM = SAFMIN / EPS
346 BIGNUM = ONE / SMLNUM
347 RMIN = SQRT( SMLNUM )
348 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
350 * Scale matrix to allowable range, if necessary.
361 ANRM = DLANSP( 'M', UPLO, N, AP, WORK )
362 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
365 ELSE IF( ANRM.GT.RMAX ) THEN
369 IF( ISCALE.EQ.1 ) THEN
370 CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 )
372 $ ABSTLL = ABSTOL*SIGMA
379 * Call DSPTRD to reduce symmetric packed matrix to tridiagonal form.
385 CALL DSPTRD( UPLO, N, AP, WORK( INDD ), WORK( INDE ),
386 $ WORK( INDTAU ), IINFO )
388 * If all eigenvalues are desired and ABSTOL is less than or equal
389 * to zero, then call DSTERF or DOPGTR and SSTEQR. If this fails
390 * for some eigenvalue, then try DSTEBZ.
394 IF (IL.EQ.1 .AND. IU.EQ.N) THEN
398 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
399 CALL DCOPY( N, WORK( INDD ), 1, W, 1 )
401 IF( .NOT.WANTZ ) THEN
402 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
403 CALL DSTERF( N, W, WORK( INDEE ), INFO )
405 CALL DOPGTR( UPLO, N, AP, WORK( INDTAU ), Z, LDZ,
406 $ WORK( INDWRK ), IINFO )
407 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
408 CALL DSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
409 $ WORK( INDWRK ), INFO )
423 * Otherwise, call DSTEBZ and, if eigenvectors are desired, SSTEIN.
433 CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
434 $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
435 $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
436 $ IWORK( INDIWO ), INFO )
439 CALL DSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
440 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
441 $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
443 * Apply orthogonal matrix used in reduction to tridiagonal
444 * form to eigenvectors returned by DSTEIN.
446 CALL DOPMTR( 'L', UPLO, 'N', N, M, AP, WORK( INDTAU ), Z, LDZ,
447 $ WORK( INDWRK ), IINFO )
450 * If matrix was scaled, then rescale eigenvalues appropriately.
453 IF( ISCALE.EQ.1 ) THEN
459 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
462 * If eigenvalues are not in order, then sort them, along with
470 IF( W( JJ ).LT.TMP1 ) THEN
477 ITMP1 = IWORK( INDIBL+I-1 )
479 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
481 IWORK( INDIBL+J-1 ) = ITMP1
482 CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
485 IFAIL( I ) = IFAIL( J )