270 SUBROUTINE slaqr3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH,
272 $ IHIZ, Z, LDZ, NS, ND, SR, SI, V, LDV, NH, T,
273 $ LDT, NV, WV, LDWV, WORK, LWORK )
280 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
281 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
285 REAL H( LDH, * ), SI( * ), SR( * ), T( LDT, * ),
286 $ V( LDV, * ), WORK( * ), WV( LDWV, * ),
293 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
296 REAL AA, BB, CC, CS, DD, EVI, EVK, FOO, S,
297 $ SAFMAX, SAFMIN, SMLNUM, SN, TAU, ULP
298 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, K, KCOL,
299 $ kend, kln, krow, kwtop, ltop, lwk1, lwk2, lwk3,
301 LOGICAL BULGE, SORTED
304 REAL SLAMCH, SROUNDUP_LWORK
306 EXTERNAL SLAMCH, SROUNDUP_LWORK, ILAENV
315 INTRINSIC abs, int, max, min, real, sqrt
321 jw = min( nw, kbot-ktop+1 )
328 CALL sgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
329 lwk1 = int( work( 1 ) )
333 CALL sormhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v,
336 lwk2 = int( work( 1 ) )
340 CALL slaqr4( .true., .true., jw, 1, jw, t, ldt, sr, si, 1,
342 $ v, ldv, work, -1, infqr )
343 lwk3 = int( work( 1 ) )
347 lwkopt = max( jw+max( lwk1, lwk2 ), lwk3 )
352 IF( lwork.EQ.-1 )
THEN
353 work( 1 ) = sroundup_lwork( lwkopt )
370 safmin = slamch(
'SAFE MINIMUM' )
371 safmax = one / safmin
372 ulp = slamch(
'PRECISION' )
373 smlnum = safmin*( real( n ) / ulp )
377 jw = min( nw, kbot-ktop+1 )
378 kwtop = kbot - jw + 1
379 IF( kwtop.EQ.ktop )
THEN
382 s = h( kwtop, kwtop-1 )
385 IF( kbot.EQ.kwtop )
THEN
389 sr( kwtop ) = h( kwtop, kwtop )
393 IF( abs( s ).LE.max( smlnum, ulp*abs( h( kwtop, kwtop ) ) ) )
398 $ h( kwtop, kwtop-1 ) = zero
410 CALL slacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
411 CALL scopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ),
414 CALL slaset(
'A', jw, jw, zero, one, v, ldv )
415 nmin = ilaenv( 12,
'SLAQR3',
'SV', jw, 1, jw, lwork )
416 IF( jw.GT.nmin )
THEN
417 CALL slaqr4( .true., .true., jw, 1, jw, t, ldt, sr( kwtop ),
418 $ si( kwtop ), 1, jw, v, ldv, work, lwork, infqr )
420 CALL slahqr( .true., .true., jw, 1, jw, t, ldt, sr( kwtop ),
421 $ si( kwtop ), 1, jw, v, ldv, infqr )
431 $ t( jw, jw-2 ) = zero
438 IF( ilst.LE.ns )
THEN
442 bulge = t( ns, ns-1 ).NE.zero
447 IF( .NOT. bulge )
THEN
451 foo = abs( t( ns, ns ) )
454 IF( abs( s*v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
THEN
465 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
474 foo = abs( t( ns, ns ) ) + sqrt( abs( t( ns, ns-1 ) ) )*
475 $ sqrt( abs( t( ns-1, ns ) ) )
478 IF( max( abs( s*v( 1, ns ) ), abs( s*v( 1, ns-1 ) ) ).LE.
479 $ max( smlnum, ulp*foo ) )
THEN
491 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
525 ELSE IF( t( i+1, i ).EQ.zero )
THEN
533 evi = abs( t( i, i ) )
535 evi = abs( t( i, i ) ) + sqrt( abs( t( i+1, i ) ) )*
536 $ sqrt( abs( t( i, i+1 ) ) )
540 evk = abs( t( k, k ) )
541 ELSE IF( t( k+1, k ).EQ.zero )
THEN
542 evk = abs( t( k, k ) )
544 evk = abs( t( k, k ) ) + sqrt( abs( t( k+1, k ) ) )*
545 $ sqrt( abs( t( k, k+1 ) ) )
548 IF( evi.GE.evk )
THEN
554 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
565 ELSE IF( t( i+1, i ).EQ.zero )
THEN
580 IF( i.GE.infqr+1 )
THEN
581 IF( i.EQ.infqr+1 )
THEN
582 sr( kwtop+i-1 ) = t( i, i )
583 si( kwtop+i-1 ) = zero
585 ELSE IF( t( i, i-1 ).EQ.zero )
THEN
586 sr( kwtop+i-1 ) = t( i, i )
587 si( kwtop+i-1 ) = zero
594 CALL slanv2( aa, bb, cc, dd, sr( kwtop+i-2 ),
595 $ si( kwtop+i-2 ), sr( kwtop+i-1 ),
596 $ si( kwtop+i-1 ), cs, sn )
602 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
603 IF( ns.GT.1 .AND. s.NE.zero )
THEN
607 CALL scopy( ns, v, ldv, work, 1 )
608 CALL slarfg( ns, work( 1 ), work( 2 ), 1, tau )
610 CALL slaset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ),
613 CALL slarf1f(
'L', ns, jw, work, 1, tau, t, ldt,
615 CALL slarf1f(
'R', ns, ns, work, 1, tau, t, ldt,
617 CALL slarf1f(
'R', jw, ns, work, 1, tau, v, ldv,
620 CALL sgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
627 $ h( kwtop, kwtop-1 ) = s*v( 1, 1 )
628 CALL slacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
629 CALL scopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
635 IF( ns.GT.1 .AND. s.NE.zero )
636 $
CALL sormhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v,
638 $ work( jw+1 ), lwork-jw, info )
647 DO 70 krow = ltop, kwtop - 1, nv
648 kln = min( nv, kwtop-krow )
649 CALL sgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
650 $ ldh, v, ldv, zero, wv, ldwv )
651 CALL slacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ),
658 DO 80 kcol = kbot + 1, n, nh
659 kln = min( nh, n-kcol+1 )
660 CALL sgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
661 $ h( kwtop, kcol ), ldh, zero, t, ldt )
662 CALL slacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
670 DO 90 krow = iloz, ihiz, nv
671 kln = min( nv, ihiz-krow+1 )
672 CALL sgemm(
'N',
'N', kln, jw, jw, one, z( krow,
674 $ ldz, v, ldv, zero, wv, ldwv )
675 CALL slacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
695 work( 1 ) = sroundup_lwork( lwkopt )