194 SUBROUTINE cheevd( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK,
196 $ LRWORK, IWORK, LIWORK, INFO )
204 INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N
208 REAL RWORK( * ), W( * )
209 COMPLEX A( LDA, * ), WORK( * )
216 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
218 parameter( cone = ( 1.0e0, 0.0e0 ) )
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 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
231 REAL CLANHE, SLAMCH, SROUNDUP_LWORK
232 EXTERNAL ilaenv, lsame, clanhe, slamch,
247 wantz = lsame( jobz,
'V' )
248 lower = lsame( uplo,
'L' )
249 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
252 IF( .NOT.( wantz .OR. lsame( jobz,
'N' ) ) )
THEN
254 ELSE IF( .NOT.( lower .OR. lsame( uplo,
'U' ) ) )
THEN
256 ELSE IF( n.LT.0 )
THEN
258 ELSE IF( lda.LT.max( 1, n ) )
THEN
273 lrwmin = 1 + 5*n + 2*n**2
280 lopt = max( lwmin, n +
281 $ n*ilaenv( 1,
'CHETRD', uplo, n, -1, -1,
286 work( 1 ) = sroundup_lwork( lopt )
287 rwork( 1 ) = sroundup_lwork( lropt )
290 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
292 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery )
THEN
294 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
300 CALL xerbla(
'CHEEVD', -info )
302 ELSE IF( lquery )
THEN
312 w( 1 ) = real( a( 1, 1 ) )
320 safmin = slamch(
'Safe minimum' )
321 eps = slamch(
'Precision' )
322 smlnum = safmin / eps
323 bignum = one / smlnum
324 rmin = sqrt( smlnum )
325 rmax = sqrt( bignum )
329 anrm = clanhe(
'M', uplo, n, a, lda, rwork )
331 IF( anrm.GT.zero .AND. anrm.LT.rmin )
THEN
334 ELSE IF( anrm.GT.rmax )
THEN
339 $
CALL clascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
347 indwk2 = indwrk + n*n
348 llwork = lwork - indwrk + 1
349 llwrk2 = lwork - indwk2 + 1
350 llrwk = lrwork - indrwk + 1
351 CALL chetrd( uplo, n, a, lda, w, rwork( inde ), work( indtau ),
352 $ work( indwrk ), llwork, iinfo )
360 IF( .NOT.wantz )
THEN
361 CALL ssterf( n, w, rwork( inde ), info )
363 CALL cstedc(
'I', n, w, rwork( inde ), work( indwrk ), n,
364 $ work( indwk2 ), llwrk2, rwork( indrwk ), llrwk,
365 $ iwork, liwork, info )
366 CALL cunmtr(
'L', uplo,
'N', n, n, a, lda, work( indtau ),
367 $ work( indwrk ), n, work( indwk2 ), llwrk2, iinfo )
368 CALL clacpy(
'A', n, n, work( indwrk ), n, a, lda )
373 IF( iscale.EQ.1 )
THEN
379 CALL sscal( imax, one / sigma, w, 1 )
382 work( 1 ) = sroundup_lwork( lopt )
383 rwork( 1 ) = sroundup_lwork( lropt )
subroutine cheevd(jobz, uplo, n, a, lda, w, work, lwork, rwork, lrwork, iwork, liwork, info)
CHEEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices