280 RECURSIVE SUBROUTINE zlaqz0( WANTS, WANTQ, WANTZ, N, ILO, IHI, A,
281 $ LDA, B, LDB, ALPHA, BETA, Q, LDQ, Z,
282 $ LDZ, WORK, LWORK, RWORK, REC,
287 CHARACTER,
INTENT( IN ) :: wants, wantq, wantz
288 INTEGER,
INTENT( IN ) :: n, ilo, ihi, lda, ldb, ldq, ldz, lwork,
290 INTEGER,
INTENT( OUT ) :: info
291 COMPLEX*16,
INTENT( INOUT ) :: a( lda, * ), b( ldb, * ), q( ldq,
292 $ * ), z( ldz, * ), alpha( * ), beta( * ), work( * )
293 DOUBLE PRECISION,
INTENT( OUT ) :: rwork( * )
296 COMPLEX*16 czero, cone
297 PARAMETER ( czero = ( 0.0d+0, 0.0d+0 ), cone = ( 1.0d+0,
299 DOUBLE PRECISION :: zero, one, half
300 parameter( zero = 0.0d0, one = 1.0d0, half = 0.5d0 )
303 DOUBLE PRECISION :: smlnum, ulp, safmin, safmax, c1, tempr,
305 COMPLEX*16 :: eshift, s1, temp
306 INTEGER :: istart, istop, iiter, maxit, istart2, k, ld, nshifts,
307 $ nblock, nw, nmin, nibble, n_undeflated, n_deflated,
308 $ ns, sweep_info, shiftpos, lworkreq, k2, istartm,
309 $ istopm, iwants, iwantq, iwantz, norm_info, aed_info,
310 $ nwr, nbr, nsr, itemp1, itemp2, rcost
311 LOGICAL :: ilschur, ilq, ilz
312 CHARACTER :: jbcmpz*3
318 LOGICAL,
EXTERNAL ::
lsame
319 INTEGER,
EXTERNAL ::
ilaenv
324 IF(
lsame( wants,
'E' ) )
THEN
327 ELSE IF(
lsame( wants,
'S' ) )
THEN
334 IF(
lsame( wantq,
'N' ) )
THEN
337 ELSE IF(
lsame( wantq,
'V' ) )
THEN
340 ELSE IF(
lsame( wantq,
'I' ) )
THEN
347 IF(
lsame( wantz,
'N' ) )
THEN
350 ELSE IF(
lsame( wantz,
'V' ) )
THEN
353 ELSE IF(
lsame( wantz,
'I' ) )
THEN
363 IF( iwants.EQ.0 )
THEN
365 ELSE IF( iwantq.EQ.0 )
THEN
367 ELSE IF( iwantz.EQ.0 )
THEN
369 ELSE IF( n.LT.0 )
THEN
371 ELSE IF( ilo.LT.1 )
THEN
373 ELSE IF( ihi.GT.n .OR. ihi.LT.ilo-1 )
THEN
375 ELSE IF( lda.LT.n )
THEN
377 ELSE IF( ldb.LT.n )
THEN
379 ELSE IF( ldq.LT.1 .OR. ( ilq .AND. ldq.LT.n ) )
THEN
381 ELSE IF( ldz.LT.1 .OR. ( ilz .AND. ldz.LT.n ) )
THEN
385 CALL xerbla(
'ZLAQZ0', -info )
393 work( 1 ) = dble( 1 )
400 jbcmpz( 1:1 ) = wants
401 jbcmpz( 2:2 ) = wantq
402 jbcmpz( 3:3 ) = wantz
404 nmin =
ilaenv( 12,
'ZLAQZ0', jbcmpz, n, ilo, ihi, lwork )
406 nwr =
ilaenv( 13,
'ZLAQZ0', jbcmpz, n, ilo, ihi, lwork )
408 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
410 nibble =
ilaenv( 14,
'ZLAQZ0', jbcmpz, n, ilo, ihi, lwork )
412 nsr =
ilaenv( 15,
'ZLAQZ0', jbcmpz, n, ilo, ihi, lwork )
413 nsr = min( nsr, ( n+6 ) / 9, ihi-ilo )
414 nsr = max( 2, nsr-mod( nsr, 2 ) )
416 rcost =
ilaenv( 17,
'ZLAQZ0', jbcmpz, n, ilo, ihi, lwork )
417 itemp1 = int( nsr/sqrt( 1+2*nsr/( dble( rcost )/100*n ) ) )
418 itemp1 = ( ( itemp1-1 )/4 )*4+4
421 IF( n .LT. nmin .OR. rec .GE. 2 )
THEN
422 CALL zhgeqz( wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb,
423 $ alpha, beta, q, ldq, z, ldz, work, lwork, rwork,
433 nw = max( nwr, nmin )
434 CALL zlaqz2( ilschur, ilq, ilz, n, ilo, ihi, nw, a, lda, b, ldb,
435 $ q, ldq, z, ldz, n_undeflated, n_deflated, alpha,
436 $ beta, work, nw, work, nw, work, -1, rwork, rec,
438 itemp1 = int( work( 1 ) )
440 CALL zlaqz3( ilschur, ilq, ilz, n, ilo, ihi, nsr, nbr, alpha,
441 $ beta, a, lda, b, ldb, q, ldq, z, ldz, work, nbr,
442 $ work, nbr, work, -1, sweep_info )
443 itemp2 = int( work( 1 ) )
445 lworkreq = max( itemp1+2*nw**2, itemp2+2*nbr**2 )
446 IF ( lwork .EQ.-1 )
THEN
447 work( 1 ) = dble( lworkreq )
449 ELSE IF ( lwork .LT. lworkreq )
THEN
453 CALL xerbla(
'ZLAQZ0', info )
459 IF( iwantq.EQ.3 )
CALL zlaset(
'FULL', n, n, czero, cone, q,
461 IF( iwantz.EQ.3 )
CALL zlaset(
'FULL', n, n, czero, cone, z,
465 safmin =
dlamch(
'SAFE MINIMUM' )
467 ulp =
dlamch(
'PRECISION' )
468 smlnum = safmin*( dble( n )/ulp )
470 bnorm =
zlanhs(
'F', ihi-ilo+1, b( ilo, ilo ), ldb, rwork )
471 btol = max( safmin, ulp*bnorm )
475 maxit = 30*( ihi-ilo+1 )
479 IF( iiter .GE. maxit )
THEN
483 IF ( istart+1 .GE. istop )
THEN
489 IF ( abs( a( istop, istop-1 ) ) .LE. max( smlnum,
490 $ ulp*( abs( a( istop, istop ) )+abs( a( istop-1,
491 $ istop-1 ) ) ) ) )
THEN
492 a( istop, istop-1 ) = czero
498 IF ( abs( a( istart+1, istart ) ) .LE. max( smlnum,
499 $ ulp*( abs( a( istart, istart ) )+abs( a( istart+1,
500 $ istart+1 ) ) ) ) )
THEN
501 a( istart+1, istart ) = czero
507 IF ( istart+1 .GE. istop )
THEN
513 DO k = istop, istart+1, -1
514 IF ( abs( a( k, k-1 ) ) .LE. max( smlnum, ulp*( abs( a( k,
515 $ k ) )+abs( a( k-1, k-1 ) ) ) ) )
THEN
534 DO WHILE ( k.GE.istart2 )
536 IF( abs( b( k, k ) ) .LT. btol )
THEN
540 DO k2 = k, istart2+1, -1
541 CALL zlartg( b( k2-1, k2 ), b( k2-1, k2-1 ), c1, s1,
544 b( k2-1, k2-1 ) = czero
546 CALL zrot( k2-2-istartm+1, b( istartm, k2 ), 1,
547 $ b( istartm, k2-1 ), 1, c1, s1 )
548 CALL zrot( min( k2+1, istop )-istartm+1, a( istartm,
549 $ k2 ), 1, a( istartm, k2-1 ), 1, c1, s1 )
551 CALL zrot( n, z( 1, k2 ), 1, z( 1, k2-1 ), 1, c1,
555 IF( k2.LT.istop )
THEN
556 CALL zlartg( a( k2, k2-1 ), a( k2+1, k2-1 ), c1,
559 a( k2+1, k2-1 ) = czero
561 CALL zrot( istopm-k2+1, a( k2, k2 ), lda, a( k2+1,
562 $ k2 ), lda, c1, s1 )
563 CALL zrot( istopm-k2+1, b( k2, k2 ), ldb, b( k2+1,
564 $ k2 ), ldb, c1, s1 )
566 CALL zrot( n, q( 1, k2 ), 1, q( 1, k2+1 ), 1,
573 IF( istart2.LT.istop )
THEN
574 CALL zlartg( a( istart2, istart2 ), a( istart2+1,
575 $ istart2 ), c1, s1, temp )
576 a( istart2, istart2 ) = temp
577 a( istart2+1, istart2 ) = czero
579 CALL zrot( istopm-( istart2+1 )+1, a( istart2,
580 $ istart2+1 ), lda, a( istart2+1,
581 $ istart2+1 ), lda, c1, s1 )
582 CALL zrot( istopm-( istart2+1 )+1, b( istart2,
583 $ istart2+1 ), ldb, b( istart2+1,
584 $ istart2+1 ), ldb, c1, s1 )
586 CALL zrot( n, q( 1, istart2 ), 1, q( 1,
587 $ istart2+1 ), 1, c1, dconjg( s1 ) )
599 IF ( istart2 .GE. istop )
THEN
610 IF ( istop-istart2+1 .LT. nmin )
THEN
614 IF ( istop-istart+1 .LT. nmin )
THEN
625 CALL zlaqz2( ilschur, ilq, ilz, n, istart2, istop, nw, a, lda,
626 $ b, ldb, q, ldq, z, ldz, n_undeflated, n_deflated,
627 $ alpha, beta, work, nw, work( nw**2+1 ), nw,
628 $ work( 2*nw**2+1 ), lwork-2*nw**2, rwork, rec,
631 IF ( n_deflated > 0 )
THEN
632 istop = istop-n_deflated
637 IF ( 100*n_deflated > nibble*( n_deflated+n_undeflated ) .OR.
638 $ istop-istart2+1 .LT. nmin )
THEN
646 ns = min( nshifts, istop-istart2 )
647 ns = min( ns, n_undeflated )
648 shiftpos = istop-n_undeflated+1
650 IF ( mod( ld, 6 ) .EQ. 0 )
THEN
654 IF( ( dble( maxit )*safmin )*abs( a( istop,
655 $ istop-1 ) ).LT.abs( a( istop-1, istop-1 ) ) )
THEN
656 eshift = a( istop, istop-1 )/b( istop-1, istop-1 )
658 eshift = eshift+cone/( safmin*dble( maxit ) )
660 alpha( shiftpos ) = cone
661 beta( shiftpos ) = eshift
668 CALL zlaqz3( ilschur, ilq, ilz, n, istart2, istop, ns, nblock,
669 $ alpha( shiftpos ), beta( shiftpos ), a, lda, b,
670 $ ldb, q, ldq, z, ldz, work, nblock, work( nblock**
671 $ 2+1 ), nblock, work( 2*nblock**2+1 ),
672 $ lwork-2*nblock**2, sweep_info )
682 80
CALL zhgeqz( wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb,
683 $ alpha, beta, q, ldq, z, ldz, work, lwork, rwork,
subroutine xerbla(srname, info)
subroutine zhgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
ZHGEQZ
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
double precision function dlamch(cmach)
DLAMCH
double precision function zlanhs(norm, n, a, lda, work)
ZLANHS returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
recursive subroutine zlaqz0(wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, rec, info)
ZLAQZ0
recursive subroutine zlaqz2(ilschur, ilq, ilz, n, ilo, ihi, nw, a, lda, b, ldb, q, ldq, z, ldz, ns, nd, alpha, beta, qc, ldqc, zc, ldzc, work, lwork, rwork, rec, info)
ZLAQZ2
subroutine zlaqz3(ilschur, ilq, ilz, n, ilo, ihi, nshifts, nblock_desired, alpha, beta, a, lda, b, ldb, q, ldq, z, ldz, qc, ldqc, zc, ldzc, work, lwork, info)
ZLAQZ3
subroutine zlartg(f, g, c, s, r)
ZLARTG generates a plane rotation with real cosine and complex sine.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
logical function lsame(ca, cb)
LSAME
subroutine zrot(n, cx, incx, cy, incy, c, s)
ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.