273 SUBROUTINE dlaqr2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH,
275 $ IHIZ, Z, LDZ, NS, ND, SR, SI, V, LDV, NH, T,
276 $ LDT, NV, WV, LDWV, WORK, LWORK )
283 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
284 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
288 DOUBLE PRECISION H( LDH, * ), SI( * ), SR( * ), T( LDT, * ),
289 $ V( LDV, * ), WORK( * ), WV( LDWV, * ),
295 DOUBLE PRECISION ZERO, ONE
296 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
299 DOUBLE PRECISION AA, BB, BETA, CC, CS, DD, EVI, EVK, FOO, S,
300 $ SAFMAX, SAFMIN, SMLNUM, SN, TAU, ULP
301 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, K, KCOL,
302 $ kend, kln, krow, kwtop, ltop, lwk1, lwk2,
304 LOGICAL BULGE, SORTED
307 DOUBLE PRECISION DLAMCH
316 INTRINSIC abs, dble, int, max, min, sqrt
322 jw = min( nw, kbot-ktop+1 )
329 CALL dgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
330 lwk1 = int( work( 1 ) )
334 CALL dormhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v,
337 lwk2 = int( work( 1 ) )
341 lwkopt = jw + max( lwk1, lwk2 )
346 IF( lwork.EQ.-1 )
THEN
347 work( 1 ) = dble( lwkopt )
364 safmin = dlamch(
'SAFE MINIMUM' )
365 safmax = one / safmin
366 ulp = dlamch(
'PRECISION' )
367 smlnum = safmin*( dble( n ) / ulp )
371 jw = min( nw, kbot-ktop+1 )
372 kwtop = kbot - jw + 1
373 IF( kwtop.EQ.ktop )
THEN
376 s = h( kwtop, kwtop-1 )
379 IF( kbot.EQ.kwtop )
THEN
383 sr( kwtop ) = h( kwtop, kwtop )
387 IF( abs( s ).LE.max( smlnum, ulp*abs( h( kwtop, kwtop ) ) ) )
392 $ h( kwtop, kwtop-1 ) = zero
404 CALL dlacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
405 CALL dcopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ),
408 CALL dlaset(
'A', jw, jw, zero, one, v, ldv )
409 CALL dlahqr( .true., .true., jw, 1, jw, t, ldt, sr( kwtop ),
410 $ si( kwtop ), 1, jw, v, ldv, infqr )
419 $ t( jw, jw-2 ) = zero
426 IF( ilst.LE.ns )
THEN
430 bulge = t( ns, ns-1 ).NE.zero
435 IF( .NOT.bulge )
THEN
439 foo = abs( t( ns, ns ) )
442 IF( abs( s*v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
THEN
453 CALL dtrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
462 foo = abs( t( ns, ns ) ) + sqrt( abs( t( ns, ns-1 ) ) )*
463 $ sqrt( abs( t( ns-1, ns ) ) )
466 IF( max( abs( s*v( 1, ns ) ), abs( s*v( 1, ns-1 ) ) ).LE.
467 $ max( smlnum, ulp*foo ) )
THEN
479 CALL dtrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
513 ELSE IF( t( i+1, i ).EQ.zero )
THEN
521 evi = abs( t( i, i ) )
523 evi = abs( t( i, i ) ) + sqrt( abs( t( i+1, i ) ) )*
524 $ sqrt( abs( t( i, i+1 ) ) )
528 evk = abs( t( k, k ) )
529 ELSE IF( t( k+1, k ).EQ.zero )
THEN
530 evk = abs( t( k, k ) )
532 evk = abs( t( k, k ) ) + sqrt( abs( t( k+1, k ) ) )*
533 $ sqrt( abs( t( k, k+1 ) ) )
536 IF( evi.GE.evk )
THEN
542 CALL dtrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
553 ELSE IF( t( i+1, i ).EQ.zero )
THEN
568 IF( i.GE.infqr+1 )
THEN
569 IF( i.EQ.infqr+1 )
THEN
570 sr( kwtop+i-1 ) = t( i, i )
571 si( kwtop+i-1 ) = zero
573 ELSE IF( t( i, i-1 ).EQ.zero )
THEN
574 sr( kwtop+i-1 ) = t( i, i )
575 si( kwtop+i-1 ) = zero
582 CALL dlanv2( aa, bb, cc, dd, sr( kwtop+i-2 ),
583 $ si( kwtop+i-2 ), sr( kwtop+i-1 ),
584 $ si( kwtop+i-1 ), cs, sn )
590 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
591 IF( ns.GT.1 .AND. s.NE.zero )
THEN
595 CALL dcopy( ns, v, ldv, work, 1 )
597 CALL dlarfg( ns, beta, work( 2 ), 1, tau )
599 CALL dlaset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ),
602 CALL dlarf1f(
'L', ns, jw, work, 1, tau, t, ldt,
604 CALL dlarf1f(
'R', ns, ns, work, 1, tau, t, ldt,
606 CALL dlarf1f(
'R', jw, ns, work, 1, tau, v, ldv,
609 CALL dgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
616 $ h( kwtop, kwtop-1 ) = s*v( 1, 1 )
617 CALL dlacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
618 CALL dcopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
624 IF( ns.GT.1 .AND. s.NE.zero )
625 $
CALL dormhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v,
627 $ work( jw+1 ), lwork-jw, info )
636 DO 70 krow = ltop, kwtop - 1, nv
637 kln = min( nv, kwtop-krow )
638 CALL dgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
639 $ ldh, v, ldv, zero, wv, ldwv )
640 CALL dlacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ),
647 DO 80 kcol = kbot + 1, n, nh
648 kln = min( nh, n-kcol+1 )
649 CALL dgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
650 $ h( kwtop, kcol ), ldh, zero, t, ldt )
651 CALL dlacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
659 DO 90 krow = iloz, ihiz, nv
660 kln = min( nv, ihiz-krow+1 )
661 CALL dgemm(
'N',
'N', kln, jw, jw, one, z( krow,
663 $ ldz, v, ldv, zero, wv, ldwv )
664 CALL dlacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
684 work( 1 ) = dble( lwkopt )