246 SUBROUTINE claqr4( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
247 $ IHIZ, Z, LDZ, WORK, LWORK, INFO )
254 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
258 COMPLEX H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )
270 parameter( ntiny = 15 )
276 parameter( kexnw = 5 )
282 parameter( kexsh = 6 )
287 parameter( wilk1 = 0.75e0 )
289 parameter( zero = ( 0.0e0, 0.0e0 ),
290 $ one = ( 1.0e0, 0.0e0 ) )
292 parameter( two = 2.0e0 )
295 COMPLEX AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2
297 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
298 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
299 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
300 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
315 INTRINSIC abs, aimag, cmplx, int, max, min, mod, real,
322 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
334 IF( n.LE.ntiny )
THEN
340 $
CALL clahqr( wantt, wantz, n, ilo, ihi, h, ldh, w, iloz,
341 $ ihiz, z, ldz, info )
370 nwr = ilaenv( 13,
'CLAQR4', jbcmpz, n, ilo, ihi, lwork )
372 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
379 nsr = ilaenv( 15,
'CLAQR4', jbcmpz, n, ilo, ihi, lwork )
380 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
381 nsr = max( 2, nsr-mod( nsr, 2 ) )
387 CALL claqr2( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
388 $ ihiz, z, ldz, ls, ld, w, h, ldh, n, h, ldh, n, h,
393 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
397 IF( lwork.EQ.-1 )
THEN
398 work( 1 ) = cmplx( lwkopt, 0 )
404 nmin = ilaenv( 12,
'CLAQR4', jbcmpz, n, ilo, ihi, lwork )
405 nmin = max( ntiny, nmin )
409 nibble = ilaenv( 14,
'CLAQR4', jbcmpz, n, ilo, ihi, lwork )
410 nibble = max( 0, nibble )
415 kacc22 = ilaenv( 16,
'CLAQR4', jbcmpz, n, ilo, ihi, lwork )
416 kacc22 = max( 0, kacc22 )
417 kacc22 = min( 2, kacc22 )
422 nwmax = min( ( n-1 ) / 3, lwork / 2 )
428 nsmax = min( ( n-3 ) / 6, 2*lwork / 3 )
429 nsmax = nsmax - mod( nsmax, 2 )
437 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
454 DO 10 k = kbot, ilo + 1, -1
455 IF( h( k, k-1 ).EQ.zero )
479 nwupbd = min( nh, nwmax )
480 IF( ndfl.LT.kexnw )
THEN
481 nw = min( nwupbd, nwr )
483 nw = min( nwupbd, 2*nw )
485 IF( nw.LT.nwmax )
THEN
486 IF( nw.GE.nh-1 )
THEN
489 kwtop = kbot - nw + 1
490 IF( cabs1( h( kwtop, kwtop-1 ) ).GT.
491 $ cabs1( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
494 IF( ndfl.LT.kexnw )
THEN
496 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
516 nho = ( n-nw-1 ) - kt + 1
518 nve = ( n-nw ) - kwv + 1
522 CALL claqr2( wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz,
523 $ ihiz, z, ldz, ls, ld, w, h( kv, 1 ), ldh, nho,
524 $ h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh, work,
541 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
542 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
548 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
549 ns = ns - mod( ns, 2 )
558 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
560 DO 30 i = kbot, ks + 1, -2
561 w( i ) = h( i, i ) + wilk1*cabs1( h( i, i-1 ) )
572 IF( kbot-ks+1.LE.ns / 2 )
THEN
575 CALL clacpy(
'A', ns, ns, h( ks, ks ), ldh,
577 CALL clahqr( .false., .false., ns, 1, ns,
578 $ h( kt, 1 ), ldh, w( ks ), 1, 1, zdum,
589 IF( ks.GE.kbot )
THEN
590 s = cabs1( h( kbot-1, kbot-1 ) ) +
591 $ cabs1( h( kbot, kbot-1 ) ) +
592 $ cabs1( h( kbot-1, kbot ) ) +
593 $ cabs1( h( kbot, kbot ) )
594 aa = h( kbot-1, kbot-1 ) / s
595 cc = h( kbot, kbot-1 ) / s
596 bb = h( kbot-1, kbot ) / s
597 dd = h( kbot, kbot ) / s
598 tr2 = ( aa+dd ) / two
599 det = ( aa-tr2 )*( dd-tr2 ) - bb*cc
600 rtdisc = sqrt( -det )
601 w( kbot-1 ) = ( tr2+rtdisc )*s
602 w( kbot ) = ( tr2-rtdisc )*s
608 IF( kbot-ks+1.GT.ns )
THEN
613 DO 50 k = kbot, ks + 1, -1
618 IF( cabs1( w( i ) ).LT.cabs1( w( i+1 ) ) )
634 IF( kbot-ks+1.EQ.2 )
THEN
635 IF( cabs1( w( kbot )-h( kbot, kbot ) ).LT.
636 $ cabs1( w( kbot-1 )-h( kbot, kbot ) ) )
THEN
637 w( kbot-1 ) = w( kbot )
639 w( kbot ) = w( kbot-1 )
648 ns = min( ns, kbot-ks+1 )
649 ns = ns - mod( ns, 2 )
666 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
668 nve = n - kdu - kwv + 1
672 CALL claqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
673 $ w( ks ), h, ldh, iloz, ihiz, z, ldz, work,
674 $ 3, h( ku, 1 ), ldh, nve, h( kwv, 1 ), ldh,
675 $ nho, h( ku, kwh ), ldh )
698 work( 1 ) = cmplx( lwkopt, 0 )
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clahqr(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, info)
CLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine claqr2(wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz, ihiz, z, ldz, ns, nd, sh, v, ldv, nh, t, ldt, nv, wv, ldwv, work, lwork)
CLAQR2 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fu...
subroutine claqr4(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, work, lwork, info)
CLAQR4 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
subroutine claqr5(wantt, wantz, kacc22, n, ktop, kbot, nshfts, s, h, ldh, iloz, ihiz, z, ldz, v, ldv, u, ldu, nv, wv, ldwv, nh, wh, ldwh)
CLAQR5 performs a single small-bulge multi-shift QR sweep.