215 SUBROUTINE cggev( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
216 $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
223 CHARACTER JOBVL, JOBVR
224 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
228 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
229 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
237 parameter( zero = 0.0e0, one = 1.0e0 )
239 parameter( czero = ( 0.0e0, 0.0e0 ),
240 $ cone = ( 1.0e0, 0.0e0 ) )
243 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
245 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
246 $ in, iright, irows, irwrk, itau, iwrk, jc, jr,
248 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
262 REAL CLANGE, SLAMCH, SROUNDUP_LWORK
263 EXTERNAL lsame, ilaenv, clange, slamch, sroundup_lwork
266 INTRINSIC abs, aimag, max, real, sqrt
272 abs1( x ) = abs( real( x ) ) + abs( aimag( x ) )
278 IF( lsame( jobvl,
'N' ) )
THEN
281 ELSE IF( lsame( jobvl,
'V' ) )
THEN
289 IF( lsame( jobvr,
'N' ) )
THEN
292 ELSE IF( lsame( jobvr,
'V' ) )
THEN
304 lquery = ( lwork.EQ.-1 )
305 IF( ijobvl.LE.0 )
THEN
307 ELSE IF( ijobvr.LE.0 )
THEN
309 ELSE IF( n.LT.0 )
THEN
311 ELSE IF( lda.LT.max( 1, n ) )
THEN
313 ELSE IF( ldb.LT.max( 1, n ) )
THEN
315 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
317 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
330 lwkmin = max( 1, 2*n )
331 lwkopt = max( 1, n + n*ilaenv( 1,
'CGEQRF',
' ', n, 1, n, 0 ) )
332 lwkopt = max( lwkopt, n +
333 $ n*ilaenv( 1,
'CUNMQR',
' ', n, 1, n, 0 ) )
335 lwkopt = max( lwkopt, n +
336 $ n*ilaenv( 1,
'CUNGQR',
' ', n, 1, n, -1 ) )
338 work( 1 ) = sroundup_lwork(lwkopt)
340 IF( lwork.LT.lwkmin .AND. .NOT.lquery )
345 CALL xerbla(
'CGGEV ', -info )
347 ELSE IF( lquery )
THEN
358 eps = slamch(
'E' )*slamch(
'B' )
359 smlnum = slamch(
'S' )
360 bignum = one / smlnum
361 smlnum = sqrt( smlnum ) / eps
362 bignum = one / smlnum
366 anrm = clange(
'M', n, n, a, lda, rwork )
368 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
371 ELSE IF( anrm.GT.bignum )
THEN
376 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
380 bnrm = clange(
'M', n, n, b, ldb, rwork )
382 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
385 ELSE IF( bnrm.GT.bignum )
THEN
390 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
398 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
399 $ rwork( iright ), rwork( irwrk ), ierr )
404 irows = ihi + 1 - ilo
412 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
413 $ work( iwrk ), lwork+1-iwrk, ierr )
418 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
419 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
420 $ lwork+1-iwrk, ierr )
426 CALL claset(
'Full', n, n, czero, cone, vl, ldvl )
427 IF( irows.GT.1 )
THEN
428 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
429 $ vl( ilo+1, ilo ), ldvl )
431 CALL cungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
432 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
438 $
CALL claset(
'Full', n, n, czero, cone, vr, ldvr )
446 CALL cgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
447 $ ldvl, vr, ldvr, ierr )
449 CALL cgghrd(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
450 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, ierr )
464 CALL chgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
465 $ alpha, beta, vl, ldvl, vr, ldvr, work( iwrk ),
466 $ lwork+1-iwrk, rwork( irwrk ), ierr )
468 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
470 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
493 CALL ctgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
494 $ vr, ldvr, n, in, work( iwrk ), rwork( irwrk ),
505 CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
506 $ rwork( iright ), n, vl, ldvl, ierr )
510 temp = max( temp, abs1( vl( jr, jc ) ) )
516 vl( jr, jc ) = vl( jr, jc )*temp
521 CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
522 $ rwork( iright ), n, vr, ldvr, ierr )
526 temp = max( temp, abs1( vr( jr, jc ) ) )
532 vr( jr, jc ) = vr( jr, jc )*temp
543 $
CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
546 $
CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
548 work( 1 ) = sroundup_lwork(lwkopt)
subroutine xerbla(srname, info)
subroutine cgeqrf(m, n, a, lda, tau, work, lwork, info)
CGEQRF
subroutine cggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
CGGBAK
subroutine cggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
CGGBAL
subroutine cggev(jobvl, jobvr, n, a, lda, b, ldb, alpha, beta, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
CGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine cgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
CGGHRD
subroutine chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
CHGEQZ
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 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 ctgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, rwork, info)
CTGEVC
subroutine cungqr(m, n, k, a, lda, tau, work, lwork, info)
CUNGQR
subroutine cunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMQR