194 SUBROUTINE zheevd( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK,
196 $ LRWORK, IWORK, LIWORK, INFO )
204 INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N
208 DOUBLE PRECISION RWORK( * ), W( * )
209 COMPLEX*16 A( LDA, * ), WORK( * )
215 DOUBLE PRECISION ZERO, ONE
216 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
218 parameter( cone = ( 1.0d0, 0.0d0 ) )
221 LOGICAL LOWER, LQUERY, WANTZ
222 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWK2,
223 $ indwrk, iscale, liopt, liwmin, llrwk, llwork,
224 $ llwrk2, lopt, lropt, lrwmin, lwmin
225 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
231 DOUBLE PRECISION DLAMCH, ZLANHE
232 EXTERNAL lsame, ilaenv, dlamch, zlanhe
246 wantz = lsame( jobz,
'V' )
247 lower = lsame( uplo,
'L' )
248 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
251 IF( .NOT.( wantz .OR. lsame( jobz,
'N' ) ) )
THEN
253 ELSE IF( .NOT.( lower .OR. lsame( uplo,
'U' ) ) )
THEN
255 ELSE IF( n.LT.0 )
THEN
257 ELSE IF( lda.LT.max( 1, n ) )
THEN
272 lrwmin = 1 + 5*n + 2*n**2
279 lopt = max( lwmin, n +
280 $ n*ilaenv( 1,
'ZHETRD', uplo, n, -1, -1,
286 rwork( 1 ) = real( lropt )
289 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
291 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery )
THEN
293 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
299 CALL xerbla(
'ZHEEVD', -info )
301 ELSE IF( lquery )
THEN
311 w( 1 ) = dble( a( 1, 1 ) )
319 safmin = dlamch(
'Safe minimum' )
320 eps = dlamch(
'Precision' )
321 smlnum = safmin / eps
322 bignum = one / smlnum
323 rmin = sqrt( smlnum )
324 rmax = sqrt( bignum )
328 anrm = zlanhe(
'M', uplo, n, a, lda, rwork )
330 IF( anrm.GT.zero .AND. anrm.LT.rmin )
THEN
333 ELSE IF( anrm.GT.rmax )
THEN
338 $
CALL zlascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
346 indwk2 = indwrk + n*n
347 llwork = lwork - indwrk + 1
348 llwrk2 = lwork - indwk2 + 1
349 llrwk = lrwork - indrwk + 1
350 CALL zhetrd( uplo, n, a, lda, w, rwork( inde ), work( indtau ),
351 $ work( indwrk ), llwork, iinfo )
359 IF( .NOT.wantz )
THEN
360 CALL dsterf( n, w, rwork( inde ), info )
362 CALL zstedc(
'I', n, w, rwork( inde ), work( indwrk ), n,
363 $ work( indwk2 ), llwrk2, rwork( indrwk ), llrwk,
364 $ iwork, liwork, info )
365 CALL zunmtr(
'L', uplo,
'N', n, n, a, lda, work( indtau ),
366 $ work( indwrk ), n, work( indwk2 ), llwrk2, iinfo )
367 CALL zlacpy(
'A', n, n, work( indwrk ), n, a, lda )
372 IF( iscale.EQ.1 )
THEN
378 CALL dscal( imax, one / sigma, w, 1 )
382 rwork( 1 ) = real( lropt )
subroutine zheevd(jobz, uplo, n, a, lda, w, work, lwork, rwork, lrwork, iwork, liwork, info)
ZHEEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices