216 SUBROUTINE cggev3( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
217 $ vl, ldvl, vr, ldvr, work, lwork, rwork, info )
225 CHARACTER JOBVL, JOBVR
226 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
230 COMPLEX A( lda, * ), ALPHA( * ), B( ldb, * ),
231 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
239 parameter ( zero = 0.0e0, one = 1.0e0 )
241 parameter ( czero = ( 0.0e0, 0.0e0 ),
242 $ cone = ( 1.0e0, 0.0e0 ) )
245 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
247 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
248 $ in, iright, irows, irwrk, itau, iwrk, jc, jr,
250 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
265 EXTERNAL lsame, clange, slamch
268 INTRINSIC abs, aimag, max,
REAL, SQRT
274 abs1( x ) = abs(
REAL( X ) ) + abs( AIMAG( x ) )
280 IF( lsame( jobvl,
'N' ) )
THEN
283 ELSE IF( lsame( jobvl,
'V' ) )
THEN
291 IF( lsame( jobvr,
'N' ) )
THEN
294 ELSE IF( lsame( jobvr,
'V' ) )
THEN
306 lquery = ( lwork.EQ.-1 )
307 IF( ijobvl.LE.0 )
THEN
309 ELSE IF( ijobvr.LE.0 )
THEN
311 ELSE IF( n.LT.0 )
THEN
313 ELSE IF( lda.LT.max( 1, n ) )
THEN
315 ELSE IF( ldb.LT.max( 1, n ) )
THEN
317 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
319 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
321 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
328 CALL cgeqrf( n, n, b, ldb, work, work, -1, ierr )
329 lwkopt = max( n, n+int( work( 1 ) ) )
330 CALL cunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
332 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
334 CALL cungqr( n, n, n, vl, ldvl, work, work, -1, ierr )
335 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
338 CALL cgghd3( jobvl, jobvr, n, 1, n, a, lda, b, ldb, vl,
339 $ ldvl, vr, ldvr, work, -1, ierr )
340 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
341 CALL chgeqz(
'S', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
342 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
344 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
346 CALL cgghd3(
'N',
'N', n, 1, n, a, lda, b, ldb, vl, ldvl,
347 $ vr, ldvr, work, -1, ierr )
348 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
349 CALL chgeqz(
'E', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
350 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
352 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
354 work( 1 ) = cmplx( lwkopt )
358 CALL xerbla(
'CGGEV3 ', -info )
360 ELSE IF( lquery )
THEN
371 eps = slamch(
'E' )*slamch(
'B' )
372 smlnum = slamch(
'S' )
373 bignum = one / smlnum
374 CALL slabad( smlnum, bignum )
375 smlnum = sqrt( smlnum ) / eps
376 bignum = one / smlnum
380 anrm = clange(
'M', n, n, a, lda, rwork )
382 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
385 ELSE IF( anrm.GT.bignum )
THEN
390 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
394 bnrm = clange(
'M', n, n, b, ldb, rwork )
396 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
399 ELSE IF( bnrm.GT.bignum )
THEN
404 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
411 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
412 $ rwork( iright ), rwork( irwrk ), ierr )
416 irows = ihi + 1 - ilo
424 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
425 $ work( iwrk ), lwork+1-iwrk, ierr )
429 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
430 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
431 $ lwork+1-iwrk, ierr )
436 CALL claset(
'Full', n, n, czero, cone, vl, ldvl )
437 IF( irows.GT.1 )
THEN
438 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
439 $ vl( ilo+1, ilo ), ldvl )
441 CALL cungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
442 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
448 $
CALL claset(
'Full', n, n, czero, cone, vr, ldvr )
456 CALL cgghd3( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
457 $ ldvl, vr, ldvr, work( iwrk ), lwork+1-iwrk,
460 CALL cgghd3(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
461 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr,
462 $ work( iwrk ), lwork+1-iwrk, ierr )
474 CALL chgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
475 $ alpha, beta, vl, ldvl, vr, ldvr, work( iwrk ),
476 $ lwork+1-iwrk, rwork( irwrk ), ierr )
478 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
480 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
501 CALL ctgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
502 $ vr, ldvr, n, in, work( iwrk ), rwork( irwrk ),
512 CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
513 $ rwork( iright ), n, vl, ldvl, ierr )
517 temp = max( temp, abs1( vl( jr, jc ) ) )
523 vl( jr, jc ) = vl( jr, jc )*temp
528 CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
529 $ rwork( iright ), n, vr, ldvr, ierr )
533 temp = max( temp, abs1( vr( jr, jc ) ) )
539 vr( jr, jc ) = vr( jr, jc )*temp
550 $
CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
553 $
CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
555 work( 1 ) = cmplx( lwkopt )
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 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 cggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
CGGBAL
subroutine slabad(SMALL, LARGE)
SLABAD
subroutine cgghd3(COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
CGGHD3
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMQR
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 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 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 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