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 )