1 SUBROUTINE DSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
2 $ ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
3 $ INFO )
4 *
5 * -- LAPACK driver routine (version 3.2) --
6 * -- LAPACK is a software package provided by Univ. of Tennessee, --
7 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
8 * November 2006
9 *
10 * .. Scalar Arguments ..
11 CHARACTER JOBZ, RANGE, UPLO
12 INTEGER IL, INFO, IU, LDZ, M, N
13 DOUBLE PRECISION ABSTOL, VL, VU
14 * ..
15 * .. Array Arguments ..
16 INTEGER IFAIL( * ), IWORK( * )
17 DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * )
18 * ..
19 *
20 * Purpose
21 * =======
22 *
23 * DSPEVX computes selected eigenvalues and, optionally, eigenvectors
24 * of a real symmetric matrix A in packed storage. Eigenvalues/vectors
25 * can be selected by specifying either a range of values or a range of
26 * indices for the desired eigenvalues.
27 *
28 * Arguments
29 * =========
30 *
31 * JOBZ (input) CHARACTER*1
32 * = 'N': Compute eigenvalues only;
33 * = 'V': Compute eigenvalues and eigenvectors.
34 *
35 * RANGE (input) CHARACTER*1
36 * = 'A': all eigenvalues will be found;
37 * = 'V': all eigenvalues in the half-open interval (VL,VU]
38 * will be found;
39 * = 'I': the IL-th through IU-th eigenvalues will be found.
40 *
41 * UPLO (input) CHARACTER*1
42 * = 'U': Upper triangle of A is stored;
43 * = 'L': Lower triangle of A is stored.
44 *
45 * N (input) INTEGER
46 * The order of the matrix A. N >= 0.
47 *
48 * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
49 * On entry, the upper or lower triangle of the symmetric matrix
50 * A, packed columnwise in a linear array. The j-th column of A
51 * is stored in the array AP as follows:
52 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
53 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
54 *
55 * On exit, AP is overwritten by values generated during the
56 * reduction to tridiagonal form. If UPLO = 'U', the diagonal
57 * and first superdiagonal of the tridiagonal matrix T overwrite
58 * the corresponding elements of A, and if UPLO = 'L', the
59 * diagonal and first subdiagonal of T overwrite the
60 * corresponding elements of A.
61 *
62 * VL (input) DOUBLE PRECISION
63 * VU (input) DOUBLE PRECISION
64 * If RANGE='V', the lower and upper bounds of the interval to
65 * be searched for eigenvalues. VL < VU.
66 * Not referenced if RANGE = 'A' or 'I'.
67 *
68 * IL (input) INTEGER
69 * IU (input) INTEGER
70 * If RANGE='I', the indices (in ascending order) of the
71 * smallest and largest eigenvalues to be returned.
72 * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
73 * Not referenced if RANGE = 'A' or 'V'.
74 *
75 * ABSTOL (input) DOUBLE PRECISION
76 * The absolute error tolerance for the eigenvalues.
77 * An approximate eigenvalue is accepted as converged
78 * when it is determined to lie in an interval [a,b]
79 * of width less than or equal to
80 *
81 * ABSTOL + EPS * max( |a|,|b| ) ,
82 *
83 * where EPS is the machine precision. If ABSTOL is less than
84 * or equal to zero, then EPS*|T| will be used in its place,
85 * where |T| is the 1-norm of the tridiagonal matrix obtained
86 * by reducing AP to tridiagonal form.
87 *
88 * Eigenvalues will be computed most accurately when ABSTOL is
89 * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
90 * If this routine returns with INFO>0, indicating that some
91 * eigenvectors did not converge, try setting ABSTOL to
92 * 2*DLAMCH('S').
93 *
94 * See "Computing Small Singular Values of Bidiagonal Matrices
95 * with Guaranteed High Relative Accuracy," by Demmel and
96 * Kahan, LAPACK Working Note #3.
97 *
98 * M (output) INTEGER
99 * The total number of eigenvalues found. 0 <= M <= N.
100 * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
101 *
102 * W (output) DOUBLE PRECISION array, dimension (N)
103 * If INFO = 0, the selected eigenvalues in ascending order.
104 *
105 * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
106 * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
107 * contain the orthonormal eigenvectors of the matrix A
108 * corresponding to the selected eigenvalues, with the i-th
109 * column of Z holding the eigenvector associated with W(i).
110 * If an eigenvector fails to converge, then that column of Z
111 * contains the latest approximation to the eigenvector, and the
112 * index of the eigenvector is returned in IFAIL.
113 * If JOBZ = 'N', then Z is not referenced.
114 * Note: the user must ensure that at least max(1,M) columns are
115 * supplied in the array Z; if RANGE = 'V', the exact value of M
116 * is not known in advance and an upper bound must be used.
117 *
118 * LDZ (input) INTEGER
119 * The leading dimension of the array Z. LDZ >= 1, and if
120 * JOBZ = 'V', LDZ >= max(1,N).
121 *
122 * WORK (workspace) DOUBLE PRECISION array, dimension (8*N)
123 *
124 * IWORK (workspace) INTEGER array, dimension (5*N)
125 *
126 * IFAIL (output) INTEGER array, dimension (N)
127 * If JOBZ = 'V', then if INFO = 0, the first M elements of
128 * IFAIL are zero. If INFO > 0, then IFAIL contains the
129 * indices of the eigenvectors that failed to converge.
130 * If JOBZ = 'N', then IFAIL is not referenced.
131 *
132 * INFO (output) INTEGER
133 * = 0: successful exit
134 * < 0: if INFO = -i, the i-th argument had an illegal value
135 * > 0: if INFO = i, then i eigenvectors failed to converge.
136 * Their indices are stored in array IFAIL.
137 *
138 * =====================================================================
139 *
140 * .. Parameters ..
141 DOUBLE PRECISION ZERO, ONE
142 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
143 * ..
144 * .. Local Scalars ..
145 LOGICAL ALLEIG, INDEIG, TEST, VALEIG, WANTZ
146 CHARACTER ORDER
147 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
148 $ INDISP, INDIWO, INDTAU, INDWRK, ISCALE, ITMP1,
149 $ J, JJ, NSPLIT
150 DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
151 $ SIGMA, SMLNUM, TMP1, VLL, VUU
152 * ..
153 * .. External Functions ..
154 LOGICAL LSAME
155 DOUBLE PRECISION DLAMCH, DLANSP
156 EXTERNAL LSAME, DLAMCH, DLANSP
157 * ..
158 * .. External Subroutines ..
159 EXTERNAL DCOPY, DOPGTR, DOPMTR, DSCAL, DSPTRD, DSTEBZ,
160 $ DSTEIN, DSTEQR, DSTERF, DSWAP, XERBLA
161 * ..
162 * .. Intrinsic Functions ..
163 INTRINSIC MAX, MIN, SQRT
164 * ..
165 * .. Executable Statements ..
166 *
167 * Test the input parameters.
168 *
169 WANTZ = LSAME( JOBZ, 'V' )
170 ALLEIG = LSAME( RANGE, 'A' )
171 VALEIG = LSAME( RANGE, 'V' )
172 INDEIG = LSAME( RANGE, 'I' )
173 *
174 INFO = 0
175 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
176 INFO = -1
177 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
178 INFO = -2
179 ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) )
180 $ THEN
181 INFO = -3
182 ELSE IF( N.LT.0 ) THEN
183 INFO = -4
184 ELSE
185 IF( VALEIG ) THEN
186 IF( N.GT.0 .AND. VU.LE.VL )
187 $ INFO = -7
188 ELSE IF( INDEIG ) THEN
189 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
190 INFO = -8
191 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
192 INFO = -9
193 END IF
194 END IF
195 END IF
196 IF( INFO.EQ.0 ) THEN
197 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
198 $ INFO = -14
199 END IF
200 *
201 IF( INFO.NE.0 ) THEN
202 CALL XERBLA( 'DSPEVX', -INFO )
203 RETURN
204 END IF
205 *
206 * Quick return if possible
207 *
208 M = 0
209 IF( N.EQ.0 )
210 $ RETURN
211 *
212 IF( N.EQ.1 ) THEN
213 IF( ALLEIG .OR. INDEIG ) THEN
214 M = 1
215 W( 1 ) = AP( 1 )
216 ELSE
217 IF( VL.LT.AP( 1 ) .AND. VU.GE.AP( 1 ) ) THEN
218 M = 1
219 W( 1 ) = AP( 1 )
220 END IF
221 END IF
222 IF( WANTZ )
223 $ Z( 1, 1 ) = ONE
224 RETURN
225 END IF
226 *
227 * Get machine constants.
228 *
229 SAFMIN = DLAMCH( 'Safe minimum' )
230 EPS = DLAMCH( 'Precision' )
231 SMLNUM = SAFMIN / EPS
232 BIGNUM = ONE / SMLNUM
233 RMIN = SQRT( SMLNUM )
234 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
235 *
236 * Scale matrix to allowable range, if necessary.
237 *
238 ISCALE = 0
239 ABSTLL = ABSTOL
240 IF( VALEIG ) THEN
241 VLL = VL
242 VUU = VU
243 ELSE
244 VLL = ZERO
245 VUU = ZERO
246 END IF
247 ANRM = DLANSP( 'M', UPLO, N, AP, WORK )
248 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
249 ISCALE = 1
250 SIGMA = RMIN / ANRM
251 ELSE IF( ANRM.GT.RMAX ) THEN
252 ISCALE = 1
253 SIGMA = RMAX / ANRM
254 END IF
255 IF( ISCALE.EQ.1 ) THEN
256 CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 )
257 IF( ABSTOL.GT.0 )
258 $ ABSTLL = ABSTOL*SIGMA
259 IF( VALEIG ) THEN
260 VLL = VL*SIGMA
261 VUU = VU*SIGMA
262 END IF
263 END IF
264 *
265 * Call DSPTRD to reduce symmetric packed matrix to tridiagonal form.
266 *
267 INDTAU = 1
268 INDE = INDTAU + N
269 INDD = INDE + N
270 INDWRK = INDD + N
271 CALL DSPTRD( UPLO, N, AP, WORK( INDD ), WORK( INDE ),
272 $ WORK( INDTAU ), IINFO )
273 *
274 * If all eigenvalues are desired and ABSTOL is less than or equal
275 * to zero, then call DSTERF or DOPGTR and SSTEQR. If this fails
276 * for some eigenvalue, then try DSTEBZ.
277 *
278 TEST = .FALSE.
279 IF (INDEIG) THEN
280 IF (IL.EQ.1 .AND. IU.EQ.N) THEN
281 TEST = .TRUE.
282 END IF
283 END IF
284 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
285 CALL DCOPY( N, WORK( INDD ), 1, W, 1 )
286 INDEE = INDWRK + 2*N
287 IF( .NOT.WANTZ ) THEN
288 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
289 CALL DSTERF( N, W, WORK( INDEE ), INFO )
290 ELSE
291 CALL DOPGTR( UPLO, N, AP, WORK( INDTAU ), Z, LDZ,
292 $ WORK( INDWRK ), IINFO )
293 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
294 CALL DSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
295 $ WORK( INDWRK ), INFO )
296 IF( INFO.EQ.0 ) THEN
297 DO 10 I = 1, N
298 IFAIL( I ) = 0
299 10 CONTINUE
300 END IF
301 END IF
302 IF( INFO.EQ.0 ) THEN
303 M = N
304 GO TO 20
305 END IF
306 INFO = 0
307 END IF
308 *
309 * Otherwise, call DSTEBZ and, if eigenvectors are desired, SSTEIN.
310 *
311 IF( WANTZ ) THEN
312 ORDER = 'B'
313 ELSE
314 ORDER = 'E'
315 END IF
316 INDIBL = 1
317 INDISP = INDIBL + N
318 INDIWO = INDISP + N
319 CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
320 $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
321 $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
322 $ IWORK( INDIWO ), INFO )
323 *
324 IF( WANTZ ) THEN
325 CALL DSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
326 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
327 $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
328 *
329 * Apply orthogonal matrix used in reduction to tridiagonal
330 * form to eigenvectors returned by DSTEIN.
331 *
332 CALL DOPMTR( 'L', UPLO, 'N', N, M, AP, WORK( INDTAU ), Z, LDZ,
333 $ WORK( INDWRK ), IINFO )
334 END IF
335 *
336 * If matrix was scaled, then rescale eigenvalues appropriately.
337 *
338 20 CONTINUE
339 IF( ISCALE.EQ.1 ) THEN
340 IF( INFO.EQ.0 ) THEN
341 IMAX = M
342 ELSE
343 IMAX = INFO - 1
344 END IF
345 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
346 END IF
347 *
348 * If eigenvalues are not in order, then sort them, along with
349 * eigenvectors.
350 *
351 IF( WANTZ ) THEN
352 DO 40 J = 1, M - 1
353 I = 0
354 TMP1 = W( J )
355 DO 30 JJ = J + 1, M
356 IF( W( JJ ).LT.TMP1 ) THEN
357 I = JJ
358 TMP1 = W( JJ )
359 END IF
360 30 CONTINUE
361 *
362 IF( I.NE.0 ) THEN
363 ITMP1 = IWORK( INDIBL+I-1 )
364 W( I ) = W( J )
365 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
366 W( J ) = TMP1
367 IWORK( INDIBL+J-1 ) = ITMP1
368 CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
369 IF( INFO.NE.0 ) THEN
370 ITMP1 = IFAIL( I )
371 IFAIL( I ) = IFAIL( J )
372 IFAIL( J ) = ITMP1
373 END IF
374 END IF
375 40 CONTINUE
376 END IF
377 *
378 RETURN
379 *
380 * End of DSPEVX
381 *
382 END
2 $ ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
3 $ INFO )
4 *
5 * -- LAPACK driver routine (version 3.2) --
6 * -- LAPACK is a software package provided by Univ. of Tennessee, --
7 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
8 * November 2006
9 *
10 * .. Scalar Arguments ..
11 CHARACTER JOBZ, RANGE, UPLO
12 INTEGER IL, INFO, IU, LDZ, M, N
13 DOUBLE PRECISION ABSTOL, VL, VU
14 * ..
15 * .. Array Arguments ..
16 INTEGER IFAIL( * ), IWORK( * )
17 DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * )
18 * ..
19 *
20 * Purpose
21 * =======
22 *
23 * DSPEVX computes selected eigenvalues and, optionally, eigenvectors
24 * of a real symmetric matrix A in packed storage. Eigenvalues/vectors
25 * can be selected by specifying either a range of values or a range of
26 * indices for the desired eigenvalues.
27 *
28 * Arguments
29 * =========
30 *
31 * JOBZ (input) CHARACTER*1
32 * = 'N': Compute eigenvalues only;
33 * = 'V': Compute eigenvalues and eigenvectors.
34 *
35 * RANGE (input) CHARACTER*1
36 * = 'A': all eigenvalues will be found;
37 * = 'V': all eigenvalues in the half-open interval (VL,VU]
38 * will be found;
39 * = 'I': the IL-th through IU-th eigenvalues will be found.
40 *
41 * UPLO (input) CHARACTER*1
42 * = 'U': Upper triangle of A is stored;
43 * = 'L': Lower triangle of A is stored.
44 *
45 * N (input) INTEGER
46 * The order of the matrix A. N >= 0.
47 *
48 * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
49 * On entry, the upper or lower triangle of the symmetric matrix
50 * A, packed columnwise in a linear array. The j-th column of A
51 * is stored in the array AP as follows:
52 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
53 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
54 *
55 * On exit, AP is overwritten by values generated during the
56 * reduction to tridiagonal form. If UPLO = 'U', the diagonal
57 * and first superdiagonal of the tridiagonal matrix T overwrite
58 * the corresponding elements of A, and if UPLO = 'L', the
59 * diagonal and first subdiagonal of T overwrite the
60 * corresponding elements of A.
61 *
62 * VL (input) DOUBLE PRECISION
63 * VU (input) DOUBLE PRECISION
64 * If RANGE='V', the lower and upper bounds of the interval to
65 * be searched for eigenvalues. VL < VU.
66 * Not referenced if RANGE = 'A' or 'I'.
67 *
68 * IL (input) INTEGER
69 * IU (input) INTEGER
70 * If RANGE='I', the indices (in ascending order) of the
71 * smallest and largest eigenvalues to be returned.
72 * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
73 * Not referenced if RANGE = 'A' or 'V'.
74 *
75 * ABSTOL (input) DOUBLE PRECISION
76 * The absolute error tolerance for the eigenvalues.
77 * An approximate eigenvalue is accepted as converged
78 * when it is determined to lie in an interval [a,b]
79 * of width less than or equal to
80 *
81 * ABSTOL + EPS * max( |a|,|b| ) ,
82 *
83 * where EPS is the machine precision. If ABSTOL is less than
84 * or equal to zero, then EPS*|T| will be used in its place,
85 * where |T| is the 1-norm of the tridiagonal matrix obtained
86 * by reducing AP to tridiagonal form.
87 *
88 * Eigenvalues will be computed most accurately when ABSTOL is
89 * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
90 * If this routine returns with INFO>0, indicating that some
91 * eigenvectors did not converge, try setting ABSTOL to
92 * 2*DLAMCH('S').
93 *
94 * See "Computing Small Singular Values of Bidiagonal Matrices
95 * with Guaranteed High Relative Accuracy," by Demmel and
96 * Kahan, LAPACK Working Note #3.
97 *
98 * M (output) INTEGER
99 * The total number of eigenvalues found. 0 <= M <= N.
100 * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
101 *
102 * W (output) DOUBLE PRECISION array, dimension (N)
103 * If INFO = 0, the selected eigenvalues in ascending order.
104 *
105 * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
106 * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
107 * contain the orthonormal eigenvectors of the matrix A
108 * corresponding to the selected eigenvalues, with the i-th
109 * column of Z holding the eigenvector associated with W(i).
110 * If an eigenvector fails to converge, then that column of Z
111 * contains the latest approximation to the eigenvector, and the
112 * index of the eigenvector is returned in IFAIL.
113 * If JOBZ = 'N', then Z is not referenced.
114 * Note: the user must ensure that at least max(1,M) columns are
115 * supplied in the array Z; if RANGE = 'V', the exact value of M
116 * is not known in advance and an upper bound must be used.
117 *
118 * LDZ (input) INTEGER
119 * The leading dimension of the array Z. LDZ >= 1, and if
120 * JOBZ = 'V', LDZ >= max(1,N).
121 *
122 * WORK (workspace) DOUBLE PRECISION array, dimension (8*N)
123 *
124 * IWORK (workspace) INTEGER array, dimension (5*N)
125 *
126 * IFAIL (output) INTEGER array, dimension (N)
127 * If JOBZ = 'V', then if INFO = 0, the first M elements of
128 * IFAIL are zero. If INFO > 0, then IFAIL contains the
129 * indices of the eigenvectors that failed to converge.
130 * If JOBZ = 'N', then IFAIL is not referenced.
131 *
132 * INFO (output) INTEGER
133 * = 0: successful exit
134 * < 0: if INFO = -i, the i-th argument had an illegal value
135 * > 0: if INFO = i, then i eigenvectors failed to converge.
136 * Their indices are stored in array IFAIL.
137 *
138 * =====================================================================
139 *
140 * .. Parameters ..
141 DOUBLE PRECISION ZERO, ONE
142 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
143 * ..
144 * .. Local Scalars ..
145 LOGICAL ALLEIG, INDEIG, TEST, VALEIG, WANTZ
146 CHARACTER ORDER
147 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
148 $ INDISP, INDIWO, INDTAU, INDWRK, ISCALE, ITMP1,
149 $ J, JJ, NSPLIT
150 DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
151 $ SIGMA, SMLNUM, TMP1, VLL, VUU
152 * ..
153 * .. External Functions ..
154 LOGICAL LSAME
155 DOUBLE PRECISION DLAMCH, DLANSP
156 EXTERNAL LSAME, DLAMCH, DLANSP
157 * ..
158 * .. External Subroutines ..
159 EXTERNAL DCOPY, DOPGTR, DOPMTR, DSCAL, DSPTRD, DSTEBZ,
160 $ DSTEIN, DSTEQR, DSTERF, DSWAP, XERBLA
161 * ..
162 * .. Intrinsic Functions ..
163 INTRINSIC MAX, MIN, SQRT
164 * ..
165 * .. Executable Statements ..
166 *
167 * Test the input parameters.
168 *
169 WANTZ = LSAME( JOBZ, 'V' )
170 ALLEIG = LSAME( RANGE, 'A' )
171 VALEIG = LSAME( RANGE, 'V' )
172 INDEIG = LSAME( RANGE, 'I' )
173 *
174 INFO = 0
175 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
176 INFO = -1
177 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
178 INFO = -2
179 ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) )
180 $ THEN
181 INFO = -3
182 ELSE IF( N.LT.0 ) THEN
183 INFO = -4
184 ELSE
185 IF( VALEIG ) THEN
186 IF( N.GT.0 .AND. VU.LE.VL )
187 $ INFO = -7
188 ELSE IF( INDEIG ) THEN
189 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
190 INFO = -8
191 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
192 INFO = -9
193 END IF
194 END IF
195 END IF
196 IF( INFO.EQ.0 ) THEN
197 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
198 $ INFO = -14
199 END IF
200 *
201 IF( INFO.NE.0 ) THEN
202 CALL XERBLA( 'DSPEVX', -INFO )
203 RETURN
204 END IF
205 *
206 * Quick return if possible
207 *
208 M = 0
209 IF( N.EQ.0 )
210 $ RETURN
211 *
212 IF( N.EQ.1 ) THEN
213 IF( ALLEIG .OR. INDEIG ) THEN
214 M = 1
215 W( 1 ) = AP( 1 )
216 ELSE
217 IF( VL.LT.AP( 1 ) .AND. VU.GE.AP( 1 ) ) THEN
218 M = 1
219 W( 1 ) = AP( 1 )
220 END IF
221 END IF
222 IF( WANTZ )
223 $ Z( 1, 1 ) = ONE
224 RETURN
225 END IF
226 *
227 * Get machine constants.
228 *
229 SAFMIN = DLAMCH( 'Safe minimum' )
230 EPS = DLAMCH( 'Precision' )
231 SMLNUM = SAFMIN / EPS
232 BIGNUM = ONE / SMLNUM
233 RMIN = SQRT( SMLNUM )
234 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
235 *
236 * Scale matrix to allowable range, if necessary.
237 *
238 ISCALE = 0
239 ABSTLL = ABSTOL
240 IF( VALEIG ) THEN
241 VLL = VL
242 VUU = VU
243 ELSE
244 VLL = ZERO
245 VUU = ZERO
246 END IF
247 ANRM = DLANSP( 'M', UPLO, N, AP, WORK )
248 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
249 ISCALE = 1
250 SIGMA = RMIN / ANRM
251 ELSE IF( ANRM.GT.RMAX ) THEN
252 ISCALE = 1
253 SIGMA = RMAX / ANRM
254 END IF
255 IF( ISCALE.EQ.1 ) THEN
256 CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 )
257 IF( ABSTOL.GT.0 )
258 $ ABSTLL = ABSTOL*SIGMA
259 IF( VALEIG ) THEN
260 VLL = VL*SIGMA
261 VUU = VU*SIGMA
262 END IF
263 END IF
264 *
265 * Call DSPTRD to reduce symmetric packed matrix to tridiagonal form.
266 *
267 INDTAU = 1
268 INDE = INDTAU + N
269 INDD = INDE + N
270 INDWRK = INDD + N
271 CALL DSPTRD( UPLO, N, AP, WORK( INDD ), WORK( INDE ),
272 $ WORK( INDTAU ), IINFO )
273 *
274 * If all eigenvalues are desired and ABSTOL is less than or equal
275 * to zero, then call DSTERF or DOPGTR and SSTEQR. If this fails
276 * for some eigenvalue, then try DSTEBZ.
277 *
278 TEST = .FALSE.
279 IF (INDEIG) THEN
280 IF (IL.EQ.1 .AND. IU.EQ.N) THEN
281 TEST = .TRUE.
282 END IF
283 END IF
284 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
285 CALL DCOPY( N, WORK( INDD ), 1, W, 1 )
286 INDEE = INDWRK + 2*N
287 IF( .NOT.WANTZ ) THEN
288 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
289 CALL DSTERF( N, W, WORK( INDEE ), INFO )
290 ELSE
291 CALL DOPGTR( UPLO, N, AP, WORK( INDTAU ), Z, LDZ,
292 $ WORK( INDWRK ), IINFO )
293 CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
294 CALL DSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
295 $ WORK( INDWRK ), INFO )
296 IF( INFO.EQ.0 ) THEN
297 DO 10 I = 1, N
298 IFAIL( I ) = 0
299 10 CONTINUE
300 END IF
301 END IF
302 IF( INFO.EQ.0 ) THEN
303 M = N
304 GO TO 20
305 END IF
306 INFO = 0
307 END IF
308 *
309 * Otherwise, call DSTEBZ and, if eigenvectors are desired, SSTEIN.
310 *
311 IF( WANTZ ) THEN
312 ORDER = 'B'
313 ELSE
314 ORDER = 'E'
315 END IF
316 INDIBL = 1
317 INDISP = INDIBL + N
318 INDIWO = INDISP + N
319 CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
320 $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
321 $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
322 $ IWORK( INDIWO ), INFO )
323 *
324 IF( WANTZ ) THEN
325 CALL DSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
326 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
327 $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
328 *
329 * Apply orthogonal matrix used in reduction to tridiagonal
330 * form to eigenvectors returned by DSTEIN.
331 *
332 CALL DOPMTR( 'L', UPLO, 'N', N, M, AP, WORK( INDTAU ), Z, LDZ,
333 $ WORK( INDWRK ), IINFO )
334 END IF
335 *
336 * If matrix was scaled, then rescale eigenvalues appropriately.
337 *
338 20 CONTINUE
339 IF( ISCALE.EQ.1 ) THEN
340 IF( INFO.EQ.0 ) THEN
341 IMAX = M
342 ELSE
343 IMAX = INFO - 1
344 END IF
345 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
346 END IF
347 *
348 * If eigenvalues are not in order, then sort them, along with
349 * eigenvectors.
350 *
351 IF( WANTZ ) THEN
352 DO 40 J = 1, M - 1
353 I = 0
354 TMP1 = W( J )
355 DO 30 JJ = J + 1, M
356 IF( W( JJ ).LT.TMP1 ) THEN
357 I = JJ
358 TMP1 = W( JJ )
359 END IF
360 30 CONTINUE
361 *
362 IF( I.NE.0 ) THEN
363 ITMP1 = IWORK( INDIBL+I-1 )
364 W( I ) = W( J )
365 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
366 W( J ) = TMP1
367 IWORK( INDIBL+J-1 ) = ITMP1
368 CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
369 IF( INFO.NE.0 ) THEN
370 ITMP1 = IFAIL( I )
371 IFAIL( I ) = IFAIL( J )
372 IFAIL( J ) = ITMP1
373 END IF
374 END IF
375 40 CONTINUE
376 END IF
377 *
378 RETURN
379 *
380 * End of DSPEVX
381 *
382 END