264 SUBROUTINE claqr2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH,
266 $ IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,
267 $ NV, WV, LDWV, WORK, LWORK )
274 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
275 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
279 COMPLEX H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
280 $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )
287 PARAMETER ( ZERO = ( 0.0e0, 0.0e0 ),
288 $ one = ( 1.0e0, 0.0e0 ) )
290 parameter( rzero = 0.0e0, rone = 1.0e0 )
294 REAL FOO, SAFMAX, SAFMIN, SMLNUM, ULP
295 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,
296 $ knt, krow, kwtop, ltop, lwk1, lwk2, lwkopt
308 INTRINSIC abs, aimag, cmplx, conjg, int, max, min, real
314 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
320 jw = min( nw, kbot-ktop+1 )
327 CALL cgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
328 lwk1 = int( work( 1 ) )
332 CALL cunmhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v,
335 lwk2 = int( work( 1 ) )
339 lwkopt = jw + max( lwk1, lwk2 )
344 IF( lwork.EQ.-1 )
THEN
345 work( 1 ) = cmplx( lwkopt, 0 )
362 safmin = slamch(
'SAFE MINIMUM' )
363 safmax = rone / safmin
364 ulp = slamch(
'PRECISION' )
365 smlnum = safmin*( real( n ) / ulp )
369 jw = min( nw, kbot-ktop+1 )
370 kwtop = kbot - jw + 1
371 IF( kwtop.EQ.ktop )
THEN
374 s = h( kwtop, kwtop-1 )
377 IF( kbot.EQ.kwtop )
THEN
381 sh( kwtop ) = h( kwtop, kwtop )
384 IF( cabs1( s ).LE.max( smlnum, ulp*cabs1( h( kwtop,
389 $ h( kwtop, kwtop-1 ) = zero
401 CALL clacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
402 CALL ccopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ),
405 CALL claset(
'A', jw, jw, zero, one, v, ldv )
406 CALL clahqr( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ), 1,
407 $ jw, v, ldv, infqr )
413 DO 10 knt = infqr + 1, jw
417 foo = cabs1( t( ns, ns ) )
420 IF( cabs1( s )*cabs1( v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
432 CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, info )
447 DO 30 i = infqr + 1, ns
450 IF( cabs1( t( j, j ) ).GT.cabs1( t( ifst, ifst ) ) )
455 $
CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
462 DO 40 i = infqr + 1, jw
463 sh( kwtop+i-1 ) = t( i, i )
467 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
468 IF( ns.GT.1 .AND. s.NE.zero )
THEN
472 CALL ccopy( ns, v, ldv, work, 1 )
474 work( i ) = conjg( work( i ) )
476 CALL clarfg( ns, work( 1 ), work( 2 ), 1, tau )
478 CALL claset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ),
481 CALL clarf1f(
'L', ns, jw, work, 1, conjg( tau ), t, ldt,
483 CALL clarf1f(
'R', ns, ns, work, 1, tau, t, ldt,
485 CALL clarf1f(
'R', jw, ns, work, 1, tau, v, ldv,
488 CALL cgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
495 $ h( kwtop, kwtop-1 ) = s*conjg( v( 1, 1 ) )
496 CALL clacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
497 CALL ccopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
503 IF( ns.GT.1 .AND. s.NE.zero )
504 $
CALL cunmhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v,
506 $ work( jw+1 ), lwork-jw, info )
515 DO 60 krow = ltop, kwtop - 1, nv
516 kln = min( nv, kwtop-krow )
517 CALL cgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
518 $ ldh, v, ldv, zero, wv, ldwv )
519 CALL clacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ),
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,
542 $ ldz, v, ldv, zero, wv, ldwv )
543 CALL clacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
563 work( 1 ) = cmplx( lwkopt, 0 )