268 SUBROUTINE claqr2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,
269 $ ihiz, z, ldz, ns, nd, sh, v, ldv, nh, t, ldt,
270 $ nv, wv, ldwv, work, lwork )
278 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
279 $ ldz, lwork, n, nd, nh, ns, nv, nw
283 COMPLEX H( ldh, * ), SH( * ), T( ldt, * ), V( ldv, * ),
284 $ work( * ), wv( ldwv, * ), z( ldz, * )
291 parameter ( zero = ( 0.0e0, 0.0e0 ),
292 $ one = ( 1.0e0, 0.0e0 ) )
294 parameter ( rzero = 0.0e0, rone = 1.0e0 )
297 COMPLEX BETA, CDUM, S, TAU
298 REAL FOO, SAFMAX, SAFMIN, SMLNUM, ULP
299 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,
300 $ knt, krow, kwtop, ltop, lwk1, lwk2, lwkopt
311 INTRINSIC abs, aimag, cmplx, conjg, int, max, min, real
317 cabs1( cdum ) = abs(
REAL( CDUM ) ) + abs( AIMAG( cdum ) )
323 jw = min( nw, kbot-ktop+1 )
330 CALL cgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
331 lwk1 = int( work( 1 ) )
335 CALL cunmhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v, ldv,
337 lwk2 = int( work( 1 ) )
341 lwkopt = jw + max( lwk1, lwk2 )
346 IF( lwork.EQ.-1 )
THEN
347 work( 1 ) = cmplx( lwkopt, 0 )
364 safmin = slamch(
'SAFE MINIMUM' )
365 safmax = rone / safmin
366 CALL slabad( safmin, safmax )
367 ulp = slamch(
'PRECISION' )
368 smlnum = safmin*(
REAL( N ) / ULP )
372 jw = min( nw, kbot-ktop+1 )
373 kwtop = kbot - jw + 1
374 IF( kwtop.EQ.ktop )
THEN
377 s = h( kwtop, kwtop-1 )
380 IF( kbot.EQ.kwtop )
THEN
384 sh( kwtop ) = h( kwtop, kwtop )
387 IF( cabs1( s ).LE.max( smlnum, ulp*cabs1( h( kwtop,
392 $ h( kwtop, kwtop-1 ) = zero
404 CALL clacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
405 CALL ccopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ), ldt+1 )
407 CALL claset(
'A', jw, jw, zero, one, v, ldv )
408 CALL clahqr( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ), 1,
409 $ jw, v, ldv, infqr )
415 DO 10 knt = infqr + 1, jw
419 foo = cabs1( t( ns, ns ) )
422 IF( cabs1( s )*cabs1( v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
434 CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, info )
449 DO 30 i = infqr + 1, ns
452 IF( cabs1( t( j, j ) ).GT.cabs1( t( ifst, ifst ) ) )
457 $
CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, info )
463 DO 40 i = infqr + 1, jw
464 sh( kwtop+i-1 ) = t( i, i )
468 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
469 IF( ns.GT.1 .AND. s.NE.zero )
THEN
473 CALL ccopy( ns, v, ldv, work, 1 )
475 work( i ) = conjg( work( i ) )
478 CALL clarfg( ns, beta, work( 2 ), 1, tau )
481 CALL claset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ), ldt )
483 CALL clarf(
'L', ns, jw, work, 1, conjg( tau ), t, ldt,
485 CALL clarf(
'R', ns, ns, work, 1, tau, t, ldt,
487 CALL clarf(
'R', jw, ns, work, 1, tau, v, ldv,
490 CALL cgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
497 $ h( kwtop, kwtop-1 ) = s*conjg( v( 1, 1 ) )
498 CALL clacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
499 CALL ccopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
505 IF( ns.GT.1 .AND. s.NE.zero )
506 $
CALL cunmhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v, ldv,
507 $ work( jw+1 ), lwork-jw, info )
516 DO 60 krow = ltop, kwtop - 1, nv
517 kln = min( nv, kwtop-krow )
518 CALL cgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
519 $ ldh, v, ldv, zero, wv, ldwv )
520 CALL clacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ), ldh )
526 DO 70 kcol = kbot + 1, n, nh
527 kln = min( nh, n-kcol+1 )
528 CALL cgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
529 $ h( kwtop, kcol ), ldh, zero, t, ldt )
530 CALL clacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
538 DO 80 krow = iloz, ihiz, nv
539 kln = min( nv, ihiz-krow+1 )
540 CALL cgemm(
'N',
'N', kln, jw, jw, one, z( krow, kwtop ),
541 $ ldz, v, ldv, zero, wv, ldwv )
542 CALL clacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
562 work( 1 ) = cmplx( lwkopt, 0 )
subroutine slabad(SMALL, LARGE)
SLABAD
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, using the double-shift/single-shift QR algorithm.
subroutine claqr2(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)
CLAQR2 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fu...
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
subroutine clarf(SIDE, M, N, V, INCV, TAU, C, LDC, WORK)
CLARF applies an elementary reflector to a general rectangular matrix.
subroutine cunmhr(SIDE, TRANS, M, N, ILO, IHI, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMHR
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine cgehrd(N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
CGEHRD
subroutine ctrexc(COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, INFO)
CTREXC
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
subroutine clarfg(N, ALPHA, X, INCX, TAU)
CLARFG generates an elementary reflector (Householder matrix).