177 SUBROUTINE zgeev( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,
178 $ work, lwork, rwork, info )
186 CHARACTER jobvl, jobvr
187 INTEGER info, lda, ldvl, ldvr, lwork, n
190 DOUBLE PRECISION rwork( * )
191 COMPLEX*16 a( lda, * ), vl( ldvl, * ), vr( ldvr, * ),
198 DOUBLE PRECISION zero, one
199 parameter( zero = 0.0d0, one = 1.0d0 )
202 LOGICAL lquery, scalea, wantvl, wantvr
204 INTEGER hswork, i, ibal, ierr, ihi, ilo, irwork, itau,
205 $ iwrk, k, maxwrk, minwrk, nout
206 DOUBLE PRECISION anrm, bignum, cscale, eps, scl, smlnum
211 DOUBLE PRECISION dum( 1 )
224 INTRINSIC dble, dcmplx, dconjg, dimag, max, sqrt
231 lquery = ( lwork.EQ.-1 )
232 wantvl =
lsame( jobvl,
'V' )
233 wantvr =
lsame( jobvr,
'V' )
234 IF( ( .NOT.wantvl ) .AND. ( .NOT.
lsame( jobvl,
'N' ) ) )
THEN
236 ELSE IF( ( .NOT.wantvr ) .AND. ( .NOT.
lsame( jobvr,
'N' ) ) )
THEN
238 ELSE IF( n.LT.0 )
THEN
240 ELSE IF( lda.LT.max( 1, n ) )
THEN
242 ELSE IF( ldvl.LT.1 .OR. ( wantvl .AND. ldvl.LT.n ) )
THEN
244 ELSE IF( ldvr.LT.1 .OR. ( wantvr .AND. ldvr.LT.n ) )
THEN
264 maxwrk = n + n*
ilaenv( 1,
'ZGEHRD',
' ', n, 1, n, 0 )
267 maxwrk = max( maxwrk, n + ( n - 1 )*
ilaenv( 1,
'ZUNGHR',
268 $
' ', n, 1, n, -1 ) )
269 CALL
zhseqr(
'S',
'V', n, 1, n, a, lda, w, vl, ldvl,
271 ELSE IF( wantvr )
THEN
272 maxwrk = max( maxwrk, n + ( n - 1 )*
ilaenv( 1,
'ZUNGHR',
273 $
' ', n, 1, n, -1 ) )
274 CALL
zhseqr(
'S',
'V', n, 1, n, a, lda, w, vr, ldvr,
277 CALL
zhseqr(
'E',
'N', n, 1, n, a, lda, w, vr, ldvr,
281 maxwrk = max( maxwrk, hswork, minwrk )
285 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
291 CALL
xerbla(
'ZGEEV ', -info )
293 ELSE IF( lquery )
THEN
306 bignum = one / smlnum
307 CALL
dlabad( smlnum, bignum )
308 smlnum = sqrt( smlnum ) / eps
309 bignum = one / smlnum
313 anrm =
zlange(
'M', n, n, a, lda, dum )
315 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
318 ELSE IF( anrm.GT.bignum )
THEN
323 $ CALL
zlascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
330 CALL
zgebal(
'B', n, a, lda, ilo, ihi, rwork( ibal ), ierr )
338 CALL
zgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
339 $ lwork-iwrk+1, ierr )
347 CALL
zlacpy(
'L', n, n, a, lda, vl, ldvl )
353 CALL
zunghr( n, ilo, ihi, vl, ldvl, work( itau ), work( iwrk ),
354 $ lwork-iwrk+1, ierr )
361 CALL
zhseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vl, ldvl,
362 $ work( iwrk ), lwork-iwrk+1, info )
370 CALL
zlacpy(
'F', n, n, vl, ldvl, vr, ldvr )
373 ELSE IF( wantvr )
THEN
379 CALL
zlacpy(
'L', n, n, a, lda, vr, ldvr )
385 CALL
zunghr( n, ilo, ihi, vr, ldvr, work( itau ), work( iwrk ),
386 $ lwork-iwrk+1, ierr )
393 CALL
zhseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vr, ldvr,
394 $ work( iwrk ), lwork-iwrk+1, info )
403 CALL
zhseqr(
'E',
'N', n, ilo, ihi, a, lda, w, vr, ldvr,
404 $ work( iwrk ), lwork-iwrk+1, info )
412 IF( wantvl .OR. wantvr )
THEN
419 CALL
ztrevc( side,
'B',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
420 $ n, nout, work( iwrk ), rwork( irwork ), ierr )
429 CALL
zgebak(
'B',
'L', n, ilo, ihi, rwork( ibal ), n, vl, ldvl,
435 scl = one /
dznrm2( n, vl( 1, i ), 1 )
436 CALL
zdscal( n, scl, vl( 1, i ), 1 )
438 rwork( irwork+k-1 ) = dble( vl( k, i ) )**2 +
439 $ dimag( vl( k, i ) )**2
441 k =
idamax( n, rwork( irwork ), 1 )
442 tmp = dconjg( vl( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
443 CALL
zscal( n, tmp, vl( 1, i ), 1 )
444 vl( k, i ) = dcmplx( dble( vl( k, i ) ), zero )
454 CALL
zgebak(
'B',
'R', n, ilo, ihi, rwork( ibal ), n, vr, ldvr,
460 scl = one /
dznrm2( n, vr( 1, i ), 1 )
461 CALL
zdscal( n, scl, vr( 1, i ), 1 )
463 rwork( irwork+k-1 ) = dble( vr( k, i ) )**2 +
464 $ dimag( vr( k, i ) )**2
466 k =
idamax( n, rwork( irwork ), 1 )
467 tmp = dconjg( vr( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
468 CALL
zscal( n, tmp, vr( 1, i ), 1 )
469 vr( k, i ) = dcmplx( dble( vr( k, i ) ), zero )
477 CALL
zlascl(
'G', 0, 0, cscale, anrm, n-info, 1, w( info+1 ),
478 $ max( n-info, 1 ), ierr )
480 CALL
zlascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, w, n, ierr )