213 SUBROUTINE zggev3( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA,
215 $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
222 CHARACTER JOBVL, JOBVR
223 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
226 DOUBLE PRECISION RWORK( * )
227 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
228 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
235 DOUBLE PRECISION ZERO, ONE
236 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
237 COMPLEX*16 CZERO, CONE
238 parameter( czero = ( 0.0d0, 0.0d0 ),
239 $ cone = ( 1.0d0, 0.0d0 ) )
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 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
261 DOUBLE PRECISION DLAMCH, ZLANGE
262 EXTERNAL lsame, dlamch, zlange
265 INTRINSIC abs, dble, dimag, max, sqrt
268 DOUBLE PRECISION ABS1
271 abs1( x ) = abs( dble( x ) ) + abs( dimag( 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 lwkmin = max( 1, 2*n )
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
319 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery )
THEN
326 CALL zgeqrf( n, n, b, ldb, work, work, -1, ierr )
327 lwkopt = max( lwkmin, n+int( work( 1 ) ) )
328 CALL zunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
330 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
332 CALL zungqr( n, n, n, vl, ldvl, work, work, -1, ierr )
333 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
336 CALL zgghd3( jobvl, jobvr, n, 1, n, a, lda, b, ldb, vl,
337 $ ldvl, vr, ldvr, work, -1, ierr )
338 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
339 CALL zlaqz0(
'S', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
340 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
342 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
344 CALL zgghd3( jobvl, jobvr, n, 1, n, a, lda, b, ldb, vl,
345 $ ldvl, vr, ldvr, work, -1, ierr )
346 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
347 CALL zlaqz0(
'E', jobvl, jobvr, n, 1, n, a, lda, b, ldb,
348 $ alpha, beta, vl, ldvl, vr, ldvr, work, -1,
350 lwkopt = max( lwkopt, n+int( work( 1 ) ) )
355 work( 1 ) = dcmplx( lwkopt )
360 CALL xerbla(
'ZGGEV3 ', -info )
362 ELSE IF( lquery )
THEN
373 eps = dlamch(
'E' )*dlamch(
'B' )
374 smlnum = dlamch(
'S' )
375 bignum = one / smlnum
376 smlnum = sqrt( smlnum ) / eps
377 bignum = one / smlnum
381 anrm = zlange(
'M', n, n, a, lda, rwork )
383 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
386 ELSE IF( anrm.GT.bignum )
THEN
391 $
CALL zlascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
395 bnrm = zlange(
'M', n, n, b, ldb, rwork )
397 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
400 ELSE IF( bnrm.GT.bignum )
THEN
405 $
CALL zlascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
412 CALL zggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
413 $ rwork( iright ), rwork( irwrk ), ierr )
417 irows = ihi + 1 - ilo
425 CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
426 $ work( iwrk ), lwork+1-iwrk, ierr )
430 CALL zunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
431 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
432 $ lwork+1-iwrk, ierr )
437 CALL zlaset(
'Full', n, n, czero, cone, vl, ldvl )
438 IF( irows.GT.1 )
THEN
439 CALL zlacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
440 $ vl( ilo+1, ilo ), ldvl )
442 CALL zungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
443 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
449 $
CALL zlaset(
'Full', n, n, czero, cone, vr, ldvr )
457 CALL zgghd3( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
458 $ ldvl, vr, ldvr, work( iwrk ), lwork+1-iwrk, ierr )
460 CALL zgghd3(
'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 zlaqz0( 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 ), 0, 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 ztgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl,
503 $ vr, ldvr, n, in, work( iwrk ), rwork( irwrk ),
513 CALL zggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
514 $ rwork( iright ), n, vl, ldvl, ierr )
518 temp = max( temp, abs1( vl( jr, jc ) ) )
524 vl( jr, jc ) = vl( jr, jc )*temp
529 CALL zggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
530 $ rwork( iright ), n, vr, ldvr, ierr )
534 temp = max( temp, abs1( vr( jr, jc ) ) )
540 vr( jr, jc ) = vr( jr, jc )*temp
551 $
CALL zlascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
554 $
CALL zlascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
556 work( 1 ) = dcmplx( lwkopt )