1 *> \brief <b> ZHEEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZHEEVD + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zheevd.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zheevd.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zheevd.f">
21 * SUBROUTINE ZHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
22 * LRWORK, IWORK, LIWORK, INFO )
24 * .. Scalar Arguments ..
25 * CHARACTER JOBZ, UPLO
26 * INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N
28 * .. Array Arguments ..
30 * DOUBLE PRECISION RWORK( * ), W( * )
31 * COMPLEX*16 A( LDA, * ), WORK( * )
40 *> ZHEEVD computes all eigenvalues and, optionally, eigenvectors of a
41 *> complex Hermitian matrix A. If eigenvectors are desired, it uses a
42 *> divide and conquer algorithm.
44 *> The divide and conquer algorithm makes very mild assumptions about
45 *> floating point arithmetic. It will work on machines with a guard
46 *> digit in add/subtract, or on those binary machines without guard
47 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
48 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines
49 *> without guard digits, but we know of none.
57 *> JOBZ is CHARACTER*1
58 *> = 'N': Compute eigenvalues only;
59 *> = 'V': Compute eigenvalues and eigenvectors.
64 *> UPLO is CHARACTER*1
65 *> = 'U': Upper triangle of A is stored;
66 *> = 'L': Lower triangle of A is stored.
72 *> The order of the matrix A. N >= 0.
77 *> A is COMPLEX*16 array, dimension (LDA, N)
78 *> On entry, the Hermitian matrix A. If UPLO = 'U', the
79 *> leading N-by-N upper triangular part of A contains the
80 *> upper triangular part of the matrix A. If UPLO = 'L',
81 *> the leading N-by-N lower triangular part of A contains
82 *> the lower triangular part of the matrix A.
83 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
84 *> orthonormal eigenvectors of the matrix A.
85 *> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
86 *> or the upper triangle (if UPLO='U') of A, including the
87 *> diagonal, is destroyed.
93 *> The leading dimension of the array A. LDA >= max(1,N).
98 *> W is DOUBLE PRECISION array, dimension (N)
99 *> If INFO = 0, the eigenvalues in ascending order.
104 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
105 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
111 *> The length of the array WORK.
112 *> If N <= 1, LWORK must be at least 1.
113 *> If JOBZ = 'N' and N > 1, LWORK must be at least N + 1.
114 *> If JOBZ = 'V' and N > 1, LWORK must be at least 2*N + N**2.
116 *> If LWORK = -1, then a workspace query is assumed; the routine
117 *> only calculates the optimal sizes of the WORK, RWORK and
118 *> IWORK arrays, returns these values as the first entries of
119 *> the WORK, RWORK and IWORK arrays, and no error message
120 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
125 *> RWORK is DOUBLE PRECISION array,
126 *> dimension (LRWORK)
127 *> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.
133 *> The dimension of the array RWORK.
134 *> If N <= 1, LRWORK must be at least 1.
135 *> If JOBZ = 'N' and N > 1, LRWORK must be at least N.
136 *> If JOBZ = 'V' and N > 1, LRWORK must be at least
139 *> If LRWORK = -1, then a workspace query is assumed; the
140 *> routine only calculates the optimal sizes of the WORK, RWORK
141 *> and IWORK arrays, returns these values as the first entries
142 *> of the WORK, RWORK and IWORK arrays, and no error message
143 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
148 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
149 *> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
155 *> The dimension of the array IWORK.
156 *> If N <= 1, LIWORK must be at least 1.
157 *> If JOBZ = 'N' and N > 1, LIWORK must be at least 1.
158 *> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N.
160 *> If LIWORK = -1, then a workspace query is assumed; the
161 *> routine only calculates the optimal sizes of the WORK, RWORK
162 *> and IWORK arrays, returns these values as the first entries
163 *> of the WORK, RWORK and IWORK arrays, and no error message
164 *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
170 *> = 0: successful exit
171 *> < 0: if INFO = -i, the i-th argument had an illegal value
172 *> > 0: if INFO = i and JOBZ = 'N', then the algorithm failed
173 *> to converge; i off-diagonal elements of an intermediate
174 *> tridiagonal form did not converge to zero;
175 *> if INFO = i and JOBZ = 'V', then the algorithm failed
176 *> to compute an eigenvalue while working on the submatrix
177 *> lying in rows and columns INFO/(N+1) through
184 *> \author Univ. of Tennessee
185 *> \author Univ. of California Berkeley
186 *> \author Univ. of Colorado Denver
189 *> \date November 2011
191 *> \ingroup complex16HEeigen
193 *> \par Further Details:
194 * =====================
196 *> Modified description of INFO. Sven, 16 Feb 05.
198 *> \par Contributors:
201 *> Jeff Rutter, Computer Science Division, University of California
204 * =====================================================================
205 SUBROUTINE ZHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
206 $ LRWORK, IWORK, LIWORK, INFO )
208 * -- LAPACK driver routine (version 3.4.0) --
209 * -- LAPACK is a software package provided by Univ. of Tennessee, --
210 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
213 * .. Scalar Arguments ..
215 INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N
217 * .. Array Arguments ..
219 DOUBLE PRECISION RWORK( * ), W( * )
220 COMPLEX*16 A( LDA, * ), WORK( * )
223 * =====================================================================
226 DOUBLE PRECISION ZERO, ONE
227 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
229 PARAMETER ( CONE = ( 1.0D0, 0.0D0 ) )
231 * .. Local Scalars ..
232 LOGICAL LOWER, LQUERY, WANTZ
233 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWK2,
234 $ INDWRK, ISCALE, LIOPT, LIWMIN, LLRWK, LLWORK,
235 $ LLWRK2, LOPT, LROPT, LRWMIN, LWMIN
236 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
239 * .. External Functions ..
242 DOUBLE PRECISION DLAMCH, ZLANHE
243 EXTERNAL LSAME, ILAENV, DLAMCH, ZLANHE
245 * .. External Subroutines ..
246 EXTERNAL DSCAL, DSTERF, XERBLA, ZHETRD, ZLACPY, ZLASCL,
249 * .. Intrinsic Functions ..
252 * .. Executable Statements ..
254 * Test the input parameters.
256 WANTZ = LSAME( JOBZ, 'V' )
257 LOWER = LSAME( UPLO, 'L' )
258 LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
261 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
263 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
265 ELSE IF( N.LT.0 ) THEN
267 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
282 LRWMIN = 1 + 5*N + 2*N**2
289 LOPT = MAX( LWMIN, N +
290 $ ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 ) )
298 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
300 ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THEN
302 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
308 CALL XERBLA( 'ZHEEVD', -INFO )
310 ELSE IF( LQUERY ) THEN
314 * Quick return if possible
326 * Get machine constants.
328 SAFMIN = DLAMCH( 'Safe minimum' )
329 EPS = DLAMCH( 'Precision' )
330 SMLNUM = SAFMIN / EPS
331 BIGNUM = ONE / SMLNUM
332 RMIN = SQRT( SMLNUM )
333 RMAX = SQRT( BIGNUM )
335 * Scale matrix to allowable range, if necessary.
337 ANRM = ZLANHE( 'M', UPLO, N, A, LDA, RWORK )
339 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
342 ELSE IF( ANRM.GT.RMAX ) THEN
347 $ CALL ZLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )
349 * Call ZHETRD to reduce Hermitian matrix to tridiagonal form.
355 INDWK2 = INDWRK + N*N
356 LLWORK = LWORK - INDWRK + 1
357 LLWRK2 = LWORK - INDWK2 + 1
358 LLRWK = LRWORK - INDRWK + 1
359 CALL ZHETRD( UPLO, N, A, LDA, W, RWORK( INDE ), WORK( INDTAU ),
360 $ WORK( INDWRK ), LLWORK, IINFO )
362 * For eigenvalues only, call DSTERF. For eigenvectors, first call
363 * ZSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the
364 * tridiagonal matrix, then call ZUNMTR to multiply it to the
365 * Householder transformations represented as Householder vectors in
368 IF( .NOT.WANTZ ) THEN
369 CALL DSTERF( N, W, RWORK( INDE ), INFO )
371 CALL ZSTEDC( 'I', N, W, RWORK( INDE ), WORK( INDWRK ), N,
372 $ WORK( INDWK2 ), LLWRK2, RWORK( INDRWK ), LLRWK,
373 $ IWORK, LIWORK, INFO )
374 CALL ZUNMTR( 'L', UPLO, 'N', N, N, A, LDA, WORK( INDTAU ),
375 $ WORK( INDWRK ), N, WORK( INDWK2 ), LLWRK2, IINFO )
376 CALL ZLACPY( 'A', N, N, WORK( INDWRK ), N, A, LDA )
379 * If matrix was scaled, then rescale eigenvalues appropriately.
381 IF( ISCALE.EQ.1 ) THEN
387 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )