179 SUBROUTINE cgeev( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,
180 $ work, lwork, rwork, info )
189 CHARACTER JOBVL, JOBVR
190 INTEGER INFO, LDA, LDVL, LDVR, LWORK, N
194 COMPLEX A( lda, * ), VL( ldvl, * ), VR( ldvr, * ),
202 parameter ( zero = 0.0e0, one = 1.0e0 )
205 LOGICAL LQUERY, SCALEA, WANTVL, WANTVR
207 INTEGER HSWORK, I, IBAL, IERR, IHI, ILO, IRWORK, ITAU,
208 $ iwrk, k, lwork_trevc, maxwrk, minwrk, nout
209 REAL ANRM, BIGNUM, CSCALE, EPS, SCL, SMLNUM
222 INTEGER ISAMAX, ILAENV
223 REAL SLAMCH, SCNRM2, CLANGE
224 EXTERNAL lsame, isamax, ilaenv, slamch, scnrm2, clange
227 INTRINSIC REAL, CMPLX, CONJG, AIMAG, MAX, SQRT
234 lquery = ( lwork.EQ.-1 )
235 wantvl = lsame( jobvl,
'V' )
236 wantvr = lsame( jobvr,
'V' )
237 IF( ( .NOT.wantvl ) .AND. ( .NOT.lsame( jobvl,
'N' ) ) )
THEN
239 ELSE IF( ( .NOT.wantvr ) .AND. ( .NOT.lsame( jobvr,
'N' ) ) )
THEN
241 ELSE IF( n.LT.0 )
THEN
243 ELSE IF( lda.LT.max( 1, n ) )
THEN
245 ELSE IF( ldvl.LT.1 .OR. ( wantvl .AND. ldvl.LT.n ) )
THEN
247 ELSE IF( ldvr.LT.1 .OR. ( wantvr .AND. ldvr.LT.n ) )
THEN
267 maxwrk = n + n*ilaenv( 1,
'CGEHRD',
' ', n, 1, n, 0 )
270 maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1,
'CUNGHR',
271 $
' ', n, 1, n, -1 ) )
272 CALL ctrevc3(
'L',
'B',
SELECT, n, a, lda,
273 $ vl, ldvl, vr, ldvr,
274 $ n, nout, work, -1, rwork, -1, ierr )
275 lwork_trevc = int( work(1) )
276 maxwrk = max( maxwrk, n + lwork_trevc )
277 CALL chseqr(
'S',
'V', n, 1, n, a, lda, w, vl, ldvl,
279 ELSE IF( wantvr )
THEN
280 maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1,
'CUNGHR',
281 $
' ', n, 1, n, -1 ) )
282 CALL ctrevc3(
'R',
'B',
SELECT, n, a, lda,
283 $ vl, ldvl, vr, ldvr,
284 $ n, nout, work, -1, rwork, -1, ierr )
285 lwork_trevc = int( work(1) )
286 maxwrk = max( maxwrk, n + lwork_trevc )
287 CALL chseqr(
'S',
'V', n, 1, n, a, lda, w, vr, ldvr,
290 CALL chseqr(
'E',
'N', n, 1, n, a, lda, w, vr, ldvr,
293 hswork = int( work(1) )
294 maxwrk = max( maxwrk, hswork, minwrk )
298 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
304 CALL xerbla(
'CGEEV ', -info )
306 ELSE IF( lquery )
THEN
318 smlnum = slamch(
'S' )
319 bignum = one / smlnum
320 CALL slabad( smlnum, bignum )
321 smlnum = sqrt( smlnum ) / eps
322 bignum = one / smlnum
326 anrm = clange(
'M', n, n, a, lda, dum )
328 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
331 ELSE IF( anrm.GT.bignum )
THEN
336 $
CALL clascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
343 CALL cgebal(
'B', n, a, lda, ilo, ihi, rwork( ibal ), ierr )
351 CALL cgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
352 $ lwork-iwrk+1, ierr )
360 CALL clacpy(
'L', n, n, a, lda, vl, ldvl )
366 CALL cunghr( n, ilo, ihi, vl, ldvl, work( itau ), work( iwrk ),
367 $ lwork-iwrk+1, ierr )
374 CALL chseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vl, ldvl,
375 $ work( iwrk ), lwork-iwrk+1, info )
383 CALL clacpy(
'F', n, n, vl, ldvl, vr, ldvr )
386 ELSE IF( wantvr )
THEN
392 CALL clacpy(
'L', n, n, a, lda, vr, ldvr )
398 CALL cunghr( n, ilo, ihi, vr, ldvr, work( itau ), work( iwrk ),
399 $ lwork-iwrk+1, ierr )
406 CALL chseqr(
'S',
'V', n, ilo, ihi, a, lda, w, vr, ldvr,
407 $ work( iwrk ), lwork-iwrk+1, info )
416 CALL chseqr(
'E',
'N', n, ilo, ihi, a, lda, w, vr, ldvr,
417 $ work( iwrk ), lwork-iwrk+1, info )
425 IF( wantvl .OR. wantvr )
THEN
432 CALL ctrevc3( side,
'B',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
433 $ n, nout, work( iwrk ), lwork-iwrk+1,
434 $ rwork( irwork ), n, ierr )
443 CALL cgebak(
'B',
'L', n, ilo, ihi, rwork( ibal ), n, vl, ldvl,
449 scl = one / scnrm2( n, vl( 1, i ), 1 )
450 CALL csscal( n, scl, vl( 1, i ), 1 )
452 rwork( irwork+k-1 ) =
REAL( VL( K, I ) )**2 +
453 $ aimag( vl( k, i ) )**2
455 k = isamax( n, rwork( irwork ), 1 )
456 tmp = conjg( vl( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
457 CALL cscal( n, tmp, vl( 1, i ), 1 )
458 vl( k, i ) = cmplx(
REAL( VL( K, I ) ), ZERO )
468 CALL cgebak(
'B',
'R', n, ilo, ihi, rwork( ibal ), n, vr, ldvr,
474 scl = one / scnrm2( n, vr( 1, i ), 1 )
475 CALL csscal( n, scl, vr( 1, i ), 1 )
477 rwork( irwork+k-1 ) =
REAL( VR( K, I ) )**2 +
478 $ aimag( vr( k, i ) )**2
480 k = isamax( n, rwork( irwork ), 1 )
481 tmp = conjg( vr( k, i ) ) / sqrt( rwork( irwork+k-1 ) )
482 CALL cscal( n, tmp, vr( 1, i ), 1 )
483 vr( k, i ) = cmplx(
REAL( VR( K, I ) ), ZERO )
491 CALL clascl(
'G', 0, 0, cscale, anrm, n-info, 1, w( info+1 ),
492 $ max( n-info, 1 ), ierr )
494 CALL clascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, w, n, ierr )
subroutine cgeev(JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO)
CGEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices ...
subroutine cunghr(N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
CUNGHR
subroutine cgebak(JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, INFO)
CGEBAK
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 slabad(SMALL, LARGE)
SLABAD
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cscal(N, CA, CX, INCX)
CSCAL
subroutine chseqr(JOB, COMPZ, N, ILO, IHI, H, LDH, W, Z, LDZ, WORK, LWORK, INFO)
CHSEQR
subroutine ctrevc3(SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR, LDVR, MM, M, WORK, LWORK, RWORK, LRWORK, INFO)
CTREVC3
subroutine cgebal(JOB, N, A, LDA, ILO, IHI, SCALE, INFO)
CGEBAL
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine cgehrd(N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
CGEHRD
subroutine csscal(N, SA, CX, INCX)
CSSCAL