1 *> \brief <b> CHEEV 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 CHEEV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cheev.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cheev.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cheev.f">
21 * SUBROUTINE CHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
24 * .. Scalar Arguments ..
25 * CHARACTER JOBZ, UPLO
26 * INTEGER INFO, LDA, LWORK, N
28 * .. Array Arguments ..
29 * REAL RWORK( * ), W( * )
30 * COMPLEX A( LDA, * ), WORK( * )
39 *> CHEEV computes all eigenvalues and, optionally, eigenvectors of a
40 *> complex Hermitian matrix A.
48 *> JOBZ is CHARACTER*1
49 *> = 'N': Compute eigenvalues only;
50 *> = 'V': Compute eigenvalues and eigenvectors.
55 *> UPLO is CHARACTER*1
56 *> = 'U': Upper triangle of A is stored;
57 *> = 'L': Lower triangle of A is stored.
63 *> The order of the matrix A. N >= 0.
68 *> A is COMPLEX array, dimension (LDA, N)
69 *> On entry, the Hermitian matrix A. If UPLO = 'U', the
70 *> leading N-by-N upper triangular part of A contains the
71 *> upper triangular part of the matrix A. If UPLO = 'L',
72 *> the leading N-by-N lower triangular part of A contains
73 *> the lower triangular part of the matrix A.
74 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
75 *> orthonormal eigenvectors of the matrix A.
76 *> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
77 *> or the upper triangle (if UPLO='U') of A, including the
78 *> diagonal, is destroyed.
84 *> The leading dimension of the array A. LDA >= max(1,N).
89 *> W is REAL array, dimension (N)
90 *> If INFO = 0, the eigenvalues in ascending order.
95 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
96 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
102 *> The length of the array WORK. LWORK >= max(1,2*N-1).
103 *> For optimal efficiency, LWORK >= (NB+1)*N,
104 *> where NB is the blocksize for CHETRD returned by ILAENV.
106 *> If LWORK = -1, then a workspace query is assumed; the routine
107 *> only calculates the optimal size of the WORK array, returns
108 *> this value as the first entry of the WORK array, and no error
109 *> message related to LWORK is issued by XERBLA.
114 *> RWORK is REAL array, dimension (max(1, 3*N-2))
120 *> = 0: successful exit
121 *> < 0: if INFO = -i, the i-th argument had an illegal value
122 *> > 0: if INFO = i, the algorithm failed to converge; i
123 *> off-diagonal elements of an intermediate tridiagonal
124 *> form did not converge to zero.
130 *> \author Univ. of Tennessee
131 *> \author Univ. of California Berkeley
132 *> \author Univ. of Colorado Denver
135 *> \date November 2011
137 *> \ingroup complexHEeigen
139 * =====================================================================
140 SUBROUTINE CHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
143 * -- LAPACK driver routine (version 3.4.0) --
144 * -- LAPACK is a software package provided by Univ. of Tennessee, --
145 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
148 * .. Scalar Arguments ..
150 INTEGER INFO, LDA, LWORK, N
152 * .. Array Arguments ..
153 REAL RWORK( * ), W( * )
154 COMPLEX A( LDA, * ), WORK( * )
157 * =====================================================================
161 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
163 PARAMETER ( CONE = ( 1.0E0, 0.0E0 ) )
165 * .. Local Scalars ..
166 LOGICAL LOWER, LQUERY, WANTZ
167 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
169 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
172 * .. External Functions ..
176 EXTERNAL ILAENV, LSAME, CLANHE, SLAMCH
178 * .. External Subroutines ..
179 EXTERNAL CHETRD, CLASCL, CSTEQR, CUNGTR, SSCAL, SSTERF,
182 * .. Intrinsic Functions ..
185 * .. Executable Statements ..
187 * Test the input parameters.
189 WANTZ = LSAME( JOBZ, 'V' )
190 LOWER = LSAME( UPLO, 'L' )
191 LQUERY = ( LWORK.EQ.-1 )
194 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
196 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
198 ELSE IF( N.LT.0 ) THEN
200 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
205 NB = ILAENV( 1, 'CHETRD', UPLO, N, -1, -1, -1 )
206 LWKOPT = MAX( 1, ( NB+1 )*N )
209 IF( LWORK.LT.MAX( 1, 2*N-1 ) .AND. .NOT.LQUERY )
214 CALL XERBLA( 'CHEEV ', -INFO )
216 ELSE IF( LQUERY ) THEN
220 * Quick return if possible
234 * Get machine constants.
236 SAFMIN = SLAMCH( 'Safe minimum' )
237 EPS = SLAMCH( 'Precision' )
238 SMLNUM = SAFMIN / EPS
239 BIGNUM = ONE / SMLNUM
240 RMIN = SQRT( SMLNUM )
241 RMAX = SQRT( BIGNUM )
243 * Scale matrix to allowable range, if necessary.
245 ANRM = CLANHE( 'M', UPLO, N, A, LDA, RWORK )
247 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
250 ELSE IF( ANRM.GT.RMAX ) THEN
255 $ CALL CLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )
257 * Call CHETRD to reduce Hermitian matrix to tridiagonal form.
262 LLWORK = LWORK - INDWRK + 1
263 CALL CHETRD( UPLO, N, A, LDA, W, RWORK( INDE ), WORK( INDTAU ),
264 $ WORK( INDWRK ), LLWORK, IINFO )
266 * For eigenvalues only, call SSTERF. For eigenvectors, first call
267 * CUNGTR to generate the unitary matrix, then call CSTEQR.
269 IF( .NOT.WANTZ ) THEN
270 CALL SSTERF( N, W, RWORK( INDE ), INFO )
272 CALL CUNGTR( UPLO, N, A, LDA, WORK( INDTAU ), WORK( INDWRK ),
275 CALL CSTEQR( JOBZ, N, W, RWORK( INDE ), A, LDA,
276 $ RWORK( INDWRK ), INFO )
279 * If matrix was scaled, then rescale eigenvalues appropriately.
281 IF( ISCALE.EQ.1 ) THEN
287 CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
290 * Set WORK(1) to optimal complex workspace size.