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