LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zheev.f
Go to the documentation of this file.
1*> \brief <b> ZHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHEEV + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zheev.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zheev.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zheev.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
20* INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ, UPLO
24* INTEGER INFO, LDA, LWORK, N
25* ..
26* .. Array Arguments ..
27* DOUBLE PRECISION RWORK( * ), W( * )
28* COMPLEX*16 A( LDA, * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> ZHEEV computes all eigenvalues and, optionally, eigenvectors of a
38*> complex Hermitian matrix A.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] JOBZ
45*> \verbatim
46*> JOBZ is CHARACTER*1
47*> = 'N': Compute eigenvalues only;
48*> = 'V': Compute eigenvalues and eigenvectors.
49*> \endverbatim
50*>
51*> \param[in] UPLO
52*> \verbatim
53*> UPLO is CHARACTER*1
54*> = 'U': Upper triangle of A is stored;
55*> = 'L': Lower triangle of A is stored.
56*> \endverbatim
57*>
58*> \param[in] N
59*> \verbatim
60*> N is INTEGER
61*> The order of the matrix A. N >= 0.
62*> \endverbatim
63*>
64*> \param[in,out] A
65*> \verbatim
66*> A is COMPLEX*16 array, dimension (LDA, N)
67*> On entry, the Hermitian matrix A. If UPLO = 'U', the
68*> leading N-by-N upper triangular part of A contains the
69*> upper triangular part of the matrix A. If UPLO = 'L',
70*> the leading N-by-N lower triangular part of A contains
71*> the lower triangular part of the matrix A.
72*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
73*> orthonormal eigenvectors of the matrix A.
74*> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
75*> or the upper triangle (if UPLO='U') of A, including the
76*> diagonal, is destroyed.
77*> \endverbatim
78*>
79*> \param[in] LDA
80*> \verbatim
81*> LDA is INTEGER
82*> The leading dimension of the array A. LDA >= max(1,N).
83*> \endverbatim
84*>
85*> \param[out] W
86*> \verbatim
87*> W is DOUBLE PRECISION array, dimension (N)
88*> If INFO = 0, the eigenvalues in ascending order.
89*> \endverbatim
90*>
91*> \param[out] WORK
92*> \verbatim
93*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
94*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
95*> \endverbatim
96*>
97*> \param[in] LWORK
98*> \verbatim
99*> LWORK is INTEGER
100*> The length of the array WORK. LWORK >= max(1,2*N-1).
101*> For optimal efficiency, LWORK >= (NB+1)*N,
102*> where NB is the blocksize for ZHETRD returned by ILAENV.
103*>
104*> If LWORK = -1, then a workspace query is assumed; the routine
105*> only calculates the optimal size of the WORK array, returns
106*> this value as the first entry of the WORK array, and no error
107*> message related to LWORK is issued by XERBLA.
108*> \endverbatim
109*>
110*> \param[out] RWORK
111*> \verbatim
112*> RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2))
113*> \endverbatim
114*>
115*> \param[out] INFO
116*> \verbatim
117*> INFO is INTEGER
118*> = 0: successful exit
119*> < 0: if INFO = -i, the i-th argument had an illegal value
120*> > 0: if INFO = i, the algorithm failed to converge; i
121*> off-diagonal elements of an intermediate tridiagonal
122*> form did not converge to zero.
123*> \endverbatim
124*
125* Authors:
126* ========
127*
128*> \author Univ. of Tennessee
129*> \author Univ. of California Berkeley
130*> \author Univ. of Colorado Denver
131*> \author NAG Ltd.
132*
133*> \ingroup heev
134*
135* =====================================================================
136 SUBROUTINE zheev( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,
137 $ INFO )
138*
139* -- LAPACK driver routine --
140* -- LAPACK is a software package provided by Univ. of Tennessee, --
141* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
142*
143* .. Scalar Arguments ..
144 CHARACTER JOBZ, UPLO
145 INTEGER INFO, LDA, LWORK, N
146* ..
147* .. Array Arguments ..
148 DOUBLE PRECISION RWORK( * ), W( * )
149 COMPLEX*16 A( LDA, * ), WORK( * )
150* ..
151*
152* =====================================================================
153*
154* .. Parameters ..
155 DOUBLE PRECISION ZERO, ONE
156 parameter( zero = 0.0d0, one = 1.0d0 )
157 COMPLEX*16 CONE
158 parameter( cone = ( 1.0d0, 0.0d0 ) )
159* ..
160* .. Local Scalars ..
161 LOGICAL LOWER, LQUERY, WANTZ
162 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
163 $ llwork, lwkopt, nb
164 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
165 $ smlnum
166* ..
167* .. External Functions ..
168 LOGICAL LSAME
169 INTEGER ILAENV
170 DOUBLE PRECISION DLAMCH, ZLANHE
171 EXTERNAL lsame, ilaenv, dlamch, zlanhe
172* ..
173* .. External Subroutines ..
174 EXTERNAL dscal, dsterf, xerbla, zhetrd, zlascl,
175 $ zsteqr,
176 $ zungtr
177* ..
178* .. Intrinsic Functions ..
179 INTRINSIC max, sqrt
180* ..
181* .. Executable Statements ..
182*
183* Test the input parameters.
184*
185 wantz = lsame( jobz, 'V' )
186 lower = lsame( uplo, 'L' )
187 lquery = ( lwork.EQ.-1 )
188*
189 info = 0
190 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
191 info = -1
192 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
193 info = -2
194 ELSE IF( n.LT.0 ) THEN
195 info = -3
196 ELSE IF( lda.LT.max( 1, n ) ) THEN
197 info = -5
198 END IF
199*
200 IF( info.EQ.0 ) THEN
201 nb = ilaenv( 1, 'ZHETRD', uplo, n, -1, -1, -1 )
202 lwkopt = max( 1, ( nb+1 )*n )
203 work( 1 ) = lwkopt
204*
205 IF( lwork.LT.max( 1, 2*n-1 ) .AND. .NOT.lquery )
206 $ info = -8
207 END IF
208*
209 IF( info.NE.0 ) THEN
210 CALL xerbla( 'ZHEEV ', -info )
211 RETURN
212 ELSE IF( lquery ) THEN
213 RETURN
214 END IF
215*
216* Quick return if possible
217*
218 IF( n.EQ.0 ) THEN
219 RETURN
220 END IF
221*
222 IF( n.EQ.1 ) THEN
223 w( 1 ) = dble( a( 1, 1 ) )
224 work( 1 ) = 1
225 IF( wantz )
226 $ a( 1, 1 ) = cone
227 RETURN
228 END IF
229*
230* Get machine constants.
231*
232 safmin = dlamch( 'Safe minimum' )
233 eps = dlamch( 'Precision' )
234 smlnum = safmin / eps
235 bignum = one / smlnum
236 rmin = sqrt( smlnum )
237 rmax = sqrt( bignum )
238*
239* Scale matrix to allowable range, if necessary.
240*
241 anrm = zlanhe( 'M', uplo, n, a, lda, rwork )
242 iscale = 0
243 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
244 iscale = 1
245 sigma = rmin / anrm
246 ELSE IF( anrm.GT.rmax ) THEN
247 iscale = 1
248 sigma = rmax / anrm
249 END IF
250 IF( iscale.EQ.1 )
251 $ CALL zlascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
252*
253* Call ZHETRD to reduce Hermitian matrix to tridiagonal form.
254*
255 inde = 1
256 indtau = 1
257 indwrk = indtau + n
258 llwork = lwork - indwrk + 1
259 CALL zhetrd( uplo, n, a, lda, w, rwork( inde ), work( indtau ),
260 $ work( indwrk ), llwork, iinfo )
261*
262* For eigenvalues only, call DSTERF. For eigenvectors, first call
263* ZUNGTR to generate the unitary matrix, then call ZSTEQR.
264*
265 IF( .NOT.wantz ) THEN
266 CALL dsterf( n, w, rwork( inde ), info )
267 ELSE
268 CALL zungtr( uplo, n, a, lda, work( indtau ),
269 $ work( indwrk ),
270 $ llwork, iinfo )
271 indwrk = inde + n
272 CALL zsteqr( jobz, n, w, rwork( inde ), a, lda,
273 $ rwork( indwrk ), info )
274 END IF
275*
276* If matrix was scaled, then rescale eigenvalues appropriately.
277*
278 IF( iscale.EQ.1 ) THEN
279 IF( info.EQ.0 ) THEN
280 imax = n
281 ELSE
282 imax = info - 1
283 END IF
284 CALL dscal( imax, one / sigma, w, 1 )
285 END IF
286*
287* Set WORK(1) to optimal complex workspace size.
288*
289 work( 1 ) = lwkopt
290*
291 RETURN
292*
293* End of ZHEEV
294*
295 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zheev(jobz, uplo, n, a, lda, w, work, lwork, rwork, info)
ZHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices
Definition zheev.f:138
subroutine zhetrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
ZHETRD
Definition zhetrd.f:191
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition zlascl.f:142
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine zsteqr(compz, n, d, e, z, ldz, work, info)
ZSTEQR
Definition zsteqr.f:130
subroutine dsterf(n, d, e, info)
DSTERF
Definition dsterf.f:84
subroutine zungtr(uplo, n, a, lda, tau, work, lwork, info)
ZUNGTR
Definition zungtr.f:121