261 SUBROUTINE claqr3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH,
263 $ IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,
264 $ NV, WV, LDWV, WORK, LWORK )
271 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
272 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
276 COMPLEX H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
277 $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )
284 PARAMETER ( ZERO = ( 0.0e0, 0.0e0 ),
285 $ one = ( 1.0e0, 0.0e0 ) )
287 parameter( rzero = 0.0e0, rone = 1.0e0 )
291 REAL FOO, SAFMAX, SAFMIN, SMLNUM, ULP
292 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,
293 $ knt, krow, kwtop, ltop, lwk1, lwk2, lwk3,
299 EXTERNAL SLAMCH, ILAENV
307 INTRINSIC abs, aimag, cmplx, conjg, int, max, min, real
313 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
319 jw = min( nw, kbot-ktop+1 )
326 CALL cgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
327 lwk1 = int( work( 1 ) )
331 CALL cunmhr(
'R',
'N', jw, jw, 1, jw-1, t, ldt, work, v,
334 lwk2 = int( work( 1 ) )
338 CALL claqr4( .true., .true., jw, 1, jw, t, ldt, sh, 1, jw,
340 $ ldv, work, -1, infqr )
341 lwk3 = int( work( 1 ) )
345 lwkopt = max( jw+max( lwk1, lwk2 ), lwk3 )
350 IF( lwork.EQ.-1 )
THEN
351 work( 1 ) = cmplx( lwkopt, 0 )
368 safmin = slamch(
'SAFE MINIMUM' )
369 safmax = rone / safmin
370 ulp = slamch(
'PRECISION' )
371 smlnum = safmin*( real( n ) / ulp )
375 jw = min( nw, kbot-ktop+1 )
376 kwtop = kbot - jw + 1
377 IF( kwtop.EQ.ktop )
THEN
380 s = h( kwtop, kwtop-1 )
383 IF( kbot.EQ.kwtop )
THEN
387 sh( kwtop ) = h( kwtop, kwtop )
390 IF( cabs1( s ).LE.max( smlnum, ulp*cabs1( h( kwtop,
395 $ h( kwtop, kwtop-1 ) = zero
407 CALL clacpy(
'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
408 CALL ccopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ),
411 CALL claset(
'A', jw, jw, zero, one, v, ldv )
412 nmin = ilaenv( 12,
'CLAQR3',
'SV', jw, 1, jw, lwork )
413 IF( jw.GT.nmin )
THEN
414 CALL claqr4( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ),
416 $ jw, v, ldv, work, lwork, infqr )
418 CALL clahqr( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ),
420 $ jw, v, ldv, infqr )
427 DO 10 knt = infqr + 1, jw
431 foo = cabs1( t( ns, ns ) )
434 IF( cabs1( s )*cabs1( v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
446 CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst, info )
461 DO 30 i = infqr + 1, ns
464 IF( cabs1( t( j, j ) ).GT.cabs1( t( ifst, ifst ) ) )
469 $
CALL ctrexc(
'V', jw, t, ldt, v, ldv, ifst, ilst,
476 DO 40 i = infqr + 1, jw
477 sh( kwtop+i-1 ) = t( i, i )
481 IF( ns.LT.jw .OR. s.EQ.zero )
THEN
482 IF( ns.GT.1 .AND. s.NE.zero )
THEN
486 CALL ccopy( ns, v, ldv, work, 1 )
488 work( i ) = conjg( work( i ) )
490 CALL clarfg( ns, work( 1 ), work( 2 ), 1, tau )
492 CALL claset(
'L', jw-2, jw-2, zero, zero, t( 3, 1 ),
495 CALL clarf1f(
'L', ns, jw, work, 1, conjg( tau ), t, ldt,
497 CALL clarf1f(
'R', ns, ns, work, 1, tau, t, ldt,
499 CALL clarf1f(
'R', jw, ns, work, 1, tau, v, ldv,
502 CALL cgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
509 $ h( kwtop, kwtop-1 ) = s*conjg( v( 1, 1 ) )
510 CALL clacpy(
'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
511 CALL ccopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
517 IF( ns.GT.1 .AND. s.NE.zero )
518 $
CALL cunmhr(
'R',
'N', jw, ns, 1, ns, t, ldt, work, v,
520 $ work( jw+1 ), lwork-jw, info )
529 DO 60 krow = ltop, kwtop - 1, nv
530 kln = min( nv, kwtop-krow )
531 CALL cgemm(
'N',
'N', kln, jw, jw, one, h( krow, kwtop ),
532 $ ldh, v, ldv, zero, wv, ldwv )
533 CALL clacpy(
'A', kln, jw, wv, ldwv, h( krow, kwtop ),
540 DO 70 kcol = kbot + 1, n, nh
541 kln = min( nh, n-kcol+1 )
542 CALL cgemm(
'C',
'N', jw, kln, jw, one, v, ldv,
543 $ h( kwtop, kcol ), ldh, zero, t, ldt )
544 CALL clacpy(
'A', jw, kln, t, ldt, h( kwtop, kcol ),
552 DO 80 krow = iloz, ihiz, nv
553 kln = min( nv, ihiz-krow+1 )
554 CALL cgemm(
'N',
'N', kln, jw, jw, one, z( krow,
556 $ ldz, v, ldv, zero, wv, ldwv )
557 CALL clacpy(
'A', kln, jw, wv, ldwv, z( krow, kwtop ),
577 work( 1 ) = cmplx( lwkopt, 0 )