238 SUBROUTINE claqr0( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
239 $ IHIZ, Z, LDZ, WORK, LWORK, INFO )
246 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
250 COMPLEX H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )
260 parameter( ntiny = 15 )
266 parameter( kexnw = 5 )
272 parameter( kexsh = 6 )
277 parameter( wilk1 = 0.75e0 )
279 parameter( zero = ( 0.0e0, 0.0e0 ),
280 $ one = ( 1.0e0, 0.0e0 ) )
282 parameter( two = 2.0e0 )
285 COMPLEX AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2
287 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
288 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
289 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
290 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
305 INTRINSIC abs, aimag, cmplx, int, max, min, mod, real,
312 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
324 IF( n.LE.ntiny )
THEN
330 $
CALL clahqr( wantt, wantz, n, ilo, ihi, h, ldh, w, iloz,
331 $ ihiz, z, ldz, info )
360 nwr = ilaenv( 13,
'CLAQR0', jbcmpz, n, ilo, ihi, lwork )
362 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
369 nsr = ilaenv( 15,
'CLAQR0', jbcmpz, n, ilo, ihi, lwork )
370 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
371 nsr = max( 2, nsr-mod( nsr, 2 ) )
377 CALL claqr3( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
378 $ ihiz, z, ldz, ls, ld, w, h, ldh, n, h, ldh, n, h,
383 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
387 IF( lwork.EQ.-1 )
THEN
388 work( 1 ) = cmplx( lwkopt, 0 )
394 nmin = ilaenv( 12,
'CLAQR0', jbcmpz, n, ilo, ihi, lwork )
395 nmin = max( ntiny, nmin )
399 nibble = ilaenv( 14,
'CLAQR0', jbcmpz, n, ilo, ihi, lwork )
400 nibble = max( 0, nibble )
405 kacc22 = ilaenv( 16,
'CLAQR0', jbcmpz, n, ilo, ihi, lwork )
406 kacc22 = max( 0, kacc22 )
407 kacc22 = min( 2, kacc22 )
412 nwmax = min( ( n-1 ) / 3, lwork / 2 )
418 nsmax = min( ( n-3 ) / 6, 2*lwork / 3 )
419 nsmax = nsmax - mod( nsmax, 2 )
427 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
444 DO 10 k = kbot, ilo + 1, -1
445 IF( h( k, k-1 ).EQ.zero )
469 nwupbd = min( nh, nwmax )
470 IF( ndfl.LT.kexnw )
THEN
471 nw = min( nwupbd, nwr )
473 nw = min( nwupbd, 2*nw )
475 IF( nw.LT.nwmax )
THEN
476 IF( nw.GE.nh-1 )
THEN
479 kwtop = kbot - nw + 1
480 IF( cabs1( h( kwtop, kwtop-1 ) ).GT.
481 $ cabs1( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
484 IF( ndfl.LT.kexnw )
THEN
486 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
506 nho = ( n-nw-1 ) - kt + 1
508 nve = ( n-nw ) - kwv + 1
512 CALL claqr3( wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz,
513 $ ihiz, z, ldz, ls, ld, w, h( kv, 1 ), ldh, nho,
514 $ h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh, work,
531 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
532 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
538 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
539 ns = ns - mod( ns, 2 )
548 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
550 DO 30 i = kbot, ks + 1, -2
551 w( i ) = h( i, i ) + wilk1*cabs1( h( i, i-1 ) )
562 IF( kbot-ks+1.LE.ns / 2 )
THEN
565 CALL clacpy(
'A', ns, ns, h( ks, ks ), ldh,
567 IF( ns.GT.nmin )
THEN
568 CALL claqr4( .false., .false., ns, 1, ns,
569 $ h( kt, 1 ), ldh, w( ks ), 1, 1,
570 $ zdum, 1, work, lwork, inf )
572 CALL clahqr( .false., .false., ns, 1, ns,
573 $ h( kt, 1 ), ldh, w( ks ), 1, 1,
585 IF( ks.GE.kbot )
THEN
586 s = cabs1( h( kbot-1, kbot-1 ) ) +
587 $ cabs1( h( kbot, kbot-1 ) ) +
588 $ cabs1( h( kbot-1, kbot ) ) +
589 $ cabs1( h( kbot, kbot ) )
590 aa = h( kbot-1, kbot-1 ) / s
591 cc = h( kbot, kbot-1 ) / s
592 bb = h( kbot-1, kbot ) / s
593 dd = h( kbot, kbot ) / s
594 tr2 = ( aa+dd ) / two
595 det = ( aa-tr2 )*( dd-tr2 ) - bb*cc
596 rtdisc = sqrt( -det )
597 w( kbot-1 ) = ( tr2+rtdisc )*s
598 w( kbot ) = ( tr2-rtdisc )*s
604 IF( kbot-ks+1.GT.ns )
THEN
609 DO 50 k = kbot, ks + 1, -1
614 IF( cabs1( w( i ) ).LT.cabs1( w( i+1 ) ) )
630 IF( kbot-ks+1.EQ.2 )
THEN
631 IF( cabs1( w( kbot )-h( kbot, kbot ) ).LT.
632 $ cabs1( w( kbot-1 )-h( kbot, kbot ) ) )
THEN
633 w( kbot-1 ) = w( kbot )
635 w( kbot ) = w( kbot-1 )
644 ns = min( ns, kbot-ks+1 )
645 ns = ns - mod( ns, 2 )
662 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
664 nve = n - kdu - kwv + 1
668 CALL claqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
669 $ w( ks ), h, ldh, iloz, ihiz, z, ldz, work,
670 $ 3, h( ku, 1 ), ldh, nve, h( kwv, 1 ), ldh,
671 $ nho, h( ku, kwh ), ldh )
694 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 claqr0(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, work, lwork, info)
CLAQR0 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
subroutine claqr3(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)
CLAQR3 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.