LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zheev()

subroutine zheev ( character jobz,
character uplo,
integer n,
complex*16, dimension( lda, * ) a,
integer lda,
double precision, dimension( * ) w,
complex*16, dimension( * ) work,
integer lwork,
double precision, dimension( * ) rwork,
integer info )

ZHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices

Download ZHEEV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> ZHEEV computes all eigenvalues and, optionally, eigenvectors of a
!> complex Hermitian matrix A.
!> 
Parameters
[in]JOBZ
!>          JOBZ is CHARACTER*1
!>          = 'N':  Compute eigenvalues only;
!>          = 'V':  Compute eigenvalues and eigenvectors.
!> 
[in]UPLO
!>          UPLO is CHARACTER*1
!>          = 'U':  Upper triangle of A is stored;
!>          = 'L':  Lower triangle of A is stored.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in,out]A
!>          A is COMPLEX*16 array, dimension (LDA, N)
!>          On entry, the Hermitian matrix A.  If UPLO = 'U', the
!>          leading N-by-N upper triangular part of A contains the
!>          upper triangular part of the matrix A.  If UPLO = 'L',
!>          the leading N-by-N lower triangular part of A contains
!>          the lower triangular part of the matrix A.
!>          On exit, if JOBZ = 'V', then if INFO = 0, A contains the
!>          orthonormal eigenvectors of the matrix A.
!>          If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
!>          or the upper triangle (if UPLO='U') of A, including the
!>          diagonal, is destroyed.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[out]W
!>          W is DOUBLE PRECISION array, dimension (N)
!>          If INFO = 0, the eigenvalues in ascending order.
!> 
[out]WORK
!>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The length of the array WORK.  LWORK >= max(1,2*N-1).
!>          For optimal efficiency, LWORK >= (NB+1)*N,
!>          where NB is the blocksize for ZHETRD returned by ILAENV.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]RWORK
!>          RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2))
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!>          > 0:  if INFO = i, the algorithm failed to converge; i
!>                off-diagonal elements of an intermediate tridiagonal
!>                form did not converge to zero.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 136 of file zheev.f.

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*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zhetrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
ZHETRD
Definition zhetrd.f:191
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function zlanhe(norm, uplo, n, a, lda, work)
ZLANHE returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition zlanhe.f:122
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
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
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
Here is the call graph for this function:
Here is the caller graph for this function: