275 SUBROUTINE dlaqr2( 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 DOUBLE PRECISION H( LDH, * ), SI( * ), SR( * ), T( LDT, * ),
290 $ V( LDV, * ), WORK( * ), WV( LDWV, * ),
296 DOUBLE PRECISION ZERO, ONE
297 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
300 DOUBLE PRECISION 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 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, ldv,
336 lwk2 = int( work( 1 ) )
340 lwkopt = jw + max( lwk1, lwk2 )
345 IF( lwork.EQ.-1 )
THEN
346 work( 1 ) = dble( lwkopt )
363 safmin = dlamch(
'SAFE MINIMUM' )
364 safmax = one / safmin
365 ulp = dlamch(
'PRECISION' )
366 smlnum = safmin*( dble( 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 dlacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
404 CALL dcopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ), ldt+1 )
406 CALL dlaset(
'A', jw, jw, zero, one, v, ldv )
407 CALL dlahqr( .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 dtrexc(
'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 dtrexc(
'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 dtrexc(
'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 dlanv2( 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 dcopy( ns, v, ldv, work, 1 )
592 CALL dlarfg( ns, beta, work( 2 ), 1, tau )
595 CALL dlaset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ), ldt )
597 CALL dlarf(
'L', ns, jw, work, 1, tau, t, ldt,
599 CALL dlarf(
'R', ns, ns, work, 1, tau, t, ldt,
601 CALL dlarf(
'R', jw, ns, work, 1, tau, v, ldv,
604 CALL dgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
611 $ h( kwtop, kwtop-1 ) = s*v( 1, 1 )
612 CALL dlacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
613 CALL dcopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
619 IF( ns.GT.1 .AND. s.NE.zero )
620 $
CALL dormhr(
'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 dgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
633 $ ldh, v, ldv, zero, wv, ldwv )
634 CALL dlacpy(
'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 dgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
643 $ h( kwtop, kcol ), ldh, zero, t, ldt )
644 CALL dlacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
652 DO 90 krow = iloz, ihiz, nv
653 kln = min( nv, ihiz-krow+1 )
654 CALL dgemm(
'N',
'N', kln, jw, jw, one, z( krow, kwtop ),
655 $ ldz, v, ldv, zero, wv, ldwv )
656 CALL dlacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
676 work( 1 ) = dble( lwkopt )
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
DGEHRD
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
subroutine dlahqr(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, info)
DLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine dlanv2(a, b, c, d, rt1r, rt1i, rt2r, rt2i, cs, sn)
DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric matrix in standard form.
subroutine dlaqr2(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)
DLAQR2 performs the orthogonal similarity transformation of a Hessenberg matrix to detect and deflate...
subroutine dlarf(side, m, n, v, incv, tau, c, ldc, work)
DLARF applies an elementary reflector to a general rectangular matrix.
subroutine dlarfg(n, alpha, x, incx, tau)
DLARFG generates an elementary reflector (Householder matrix).
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine dtrexc(compq, n, t, ldt, q, ldq, ifst, ilst, work, info)
DTREXC
subroutine dormhr(side, trans, m, n, ilo, ihi, a, lda, tau, c, ldc, work, lwork, info)
DORMHR