280 RECURSIVE SUBROUTINE claqz0( 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,
INTENT( INOUT ) :: a( lda, * ), b( ldb, * ), q( ldq, * ),
292 $ z( ldz, * ), alpha( * ), beta( * ), work( * )
293 REAL,
INTENT( OUT ) :: rwork( * )
297 PARAMETER ( czero = ( 0.0, 0.0 ), cone = ( 1.0, 0.0 ) )
298 REAL :: zero, one, half
299 parameter( zero = 0.0, one = 1.0, half = 0.5 )
302 REAL :: smlnum, ulp, safmin, safmax, c1, tempr, bnorm, btol
303 COMPLEX :: eshift, s1, temp
304 INTEGER :: istart, istop, iiter, maxit, istart2, k, ld, nshifts,
305 $ nblock, nw, nmin, nibble, n_undeflated, n_deflated,
306 $ ns, sweep_info, shiftpos, lworkreq, k2, istartm,
307 $ istopm, iwants, iwantq, iwantz, norm_info, aed_info,
308 $ nwr, nbr, nsr, itemp1, itemp2, rcost
309 LOGICAL :: ilschur, ilq, ilz
310 CHARACTER :: jbcmpz*3
316 LOGICAL,
EXTERNAL ::
lsame
317 INTEGER,
EXTERNAL ::
ilaenv
322 IF(
lsame( wants,
'E' ) )
THEN
325 ELSE IF(
lsame( wants,
'S' ) )
THEN
332 IF(
lsame( wantq,
'N' ) )
THEN
335 ELSE IF(
lsame( wantq,
'V' ) )
THEN
338 ELSE IF(
lsame( wantq,
'I' ) )
THEN
345 IF(
lsame( wantz,
'N' ) )
THEN
348 ELSE IF(
lsame( wantz,
'V' ) )
THEN
351 ELSE IF(
lsame( wantz,
'I' ) )
THEN
361 IF( iwants.EQ.0 )
THEN
363 ELSE IF( iwantq.EQ.0 )
THEN
365 ELSE IF( iwantz.EQ.0 )
THEN
367 ELSE IF( n.LT.0 )
THEN
369 ELSE IF( ilo.LT.1 )
THEN
371 ELSE IF( ihi.GT.n .OR. ihi.LT.ilo-1 )
THEN
373 ELSE IF( lda.LT.n )
THEN
375 ELSE IF( ldb.LT.n )
THEN
377 ELSE IF( ldq.LT.1 .OR. ( ilq .AND. ldq.LT.n ) )
THEN
379 ELSE IF( ldz.LT.1 .OR. ( ilz .AND. ldz.LT.n ) )
THEN
383 CALL xerbla(
'CLAQZ0', -info )
391 work( 1 ) = real( 1 )
398 jbcmpz( 1:1 ) = wants
399 jbcmpz( 2:2 ) = wantq
400 jbcmpz( 3:3 ) = wantz
402 nmin =
ilaenv( 12,
'CLAQZ0', jbcmpz, n, ilo, ihi, lwork )
404 nwr =
ilaenv( 13,
'CLAQZ0', jbcmpz, n, ilo, ihi, lwork )
406 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
408 nibble =
ilaenv( 14,
'CLAQZ0', jbcmpz, n, ilo, ihi, lwork )
410 nsr =
ilaenv( 15,
'CLAQZ0', jbcmpz, n, ilo, ihi, lwork )
411 nsr = min( nsr, ( n+6 ) / 9, ihi-ilo )
412 nsr = max( 2, nsr-mod( nsr, 2 ) )
414 rcost =
ilaenv( 17,
'CLAQZ0', jbcmpz, n, ilo, ihi, lwork )
415 itemp1 = int( nsr/sqrt( 1+2*nsr/( real( rcost )/100*n ) ) )
416 itemp1 = ( ( itemp1-1 )/4 )*4+4
419 IF( n .LT. nmin .OR. rec .GE. 2 )
THEN
420 CALL chgeqz( wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb,
421 $ alpha, beta, q, ldq, z, ldz, work, lwork, rwork,
431 nw = max( nwr, nmin )
432 CALL claqz2( ilschur, ilq, ilz, n, ilo, ihi, nw, a, lda, b, ldb,
433 $ q, ldq, z, ldz, n_undeflated, n_deflated, alpha,
434 $ beta, work, nw, work, nw, work, -1, rwork, rec,
436 itemp1 = int( work( 1 ) )
438 CALL claqz3( ilschur, ilq, ilz, n, ilo, ihi, nsr, nbr, alpha,
439 $ beta, a, lda, b, ldb, q, ldq, z, ldz, work, nbr,
440 $ work, nbr, work, -1, sweep_info )
441 itemp2 = int( work( 1 ) )
443 lworkreq = max( itemp1+2*nw**2, itemp2+2*nbr**2 )
444 IF ( lwork .EQ.-1 )
THEN
445 work( 1 ) = real( lworkreq )
447 ELSE IF ( lwork .LT. lworkreq )
THEN
451 CALL xerbla(
'CLAQZ0', info )
457 IF( iwantq.EQ.3 )
CALL claset(
'FULL', n, n, czero, cone, q,
459 IF( iwantz.EQ.3 )
CALL claset(
'FULL', n, n, czero, cone, z,
463 safmin =
slamch(
'SAFE MINIMUM' )
465 ulp =
slamch(
'PRECISION' )
466 smlnum = safmin*( real( n )/ulp )
468 bnorm =
clanhs(
'F', ihi-ilo+1, b( ilo, ilo ), ldb, rwork )
469 btol = max( safmin, ulp*bnorm )
473 maxit = 30*( ihi-ilo+1 )
477 IF( iiter .GE. maxit )
THEN
481 IF ( istart+1 .GE. istop )
THEN
487 IF ( abs( a( istop, istop-1 ) ) .LE. max( smlnum,
488 $ ulp*( abs( a( istop, istop ) )+abs( a( istop-1,
489 $ istop-1 ) ) ) ) )
THEN
490 a( istop, istop-1 ) = czero
496 IF ( abs( a( istart+1, istart ) ) .LE. max( smlnum,
497 $ ulp*( abs( a( istart, istart ) )+abs( a( istart+1,
498 $ istart+1 ) ) ) ) )
THEN
499 a( istart+1, istart ) = czero
505 IF ( istart+1 .GE. istop )
THEN
511 DO k = istop, istart+1, -1
512 IF ( abs( a( k, k-1 ) ) .LE. max( smlnum, ulp*( abs( a( k,
513 $ k ) )+abs( a( k-1, k-1 ) ) ) ) )
THEN
532 DO WHILE ( k.GE.istart2 )
534 IF( abs( b( k, k ) ) .LT. btol )
THEN
538 DO k2 = k, istart2+1, -1
539 CALL clartg( b( k2-1, k2 ), b( k2-1, k2-1 ), c1, s1,
542 b( k2-1, k2-1 ) = czero
544 CALL crot( k2-2-istartm+1, b( istartm, k2 ), 1,
545 $ b( istartm, k2-1 ), 1, c1, s1 )
546 CALL crot( min( k2+1, istop )-istartm+1, a( istartm,
547 $ k2 ), 1, a( istartm, k2-1 ), 1, c1, s1 )
549 CALL crot( n, z( 1, k2 ), 1, z( 1, k2-1 ), 1, c1,
553 IF( k2.LT.istop )
THEN
554 CALL clartg( a( k2, k2-1 ), a( k2+1, k2-1 ), c1,
557 a( k2+1, k2-1 ) = czero
559 CALL crot( istopm-k2+1, a( k2, k2 ), lda, a( k2+1,
560 $ k2 ), lda, c1, s1 )
561 CALL crot( istopm-k2+1, b( k2, k2 ), ldb, b( k2+1,
562 $ k2 ), ldb, c1, s1 )
564 CALL crot( n, q( 1, k2 ), 1, q( 1, k2+1 ), 1,
571 IF( istart2.LT.istop )
THEN
572 CALL clartg( a( istart2, istart2 ), a( istart2+1,
573 $ istart2 ), c1, s1, temp )
574 a( istart2, istart2 ) = temp
575 a( istart2+1, istart2 ) = czero
577 CALL crot( istopm-( istart2+1 )+1, a( istart2,
578 $ istart2+1 ), lda, a( istart2+1,
579 $ istart2+1 ), lda, c1, s1 )
580 CALL crot( istopm-( istart2+1 )+1, b( istart2,
581 $ istart2+1 ), ldb, b( istart2+1,
582 $ istart2+1 ), ldb, c1, s1 )
584 CALL crot( n, q( 1, istart2 ), 1, q( 1,
585 $ istart2+1 ), 1, c1, conjg( s1 ) )
597 IF ( istart2 .GE. istop )
THEN
608 IF ( istop-istart2+1 .LT. nmin )
THEN
612 IF ( istop-istart+1 .LT. nmin )
THEN
623 CALL claqz2( ilschur, ilq, ilz, n, istart2, istop, nw, a, lda,
624 $ b, ldb, q, ldq, z, ldz, n_undeflated, n_deflated,
625 $ alpha, beta, work, nw, work( nw**2+1 ), nw,
626 $ work( 2*nw**2+1 ), lwork-2*nw**2, rwork, rec,
629 IF ( n_deflated > 0 )
THEN
630 istop = istop-n_deflated
635 IF ( 100*n_deflated > nibble*( n_deflated+n_undeflated ) .OR.
636 $ istop-istart2+1 .LT. nmin )
THEN
644 ns = min( nshifts, istop-istart2 )
645 ns = min( ns, n_undeflated )
646 shiftpos = istop-n_undeflated+1
648 IF ( mod( ld, 6 ) .EQ. 0 )
THEN
652 IF( ( real( maxit )*safmin )*abs( a( istop,
653 $ istop-1 ) ).LT.abs( a( istop-1, istop-1 ) ) )
THEN
654 eshift = a( istop, istop-1 )/b( istop-1, istop-1 )
656 eshift = eshift+cone/( safmin*real( maxit ) )
658 alpha( shiftpos ) = cone
659 beta( shiftpos ) = eshift
666 CALL claqz3( ilschur, ilq, ilz, n, istart2, istop, ns, nblock,
667 $ alpha( shiftpos ), beta( shiftpos ), a, lda, b,
668 $ ldb, q, ldq, z, ldz, work, nblock, work( nblock**
669 $ 2+1 ), nblock, work( 2*nblock**2+1 ),
670 $ lwork-2*nblock**2, sweep_info )
680 80
CALL chgeqz( wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb,
681 $ alpha, beta, q, ldq, z, ldz, work, lwork, rwork,
subroutine xerbla(srname, info)
subroutine chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
CHGEQZ
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
real function slamch(cmach)
SLAMCH
real function clanhs(norm, n, a, lda, work)
CLANHS returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
recursive subroutine claqz0(wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, rec, info)
CLAQZ0
recursive subroutine claqz2(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)
CLAQZ2
subroutine claqz3(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)
CLAQZ3
subroutine clartg(f, g, c, s, r)
CLARTG generates a plane rotation with real cosine and complex sine.
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.
logical function lsame(ca, cb)
LSAME
subroutine crot(n, cx, incx, cy, incy, c, s)
CROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.