285 SUBROUTINE cgeevx( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, W, VL,
286 $ LDVL, VR, LDVR, ILO, IHI, SCALE, ABNRM, RCONDE,
287 $ RCONDV, WORK, LWORK, RWORK, INFO )
295 CHARACTER BALANC, JOBVL, JOBVR, SENSE
296 INTEGER IHI, ILO, INFO, LDA, LDVL, LDVR, LWORK, N
300 REAL RCONDE( * ), RCONDV( * ), RWORK( * ),
302 COMPLEX A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ),
310 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
313 LOGICAL LQUERY, SCALEA, WANTVL, WANTVR, WNTSNB, WNTSNE,
316 INTEGER HSWORK, I, ICOND, IERR, ITAU, IWRK, K,
317 $ lwork_trevc, maxwrk, minwrk, nout
318 REAL ANRM, BIGNUM, CSCALE, EPS, SCL, SMLNUM
332 INTEGER ISAMAX, ILAENV
333 REAL SLAMCH, SCNRM2, CLANGE, SROUNDUP_LWORK
334 EXTERNAL lsame, isamax, ilaenv, slamch, scnrm2, clange,
338 INTRINSIC real, cmplx, conjg, aimag, max, sqrt
345 lquery = ( lwork.EQ.-1 )
346 wantvl = lsame( jobvl,
'V' )
347 wantvr = lsame( jobvr,
'V' )
348 wntsnn = lsame( sense,
'N' )
349 wntsne = lsame( sense,
'E' )
350 wntsnv = lsame( sense,
'V' )
351 wntsnb = lsame( sense,
'B' )
352 IF( .NOT.( lsame( balanc,
'N' ) .OR. lsame( balanc,
'S' ) .OR.
353 $ lsame( balanc,
'P' ) .OR. lsame( balanc,
'B' ) ) )
THEN
355 ELSE IF( ( .NOT.wantvl ) .AND. ( .NOT.lsame( jobvl,
'N' ) ) )
THEN
357 ELSE IF( ( .NOT.wantvr ) .AND. ( .NOT.lsame( jobvr,
'N' ) ) )
THEN
359 ELSE IF( .NOT.( wntsnn .OR. wntsne .OR. wntsnb .OR. wntsnv ) .OR.
360 $ ( ( wntsne .OR. wntsnb ) .AND. .NOT.( wantvl .AND.
363 ELSE IF( n.LT.0 )
THEN
365 ELSE IF( lda.LT.max( 1, n ) )
THEN
367 ELSE IF( ldvl.LT.1 .OR. ( wantvl .AND. ldvl.LT.n ) )
THEN
369 ELSE IF( ldvr.LT.1 .OR. ( wantvr .AND. ldvr.LT.n ) )
THEN
389 maxwrk = n + n*ilaenv( 1,
'CGEHRD',
' ', n, 1, n, 0 )
392 CALL ctrevc3(
'L',
'B',
SELECT, n, a, lda,
393 $ vl, ldvl, vr, ldvr,
394 $ n, nout, work, -1, rwork, -1, ierr )
395 lwork_trevc = int( work(1) )
396 maxwrk = max( maxwrk, lwork_trevc )
397 CALL chseqr(
'S',
'V', n, 1, n, a, lda, w, vl, ldvl,
399 ELSE IF( wantvr )
THEN
400 CALL ctrevc3(
'R',
'B',
SELECT, n, a, lda,
401 $ vl, ldvl, vr, ldvr,
402 $ n, nout, work, -1, rwork, -1, ierr )
403 lwork_trevc = int( work(1) )
404 maxwrk = max( maxwrk, lwork_trevc )
405 CALL chseqr(
'S',
'V', n, 1, n, a, lda, w, vr, ldvr,
409 CALL chseqr(
'E',
'N', n, 1, n, a, lda, w, vr, ldvr,
412 CALL chseqr(
'S',
'N', n, 1, n, a, lda, w, vr, ldvr,
416 hswork = int( work(1) )
418 IF( ( .NOT.wantvl ) .AND. ( .NOT.wantvr ) )
THEN
420 IF( .NOT.( wntsnn .OR. wntsne ) )
421 $ minwrk = max( minwrk, n*n + 2*n )
422 maxwrk = max( maxwrk, hswork )
423 IF( .NOT.( wntsnn .OR. wntsne ) )
424 $ maxwrk = max( maxwrk, n*n + 2*n )
427 IF( .NOT.( wntsnn .OR. wntsne ) )
428 $ minwrk = max( minwrk, n*n + 2*n )
429 maxwrk = max( maxwrk, hswork )
430 maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1,
'CUNGHR',
431 $
' ', n, 1, n, -1 ) )
432 IF( .NOT.( wntsnn .OR. wntsne ) )
433 $ maxwrk = max( maxwrk, n*n + 2*n )
434 maxwrk = max( maxwrk, 2*n )
436 maxwrk = max( maxwrk, minwrk )
438 work( 1 ) = sroundup_lwork(maxwrk)
440 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
446 CALL xerbla(
'CGEEVX', -info )
448 ELSE IF( lquery )
THEN
460 smlnum = slamch(
'S' )
461 bignum = one / smlnum
462 smlnum = sqrt( smlnum ) / eps
463 bignum = one / smlnum
468 anrm = clange(
'M', n, n, a, lda, dum )
470 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
473 ELSE IF( anrm.GT.bignum )
THEN
478 $
CALL clascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
482 CALL cgebal( balanc, n, a, lda, ilo, ihi, scale, ierr )
483 abnrm = clange(
'1', n, n, a, lda, dum )
486 CALL slascl(
'G', 0, 0, cscale, anrm, 1, 1, dum, 1, ierr )
496 CALL cgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
497 $ lwork-iwrk+1, ierr )
505 CALL clacpy(
'L', n, n, a, lda, vl, ldvl )
511 CALL cunghr( n, ilo, ihi, vl, ldvl, work( itau ), work( iwrk ),
512 $ lwork-iwrk+1, ierr )
519 CALL chseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vl, ldvl,
520 $ work( iwrk ), lwork-iwrk+1, info )
528 CALL clacpy(
'F', n, n, vl, ldvl, vr, ldvr )
531 ELSE IF( wantvr )
THEN
537 CALL clacpy(
'L', n, n, a, lda, vr, ldvr )
543 CALL cunghr( n, ilo, ihi, vr, ldvr, work( itau ), work( iwrk ),
544 $ lwork-iwrk+1, ierr )
551 CALL chseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vr, ldvr,
552 $ work( iwrk ), lwork-iwrk+1, info )
569 CALL chseqr( job,
'N', n, ilo, ihi, a, lda, w, vr, ldvr,
570 $ work( iwrk ), lwork-iwrk+1, info )
578 IF( wantvl .OR. wantvr )
THEN
584 CALL ctrevc3( side,
'B',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
585 $ n, nout, work( iwrk ), lwork-iwrk+1,
593 IF( .NOT.wntsnn )
THEN
594 CALL ctrsna( sense,
'A',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
595 $ rconde, rcondv, n, nout, work( iwrk ), n, rwork,
603 CALL cgebak( balanc,
'L', n, ilo, ihi, scale, n, vl, ldvl,
609 scl = one / scnrm2( n, vl( 1, i ), 1 )
610 CALL csscal( n, scl, vl( 1, i ), 1 )
612 rwork( k ) = real( vl( k, i ) )**2 +
613 $ aimag( vl( k, i ) )**2
615 k = isamax( n, rwork, 1 )
616 tmp = conjg( vl( k, i ) ) / sqrt( rwork( k ) )
617 CALL cscal( n, tmp, vl( 1, i ), 1 )
618 vl( k, i ) = cmplx( real( vl( k, i ) ), zero )
626 CALL cgebak( balanc,
'R', n, ilo, ihi, scale, n, vr, ldvr,
632 scl = one / scnrm2( n, vr( 1, i ), 1 )
633 CALL csscal( n, scl, vr( 1, i ), 1 )
635 rwork( k ) = real( vr( k, i ) )**2 +
636 $ aimag( vr( k, i ) )**2
638 k = isamax( n, rwork, 1 )
639 tmp = conjg( vr( k, i ) ) / sqrt( rwork( k ) )
640 CALL cscal( n, tmp, vr( 1, i ), 1 )
641 vr( k, i ) = cmplx( real( vr( k, i ) ), zero )
649 CALL clascl(
'G', 0, 0, cscale, anrm, n-info, 1, w( info+1 ),
650 $ max( n-info, 1 ), ierr )
652 IF( ( wntsnv .OR. wntsnb ) .AND. icond.EQ.0 )
653 $
CALL slascl(
'G', 0, 0, cscale, anrm, n, 1, rcondv, n,
656 CALL clascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, w, n, ierr )
660 work( 1 ) = sroundup_lwork(maxwrk)
subroutine xerbla(srname, info)
subroutine cgebak(job, side, n, ilo, ihi, scale, m, v, ldv, info)
CGEBAK
subroutine cgebal(job, n, a, lda, ilo, ihi, scale, info)
CGEBAL
subroutine cgeevx(balanc, jobvl, jobvr, sense, n, a, lda, w, vl, ldvl, vr, ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, lwork, rwork, info)
CGEEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine cgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
CGEHRD
subroutine chseqr(job, compz, n, ilo, ihi, h, ldh, w, z, ldz, work, lwork, info)
CHSEQR
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine csscal(n, sa, cx, incx)
CSSCAL
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine ctrevc3(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, lwork, rwork, lrwork, info)
CTREVC3
subroutine ctrsna(job, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, s, sep, mm, m, work, ldwork, rwork, info)
CTRSNA
subroutine cunghr(n, ilo, ihi, a, lda, tau, work, lwork, info)
CUNGHR