214 SUBROUTINE cggev3( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
215 $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
222 CHARACTER JOBVL, JOBVR
223 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
227 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
228 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
236 parameter( zero = 0.0e0, one = 1.0e0 )
238 parameter( czero = ( 0.0e0, 0.0e0 ),
239 $ cone = ( 1.0e0, 0.0e0 ) )
242 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
244 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
245 $ in, iright, irows, irwrk, itau, iwrk, jc, jr,
247 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
262 EXTERNAL lsame, clange, slamch
265 INTRINSIC abs, aimag, max, real, sqrt
271 abs1( x ) = abs( real( x ) ) + abs( aimag( x ) )
277 IF( lsame( jobvl,
'N' ) )
THEN
280 ELSE IF( lsame( jobvl,
'V' ) )
THEN
288 IF( lsame( jobvr,
'N' ) )
THEN
291 ELSE IF( lsame( jobvr,
'V' ) )
THEN
303 lquery = ( lwork.EQ.-1 )
304 IF( ijobvl.LE.0 )
THEN
306 ELSE IF( ijobvr.LE.0 )
THEN
308 ELSE IF( n.LT.0 )
THEN
310 ELSE IF( lda.LT.max( 1, n ) )
THEN
312 ELSE IF( ldb.LT.max( 1, n ) )
THEN
314 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
316 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
318 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
325 CALL cgeqrf( n, n, b, ldb, work, work, -1, ierr )
326 lwkopt = max( n, n+int( work( 1 ) ) )
327 CALL cunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
329 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
331 CALL cungqr( n, n, n, vl, ldvl, work, work, -1, ierr )
332 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
335 CALL cgghd3( jobvl, jobvr, n, 1, n, a, lda, b, ldb, vl,
336 $ ldvl, vr, ldvr, work, -1, ierr )
337 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
338 CALL chgeqz(
'S', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
339 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
341 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
343 CALL cgghd3(
'N',
'N', n, 1, n, a, lda, b, ldb, vl, ldvl,
344 $ vr, ldvr, work, -1, ierr )
345 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
346 CALL chgeqz(
'E', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
347 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
349 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
351 work( 1 ) = cmplx( lwkopt )
355 CALL xerbla(
'CGGEV3 ', -info )
357 ELSE IF( lquery )
THEN
368 eps = slamch(
'E' )*slamch(
'B' )
369 smlnum = slamch(
'S' )
370 bignum = one / smlnum
371 CALL slabad( smlnum, bignum )
372 smlnum = sqrt( smlnum ) / eps
373 bignum = one / smlnum
377 anrm = clange(
'M', n, n, a, lda, rwork )
379 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
382 ELSE IF( anrm.GT.bignum )
THEN
387 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
391 bnrm = clange(
'M', n, n, b, ldb, rwork )
393 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
396 ELSE IF( bnrm.GT.bignum )
THEN
401 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
408 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
409 $ rwork( iright ), rwork( irwrk ), ierr )
413 irows = ihi + 1 - ilo
421 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
422 $ work( iwrk ), lwork+1-iwrk, ierr )
426 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
427 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
428 $ lwork+1-iwrk, ierr )
433 CALL claset(
'Full', n, n, czero, cone, vl, ldvl )
434 IF( irows.GT.1 )
THEN
435 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
436 $ vl( ilo+1, ilo ), ldvl )
438 CALL cungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
439 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
445 $
CALL claset(
'Full', n, n, czero, cone, vr, ldvr )
453 CALL cgghd3( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
454 $ ldvl, vr, ldvr, work( iwrk ), lwork+1-iwrk,
457 CALL cgghd3(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
458 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr,
459 $ work( iwrk ), lwork+1-iwrk, ierr )
471 CALL chgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
472 $ alpha, beta, vl, ldvl, vr, ldvr, work( iwrk ),
473 $ lwork+1-iwrk, rwork( irwrk ), ierr )
475 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
477 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
498 CALL ctgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
499 $ vr, ldvr, n, in, work( iwrk ), rwork( irwrk ),
509 CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
510 $ rwork( iright ), n, vl, ldvl, ierr )
514 temp = max( temp, abs1( vl( jr, jc ) ) )
520 vl( jr, jc ) = vl( jr, jc )*temp
525 CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
526 $ rwork( iright ), n, vr, ldvr, ierr )
530 temp = max( temp, abs1( vr( jr, jc ) ) )
536 vr( jr, jc ) = vr( jr, jc )*temp
547 $
CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
550 $
CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
552 work( 1 ) = cmplx( lwkopt )
subroutine slabad(SMALL, LARGE)
SLABAD
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
CGGBAL
subroutine cggbak(JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V, LDV, INFO)
CGGBAK
subroutine chgeqz(JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, RWORK, INFO)
CHGEQZ
subroutine cgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGEQRF
subroutine ctgevc(SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL, LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO)
CTGEVC
subroutine cggev3(JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA, VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO)
CGGEV3 computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices (...
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
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 clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine cgghd3(COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
CGGHD3
subroutine cunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMQR
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR