275 SUBROUTINE slaqr2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,
276 $ IHIZ, Z, LDZ, NS, ND, SR, SI, V, LDV, NH, T,
277 $ LDT, NV, WV, LDWV, WORK, LWORK )
284 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
285 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
289 REAL H( LDH, * ), SI( * ), SR( * ), T( LDT, * ),
290 $ V( LDV, * ), WORK( * ), WV( LDWV, * ),
297 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
300 REAL AA, BB, BETA, CC, CS, DD, EVI, EVK, FOO, S,
301 $ SAFMAX, SAFMIN, SMLNUM, SN, TAU, ULP
302 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, K, KCOL,
303 $ KEND, KLN, KROW, KWTOP, LTOP, LWK1, LWK2,
305 LOGICAL BULGE, SORTED
308 REAL SLAMCH, SROUNDUP_LWORK
309 EXTERNAL SLAMCH, SROUNDUP_LWORK
316 INTRINSIC abs, int, max, min, real, sqrt
322 jw = min( nw, kbot-ktop+1 )
329 CALL sgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
330 lwk1 = int( work( 1 ) )
334 CALL sormhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v, ldv,
336 lwk2 = int( work( 1 ) )
340 lwkopt = jw + max( lwk1, lwk2 )
345 IF( lwork.EQ.-1 )
THEN
346 work( 1 ) = sroundup_lwork( lwkopt )
363 safmin = slamch(
'SAFE MINIMUM' )
364 safmax = one / safmin
365 ulp = slamch(
'PRECISION' )
366 smlnum = safmin*( real( n ) / ulp )
370 jw = min( nw, kbot-ktop+1 )
371 kwtop = kbot - jw + 1
372 IF( kwtop.EQ.ktop )
THEN
375 s = h( kwtop, kwtop-1 )
378 IF( kbot.EQ.kwtop )
THEN
382 sr( kwtop ) = h( kwtop, kwtop )
386 IF( abs( s ).LE.max( smlnum, ulp*abs( h( kwtop, kwtop ) ) ) )
391 $ h( kwtop, kwtop-1 ) = zero
403 CALL slacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
404 CALL scopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ), ldt+1 )
406 CALL slaset(
'A', jw, jw, zero, one, v, ldv )
407 CALL slahqr( .true., .true., jw, 1, jw, t, ldt, sr( kwtop ),
408 $ si( kwtop ), 1, jw, v, ldv, infqr )
417 $ t( jw, jw-2 ) = zero
424 IF( ilst.LE.ns )
THEN
428 bulge = t( ns, ns-1 ).NE.zero
433 IF( .NOT.bulge )
THEN
437 foo = abs( t( ns, ns ) )
440 IF( abs( s*v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
THEN
451 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, work,
459 foo = abs( t( ns, ns ) ) + sqrt( abs( t( ns, ns-1 ) ) )*
460 $ sqrt( abs( t( ns-1, ns ) ) )
463 IF( max( abs( s*v( 1, ns ) ), abs( s*v( 1, ns-1 ) ) ).LE.
464 $ max( smlnum, ulp*foo ) )
THEN
476 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, work,
509 ELSE IF( t( i+1, i ).EQ.zero )
THEN
517 evi = abs( t( i, i ) )
519 evi = abs( t( i, i ) ) + sqrt( abs( t( i+1, i ) ) )*
520 $ sqrt( abs( t( i, i+1 ) ) )
524 evk = abs( t( k, k ) )
525 ELSE IF( t( k+1, k ).EQ.zero )
THEN
526 evk = abs( t( k, k ) )
528 evk = abs( t( k, k ) ) + sqrt( abs( t( k+1, k ) ) )*
529 $ sqrt( abs( t( k, k+1 ) ) )
532 IF( evi.GE.evk )
THEN
538 CALL strexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, work,
548 ELSE IF( t( i+1, i ).EQ.zero )
THEN
563 IF( i.GE.infqr+1 )
THEN
564 IF( i.EQ.infqr+1 )
THEN
565 sr( kwtop+i-1 ) = t( i, i )
566 si( kwtop+i-1 ) = zero
568 ELSE IF( t( i, i-1 ).EQ.zero )
THEN
569 sr( kwtop+i-1 ) = t( i, i )
570 si( kwtop+i-1 ) = zero
577 CALL slanv2( aa, bb, cc, dd, sr( kwtop+i-2 ),
578 $ si( kwtop+i-2 ), sr( kwtop+i-1 ),
579 $ si( kwtop+i-1 ), cs, sn )
585 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
586 IF( ns.GT.1 .AND. s.NE.zero )
THEN
590 CALL scopy( ns, v, ldv, work, 1 )
592 CALL slarfg( ns, beta, work( 2 ), 1, tau )
595 CALL slaset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ), ldt )
597 CALL slarf(
'L', ns, jw, work, 1, tau, t, ldt,
599 CALL slarf(
'R', ns, ns, work, 1, tau, t, ldt,
601 CALL slarf(
'R', jw, ns, work, 1, tau, v, ldv,
604 CALL sgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
611 $ h( kwtop, kwtop-1 ) = s*v( 1, 1 )
612 CALL slacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
613 CALL scopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
619 IF( ns.GT.1 .AND. s.NE.zero )
620 $
CALL sormhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v, ldv,
621 $ work( jw+1 ), lwork-jw, info )
630 DO 70 krow = ltop, kwtop - 1, nv
631 kln = min( nv, kwtop-krow )
632 CALL sgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
633 $ ldh, v, ldv, zero, wv, ldwv )
634 CALL slacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ), ldh )
640 DO 80 kcol = kbot + 1, n, nh
641 kln = min( nh, n-kcol+1 )
642 CALL sgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
643 $ h( kwtop, kcol ), ldh, zero, t, ldt )
644 CALL slacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
652 DO 90 krow = iloz, ihiz, nv
653 kln = min( nv, ihiz-krow+1 )
654 CALL sgemm(
'N',
'N', kln, jw, jw, one, z( krow, kwtop ),
655 $ ldz, v, ldv, zero, wv, ldwv )
656 CALL slacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
676 work( 1 ) = sroundup_lwork( lwkopt )
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
subroutine sgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
SGEHRD
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
subroutine slahqr(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, info)
SLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine slanv2(a, b, c, d, rt1r, rt1i, rt2r, rt2i, cs, sn)
SLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric matrix in standard form.
subroutine slaqr2(wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz, ihiz, z, ldz, ns, nd, sr, si, v, ldv, nh, t, ldt, nv, wv, ldwv, work, lwork)
SLAQR2 performs the orthogonal similarity transformation of a Hessenberg matrix to detect and deflate...
subroutine slarf(side, m, n, v, incv, tau, c, ldc, work)
SLARF applies an elementary reflector to a general rectangular matrix.
subroutine slarfg(n, alpha, x, incx, tau)
SLARFG generates an elementary reflector (Householder matrix).
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine strexc(compq, n, t, ldt, q, ldq, ifst, ilst, work, info)
STREXC
subroutine sormhr(side, trans, m, n, ilo, ihi, a, lda, tau, c, ldc, work, lwork, info)
SORMHR