Annotation of rpl/lapack/lapack/dsyevx.f, revision 1.12
1.8 bertrand 1: *> \brief <b> DSYEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download DSYEVX + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsyevx.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsyevx.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsyevx.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE DSYEVX( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
22: * ABSTOL, M, W, Z, LDZ, WORK, LWORK, IWORK,
23: * IFAIL, INFO )
24: *
25: * .. Scalar Arguments ..
26: * CHARACTER JOBZ, RANGE, UPLO
27: * INTEGER IL, INFO, IU, LDA, LDZ, LWORK, M, N
28: * DOUBLE PRECISION ABSTOL, VL, VU
29: * ..
30: * .. Array Arguments ..
31: * INTEGER IFAIL( * ), IWORK( * )
32: * DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
33: * ..
34: *
35: *
36: *> \par Purpose:
37: * =============
38: *>
39: *> \verbatim
40: *>
41: *> DSYEVX computes selected eigenvalues and, optionally, eigenvectors
42: *> of a real symmetric matrix A. Eigenvalues and eigenvectors can be
43: *> selected by specifying either a range of values or a range of indices
44: *> for the desired eigenvalues.
45: *> \endverbatim
46: *
47: * Arguments:
48: * ==========
49: *
50: *> \param[in] JOBZ
51: *> \verbatim
52: *> JOBZ is CHARACTER*1
53: *> = 'N': Compute eigenvalues only;
54: *> = 'V': Compute eigenvalues and eigenvectors.
55: *> \endverbatim
56: *>
57: *> \param[in] RANGE
58: *> \verbatim
59: *> RANGE is CHARACTER*1
60: *> = 'A': all eigenvalues will be found.
61: *> = 'V': all eigenvalues in the half-open interval (VL,VU]
62: *> will be found.
63: *> = 'I': the IL-th through IU-th eigenvalues will be found.
64: *> \endverbatim
65: *>
66: *> \param[in] UPLO
67: *> \verbatim
68: *> UPLO is CHARACTER*1
69: *> = 'U': Upper triangle of A is stored;
70: *> = 'L': Lower triangle of A is stored.
71: *> \endverbatim
72: *>
73: *> \param[in] N
74: *> \verbatim
75: *> N is INTEGER
76: *> The order of the matrix A. N >= 0.
77: *> \endverbatim
78: *>
79: *> \param[in,out] A
80: *> \verbatim
81: *> A is DOUBLE PRECISION array, dimension (LDA, N)
82: *> On entry, the symmetric matrix A. If UPLO = 'U', the
83: *> leading N-by-N upper triangular part of A contains the
84: *> upper triangular part of the matrix A. If UPLO = 'L',
85: *> the leading N-by-N lower triangular part of A contains
86: *> the lower triangular part of the matrix A.
87: *> On exit, the lower triangle (if UPLO='L') or the upper
88: *> triangle (if UPLO='U') of A, including the diagonal, is
89: *> destroyed.
90: *> \endverbatim
91: *>
92: *> \param[in] LDA
93: *> \verbatim
94: *> LDA is INTEGER
95: *> The leading dimension of the array A. LDA >= max(1,N).
96: *> \endverbatim
97: *>
98: *> \param[in] VL
99: *> \verbatim
100: *> VL is DOUBLE PRECISION
101: *> \endverbatim
102: *>
103: *> \param[in] VU
104: *> \verbatim
105: *> VU is DOUBLE PRECISION
106: *> If RANGE='V', the lower and upper bounds of the interval to
107: *> be searched for eigenvalues. VL < VU.
108: *> Not referenced if RANGE = 'A' or 'I'.
109: *> \endverbatim
110: *>
111: *> \param[in] IL
112: *> \verbatim
113: *> IL is INTEGER
114: *> \endverbatim
115: *>
116: *> \param[in] IU
117: *> \verbatim
118: *> IU is INTEGER
119: *> If RANGE='I', the indices (in ascending order) of the
120: *> smallest and largest eigenvalues to be returned.
121: *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
122: *> Not referenced if RANGE = 'A' or 'V'.
123: *> \endverbatim
124: *>
125: *> \param[in] ABSTOL
126: *> \verbatim
127: *> ABSTOL is DOUBLE PRECISION
128: *> The absolute error tolerance for the eigenvalues.
129: *> An approximate eigenvalue is accepted as converged
130: *> when it is determined to lie in an interval [a,b]
131: *> of width less than or equal to
132: *>
133: *> ABSTOL + EPS * max( |a|,|b| ) ,
134: *>
135: *> where EPS is the machine precision. If ABSTOL is less than
136: *> or equal to zero, then EPS*|T| will be used in its place,
137: *> where |T| is the 1-norm of the tridiagonal matrix obtained
138: *> by reducing A to tridiagonal form.
139: *>
140: *> Eigenvalues will be computed most accurately when ABSTOL is
141: *> set to twice the underflow threshold 2*DLAMCH('S'), not zero.
142: *> If this routine returns with INFO>0, indicating that some
143: *> eigenvectors did not converge, try setting ABSTOL to
144: *> 2*DLAMCH('S').
145: *>
146: *> See "Computing Small Singular Values of Bidiagonal Matrices
147: *> with Guaranteed High Relative Accuracy," by Demmel and
148: *> Kahan, LAPACK Working Note #3.
149: *> \endverbatim
150: *>
151: *> \param[out] M
152: *> \verbatim
153: *> M is INTEGER
154: *> The total number of eigenvalues found. 0 <= M <= N.
155: *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
156: *> \endverbatim
157: *>
158: *> \param[out] W
159: *> \verbatim
160: *> W is DOUBLE PRECISION array, dimension (N)
161: *> On normal exit, the first M elements contain the selected
162: *> eigenvalues in ascending order.
163: *> \endverbatim
164: *>
165: *> \param[out] Z
166: *> \verbatim
167: *> Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M))
168: *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
169: *> contain the orthonormal eigenvectors of the matrix A
170: *> corresponding to the selected eigenvalues, with the i-th
171: *> column of Z holding the eigenvector associated with W(i).
172: *> If an eigenvector fails to converge, then that column of Z
173: *> contains the latest approximation to the eigenvector, and the
174: *> index of the eigenvector is returned in IFAIL.
175: *> If JOBZ = 'N', then Z is not referenced.
176: *> Note: the user must ensure that at least max(1,M) columns are
177: *> supplied in the array Z; if RANGE = 'V', the exact value of M
178: *> is not known in advance and an upper bound must be used.
179: *> \endverbatim
180: *>
181: *> \param[in] LDZ
182: *> \verbatim
183: *> LDZ is INTEGER
184: *> The leading dimension of the array Z. LDZ >= 1, and if
185: *> JOBZ = 'V', LDZ >= max(1,N).
186: *> \endverbatim
187: *>
188: *> \param[out] WORK
189: *> \verbatim
190: *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
191: *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
192: *> \endverbatim
193: *>
194: *> \param[in] LWORK
195: *> \verbatim
196: *> LWORK is INTEGER
197: *> The length of the array WORK. LWORK >= 1, when N <= 1;
198: *> otherwise 8*N.
199: *> For optimal efficiency, LWORK >= (NB+3)*N,
200: *> where NB is the max of the blocksize for DSYTRD and DORMTR
201: *> returned by ILAENV.
202: *>
203: *> If LWORK = -1, then a workspace query is assumed; the routine
204: *> only calculates the optimal size of the WORK array, returns
205: *> this value as the first entry of the WORK array, and no error
206: *> message related to LWORK is issued by XERBLA.
207: *> \endverbatim
208: *>
209: *> \param[out] IWORK
210: *> \verbatim
211: *> IWORK is INTEGER array, dimension (5*N)
212: *> \endverbatim
213: *>
214: *> \param[out] IFAIL
215: *> \verbatim
216: *> IFAIL is INTEGER array, dimension (N)
217: *> If JOBZ = 'V', then if INFO = 0, the first M elements of
218: *> IFAIL are zero. If INFO > 0, then IFAIL contains the
219: *> indices of the eigenvectors that failed to converge.
220: *> If JOBZ = 'N', then IFAIL is not referenced.
221: *> \endverbatim
222: *>
223: *> \param[out] INFO
224: *> \verbatim
225: *> INFO is INTEGER
226: *> = 0: successful exit
227: *> < 0: if INFO = -i, the i-th argument had an illegal value
228: *> > 0: if INFO = i, then i eigenvectors failed to converge.
229: *> Their indices are stored in array IFAIL.
230: *> \endverbatim
231: *
232: * Authors:
233: * ========
234: *
235: *> \author Univ. of Tennessee
236: *> \author Univ. of California Berkeley
237: *> \author Univ. of Colorado Denver
238: *> \author NAG Ltd.
239: *
240: *> \date November 2011
241: *
242: *> \ingroup doubleSYeigen
243: *
244: * =====================================================================
1.1 bertrand 245: SUBROUTINE DSYEVX( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU,
246: $ ABSTOL, M, W, Z, LDZ, WORK, LWORK, IWORK,
247: $ IFAIL, INFO )
248: *
1.8 bertrand 249: * -- LAPACK driver routine (version 3.4.0) --
1.1 bertrand 250: * -- LAPACK is a software package provided by Univ. of Tennessee, --
251: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.8 bertrand 252: * November 2011
1.1 bertrand 253: *
254: * .. Scalar Arguments ..
255: CHARACTER JOBZ, RANGE, UPLO
256: INTEGER IL, INFO, IU, LDA, LDZ, LWORK, M, N
257: DOUBLE PRECISION ABSTOL, VL, VU
258: * ..
259: * .. Array Arguments ..
260: INTEGER IFAIL( * ), IWORK( * )
261: DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * ), Z( LDZ, * )
262: * ..
263: *
264: * =====================================================================
265: *
266: * .. Parameters ..
267: DOUBLE PRECISION ZERO, ONE
268: PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
269: * ..
270: * .. Local Scalars ..
271: LOGICAL ALLEIG, INDEIG, LOWER, LQUERY, TEST, VALEIG,
272: $ WANTZ
273: CHARACTER ORDER
274: INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
275: $ INDISP, INDIWO, INDTAU, INDWKN, INDWRK, ISCALE,
276: $ ITMP1, J, JJ, LLWORK, LLWRKN, LWKMIN,
277: $ LWKOPT, NB, NSPLIT
278: DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
279: $ SIGMA, SMLNUM, TMP1, VLL, VUU
280: * ..
281: * .. External Functions ..
282: LOGICAL LSAME
283: INTEGER ILAENV
284: DOUBLE PRECISION DLAMCH, DLANSY
285: EXTERNAL LSAME, ILAENV, DLAMCH, DLANSY
286: * ..
287: * .. External Subroutines ..
288: EXTERNAL DCOPY, DLACPY, DORGTR, DORMTR, DSCAL, DSTEBZ,
289: $ DSTEIN, DSTEQR, DSTERF, DSWAP, DSYTRD, XERBLA
290: * ..
291: * .. Intrinsic Functions ..
292: INTRINSIC MAX, MIN, SQRT
293: * ..
294: * .. Executable Statements ..
295: *
296: * Test the input parameters.
297: *
298: LOWER = LSAME( UPLO, 'L' )
299: WANTZ = LSAME( JOBZ, 'V' )
300: ALLEIG = LSAME( RANGE, 'A' )
301: VALEIG = LSAME( RANGE, 'V' )
302: INDEIG = LSAME( RANGE, 'I' )
303: LQUERY = ( LWORK.EQ.-1 )
304: *
305: INFO = 0
306: IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
307: INFO = -1
308: ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
309: INFO = -2
310: ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
311: INFO = -3
312: ELSE IF( N.LT.0 ) THEN
313: INFO = -4
314: ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
315: INFO = -6
316: ELSE
317: IF( VALEIG ) THEN
318: IF( N.GT.0 .AND. VU.LE.VL )
319: $ INFO = -8
320: ELSE IF( INDEIG ) THEN
321: IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
322: INFO = -9
323: ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
324: INFO = -10
325: END IF
326: END IF
327: END IF
328: IF( INFO.EQ.0 ) THEN
329: IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
330: INFO = -15
331: END IF
332: END IF
333: *
334: IF( INFO.EQ.0 ) THEN
335: IF( N.LE.1 ) THEN
336: LWKMIN = 1
337: WORK( 1 ) = LWKMIN
338: ELSE
339: LWKMIN = 8*N
340: NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 )
341: NB = MAX( NB, ILAENV( 1, 'DORMTR', UPLO, N, -1, -1, -1 ) )
342: LWKOPT = MAX( LWKMIN, ( NB + 3 )*N )
343: WORK( 1 ) = LWKOPT
344: END IF
345: *
346: IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )
347: $ INFO = -17
348: END IF
349: *
350: IF( INFO.NE.0 ) THEN
351: CALL XERBLA( 'DSYEVX', -INFO )
352: RETURN
353: ELSE IF( LQUERY ) THEN
354: RETURN
355: END IF
356: *
357: * Quick return if possible
358: *
359: M = 0
360: IF( N.EQ.0 ) THEN
361: RETURN
362: END IF
363: *
364: IF( N.EQ.1 ) THEN
365: IF( ALLEIG .OR. INDEIG ) THEN
366: M = 1
367: W( 1 ) = A( 1, 1 )
368: ELSE
369: IF( VL.LT.A( 1, 1 ) .AND. VU.GE.A( 1, 1 ) ) THEN
370: M = 1
371: W( 1 ) = A( 1, 1 )
372: END IF
373: END IF
374: IF( WANTZ )
375: $ Z( 1, 1 ) = ONE
376: RETURN
377: END IF
378: *
379: * Get machine constants.
380: *
381: SAFMIN = DLAMCH( 'Safe minimum' )
382: EPS = DLAMCH( 'Precision' )
383: SMLNUM = SAFMIN / EPS
384: BIGNUM = ONE / SMLNUM
385: RMIN = SQRT( SMLNUM )
386: RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
387: *
388: * Scale matrix to allowable range, if necessary.
389: *
390: ISCALE = 0
391: ABSTLL = ABSTOL
392: IF( VALEIG ) THEN
393: VLL = VL
394: VUU = VU
395: END IF
396: ANRM = DLANSY( 'M', UPLO, N, A, LDA, WORK )
397: IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
398: ISCALE = 1
399: SIGMA = RMIN / ANRM
400: ELSE IF( ANRM.GT.RMAX ) THEN
401: ISCALE = 1
402: SIGMA = RMAX / ANRM
403: END IF
404: IF( ISCALE.EQ.1 ) THEN
405: IF( LOWER ) THEN
406: DO 10 J = 1, N
407: CALL DSCAL( N-J+1, SIGMA, A( J, J ), 1 )
408: 10 CONTINUE
409: ELSE
410: DO 20 J = 1, N
411: CALL DSCAL( J, SIGMA, A( 1, J ), 1 )
412: 20 CONTINUE
413: END IF
414: IF( ABSTOL.GT.0 )
415: $ ABSTLL = ABSTOL*SIGMA
416: IF( VALEIG ) THEN
417: VLL = VL*SIGMA
418: VUU = VU*SIGMA
419: END IF
420: END IF
421: *
422: * Call DSYTRD to reduce symmetric matrix to tridiagonal form.
423: *
424: INDTAU = 1
425: INDE = INDTAU + N
426: INDD = INDE + N
427: INDWRK = INDD + N
428: LLWORK = LWORK - INDWRK + 1
429: CALL DSYTRD( UPLO, N, A, LDA, WORK( INDD ), WORK( INDE ),
430: $ WORK( INDTAU ), WORK( INDWRK ), LLWORK, IINFO )
431: *
432: * If all eigenvalues are desired and ABSTOL is less than or equal to
433: * zero, then call DSTERF or DORGTR and SSTEQR. If this fails for
434: * some eigenvalue, then try DSTEBZ.
435: *
436: TEST = .FALSE.
437: IF( INDEIG ) THEN
438: IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
439: TEST = .TRUE.
440: END IF
441: END IF
442: IF( ( ALLEIG .OR. TEST ) .AND. ( ABSTOL.LE.ZERO ) ) THEN
443: CALL DCOPY( N, WORK( INDD ), 1, W, 1 )
444: INDEE = INDWRK + 2*N
445: IF( .NOT.WANTZ ) THEN
446: CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
447: CALL DSTERF( N, W, WORK( INDEE ), INFO )
448: ELSE
449: CALL DLACPY( 'A', N, N, A, LDA, Z, LDZ )
450: CALL DORGTR( UPLO, N, Z, LDZ, WORK( INDTAU ),
451: $ WORK( INDWRK ), LLWORK, IINFO )
452: CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
453: CALL DSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
454: $ WORK( INDWRK ), INFO )
455: IF( INFO.EQ.0 ) THEN
456: DO 30 I = 1, N
457: IFAIL( I ) = 0
458: 30 CONTINUE
459: END IF
460: END IF
461: IF( INFO.EQ.0 ) THEN
462: M = N
463: GO TO 40
464: END IF
465: INFO = 0
466: END IF
467: *
468: * Otherwise, call DSTEBZ and, if eigenvectors are desired, SSTEIN.
469: *
470: IF( WANTZ ) THEN
471: ORDER = 'B'
472: ELSE
473: ORDER = 'E'
474: END IF
475: INDIBL = 1
476: INDISP = INDIBL + N
477: INDIWO = INDISP + N
478: CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
479: $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
480: $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
481: $ IWORK( INDIWO ), INFO )
482: *
483: IF( WANTZ ) THEN
484: CALL DSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
485: $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
486: $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
487: *
488: * Apply orthogonal matrix used in reduction to tridiagonal
489: * form to eigenvectors returned by DSTEIN.
490: *
491: INDWKN = INDE
492: LLWRKN = LWORK - INDWKN + 1
493: CALL DORMTR( 'L', UPLO, 'N', N, M, A, LDA, WORK( INDTAU ), Z,
494: $ LDZ, WORK( INDWKN ), LLWRKN, IINFO )
495: END IF
496: *
497: * If matrix was scaled, then rescale eigenvalues appropriately.
498: *
499: 40 CONTINUE
500: IF( ISCALE.EQ.1 ) THEN
501: IF( INFO.EQ.0 ) THEN
502: IMAX = M
503: ELSE
504: IMAX = INFO - 1
505: END IF
506: CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
507: END IF
508: *
509: * If eigenvalues are not in order, then sort them, along with
510: * eigenvectors.
511: *
512: IF( WANTZ ) THEN
513: DO 60 J = 1, M - 1
514: I = 0
515: TMP1 = W( J )
516: DO 50 JJ = J + 1, M
517: IF( W( JJ ).LT.TMP1 ) THEN
518: I = JJ
519: TMP1 = W( JJ )
520: END IF
521: 50 CONTINUE
522: *
523: IF( I.NE.0 ) THEN
524: ITMP1 = IWORK( INDIBL+I-1 )
525: W( I ) = W( J )
526: IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
527: W( J ) = TMP1
528: IWORK( INDIBL+J-1 ) = ITMP1
529: CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
530: IF( INFO.NE.0 ) THEN
531: ITMP1 = IFAIL( I )
532: IFAIL( I ) = IFAIL( J )
533: IFAIL( J ) = ITMP1
534: END IF
535: END IF
536: 60 CONTINUE
537: END IF
538: *
539: * Set WORK(1) to optimal workspace size.
540: *
541: WORK( 1 ) = LWKOPT
542: *
543: RETURN
544: *
545: * End of DSYEVX
546: *
547: END
CVSweb interface <joel.bertrand@systella.fr>