178 SUBROUTINE zgeev( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,
179 $ WORK, LWORK, RWORK, INFO )
187 CHARACTER JOBVL, JOBVR
188 INTEGER INFO, LDA, LDVL, LDVR, LWORK, N
191 DOUBLE PRECISION RWORK( * )
192 COMPLEX*16 A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ),
199 DOUBLE PRECISION ZERO, ONE
200 parameter( zero = 0.0d0, one = 1.0d0 )
203 LOGICAL LQUERY, SCALEA, WANTVL, WANTVR
205 INTEGER HSWORK, I, IBAL, IERR, IHI, ILO, IRWORK, ITAU,
206 $ iwrk, k, lwork_trevc, maxwrk, minwrk, nout
207 DOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, SCL, SMLNUM
212 DOUBLE PRECISION DUM( 1 )
220 INTEGER IDAMAX, ILAENV
221 DOUBLE PRECISION DLAMCH, DZNRM2, ZLANGE
222 EXTERNAL lsame, idamax, ilaenv, dlamch, dznrm2, zlange
225 INTRINSIC dble, dcmplx, conjg, aimag, max, sqrt
232 lquery = ( lwork.EQ.-1 )
233 wantvl = lsame( jobvl,
'V' )
234 wantvr = lsame( jobvr,
'V' )
235 IF( ( .NOT.wantvl ) .AND. ( .NOT.lsame( jobvl,
'N' ) ) )
THEN
237 ELSE IF( ( .NOT.wantvr ) .AND. ( .NOT.lsame( jobvr,
'N' ) ) )
THEN
239 ELSE IF( n.LT.0 )
THEN
241 ELSE IF( lda.LT.max( 1, n ) )
THEN
243 ELSE IF( ldvl.LT.1 .OR. ( wantvl .AND. ldvl.LT.n ) )
THEN
245 ELSE IF( ldvr.LT.1 .OR. ( wantvr .AND. ldvr.LT.n ) )
THEN
265 maxwrk = n + n*ilaenv( 1,
'ZGEHRD',
' ', n, 1, n, 0 )
268 maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1,
'ZUNGHR',
269 $
' ', n, 1, n, -1 ) )
270 CALL ztrevc3(
'L',
'B',
SELECT, n, a, lda,
271 $ vl, ldvl, vr, ldvr,
272 $ n, nout, work, -1, rwork, -1, ierr )
273 lwork_trevc = int( work(1) )
274 maxwrk = max( maxwrk, n + lwork_trevc )
275 CALL zhseqr(
'S',
'V', n, 1, n, a, lda, w, vl, ldvl,
277 ELSE IF( wantvr )
THEN
278 maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1,
'ZUNGHR',
279 $
' ', n, 1, n, -1 ) )
280 CALL ztrevc3(
'R',
'B',
SELECT, n, a, lda,
281 $ vl, ldvl, vr, ldvr,
282 $ n, nout, work, -1, rwork, -1, ierr )
283 lwork_trevc = int( work(1) )
284 maxwrk = max( maxwrk, n + lwork_trevc )
285 CALL zhseqr(
'S',
'V', n, 1, n, a, lda, w, vr, ldvr,
288 CALL zhseqr(
'E',
'N', n, 1, n, a, lda, w, vr, ldvr,
291 hswork = int( work(1) )
292 maxwrk = max( maxwrk, hswork, minwrk )
296 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
302 CALL xerbla(
'ZGEEV ', -info )
304 ELSE IF( lquery )
THEN
316 smlnum = dlamch(
'S' )
317 bignum = one / smlnum
318 smlnum = sqrt( smlnum ) / eps
319 bignum = one / smlnum
323 anrm = zlange(
'M', n, n, a, lda, dum )
325 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
328 ELSE IF( anrm.GT.bignum )
THEN
333 $
CALL zlascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
340 CALL zgebal(
'B', n, a, lda, ilo, ihi, rwork( ibal ), ierr )
348 CALL zgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
349 $ lwork-iwrk+1, ierr )
357 CALL zlacpy(
'L', n, n, a, lda, vl, ldvl )
363 CALL zunghr( n, ilo, ihi, vl, ldvl, work( itau ), work( iwrk ),
364 $ lwork-iwrk+1, ierr )
371 CALL zhseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vl, ldvl,
372 $ work( iwrk ), lwork-iwrk+1, info )
380 CALL zlacpy(
'F', n, n, vl, ldvl, vr, ldvr )
383 ELSE IF( wantvr )
THEN
389 CALL zlacpy(
'L', n, n, a, lda, vr, ldvr )
395 CALL zunghr( n, ilo, ihi, vr, ldvr, work( itau ), work( iwrk ),
396 $ lwork-iwrk+1, ierr )
403 CALL zhseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vr, ldvr,
404 $ work( iwrk ), lwork-iwrk+1, info )
413 CALL zhseqr(
'E',
'N', n, ilo, ihi, a, lda, w, vr, ldvr,
414 $ work( iwrk ), lwork-iwrk+1, info )
422 IF( wantvl .OR. wantvr )
THEN
429 CALL ztrevc3( side,
'B',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
430 $ n, nout, work( iwrk ), lwork-iwrk+1,
431 $ rwork( irwork ), n, ierr )
440 CALL zgebak(
'B',
'L', n, ilo, ihi, rwork( ibal ), n, vl, ldvl,
446 scl = one / dznrm2( n, vl( 1, i ), 1 )
447 CALL zdscal( n, scl, vl( 1, i ), 1 )
449 rwork( irwork+k-1 ) = dble( vl( k, i ) )**2 +
450 $ aimag( vl( k, i ) )**2
452 k = idamax( n, rwork( irwork ), 1 )
453 tmp = conjg( vl( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
454 CALL zscal( n, tmp, vl( 1, i ), 1 )
455 vl( k, i ) = dcmplx( dble( vl( k, i ) ), zero )
465 CALL zgebak(
'B',
'R', n, ilo, ihi, rwork( ibal ), n, vr, ldvr,
471 scl = one / dznrm2( n, vr( 1, i ), 1 )
472 CALL zdscal( n, scl, vr( 1, i ), 1 )
474 rwork( irwork+k-1 ) = dble( vr( k, i ) )**2 +
475 $ aimag( vr( k, i ) )**2
477 k = idamax( n, rwork( irwork ), 1 )
478 tmp = conjg( vr( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
479 CALL zscal( n, tmp, vr( 1, i ), 1 )
480 vr( k, i ) = dcmplx( dble( vr( k, i ) ), zero )
488 CALL zlascl(
'G', 0, 0, cscale, anrm, n-info, 1, w( info+1 ),
489 $ max( n-info, 1 ), ierr )
491 CALL zlascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, w, n, ierr )
subroutine xerbla(srname, info)
subroutine zgebak(job, side, n, ilo, ihi, scale, m, v, ldv, info)
ZGEBAK
subroutine zgebal(job, n, a, lda, ilo, ihi, scale, info)
ZGEBAL
subroutine zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
ZGEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine zgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
ZGEHRD
subroutine zhseqr(job, compz, n, ilo, ihi, h, ldh, w, z, ldz, work, lwork, info)
ZHSEQR
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
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.
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine ztrevc3(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, lwork, rwork, lrwork, info)
ZTREVC3
subroutine zunghr(n, ilo, ihi, a, lda, tau, work, lwork, info)
ZUNGHR