279 SUBROUTINE clarrv( N, VL, VU, D, L, PIVMIN,
280 $ ISPLIT, M, DOL, DOU, MINRGP,
281 $ RTOL1, RTOL2, W, WERR, WGAP,
282 $ IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ,
283 $ WORK, IWORK, INFO )
290 INTEGER DOL, DOU, INFO, LDZ, M, N
291 REAL MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU
294 INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ),
295 $ isuppz( * ), iwork( * )
296 REAL D( * ), GERS( * ), L( * ), W( * ), WERR( * ),
297 $ WGAP( * ), WORK( * )
305 PARAMETER ( MAXITR = 10 )
307 parameter( czero = ( 0.0e0, 0.0e0 ) )
308 REAL ZERO, ONE, TWO, THREE, FOUR, HALF
309 parameter( zero = 0.0e0, one = 1.0e0,
310 $ two = 2.0e0, three = 3.0e0,
311 $ four = 4.0e0, half = 0.5e0)
314 LOGICAL ESKIP, NEEDBS, STP2II, TRYRQC, USEDBS, USEDRQ
315 INTEGER DONE, I, IBEGIN, IDONE, IEND, II, IINDC1,
316 $ IINDC2, IINDR, IINDWK, IINFO, IM, IN, INDEIG,
317 $ INDLD, INDLLD, INDWRK, ISUPMN, ISUPMX, ITER,
318 $ itmp1, j, jblk, k, miniwsize, minwsize, nclus,
319 $ ndepth, negcnt, newcls, newfst, newftt, newlst,
320 $ newsiz, offset, oldcls, oldfst, oldien, oldlst,
321 $ oldncl, p, parity, q, wbegin, wend, windex,
322 $ windmn, windpl, zfrom, zto, zusedl, zusedu,
324 INTEGER INDIN1, INDIN2
325 REAL BSTRES, BSTW, EPS, FUDGE, GAP, GAPTOL, GL, GU,
326 $ LAMBDA, LEFT, LGAP, MINGMA, NRMINV, RESID,
327 $ RGAP, RIGHT, RQCORR, RQTOL, SAVGAP, SGNDEF,
328 $ sigma, spdiam, ssigma, tau, tmp, tol, ztz
340 INTRINSIC abs, real, max, min
350 IF( (n.LE.0).OR.(m.LE.0) )
THEN
391 zusedw = zusedu - zusedl + 1
394 CALL claset(
'Full', n, zusedw, czero, czero,
397 eps = slamch(
'Precision' )
403 IF((dol.EQ.1).AND.(dou.EQ.m))
THEN
422 DO 170 jblk = 1, iblock( m )
423 iend = isplit( jblk )
430 IF( iblock( wend+1 ).EQ.jblk )
THEN
435 IF( wend.LT.wbegin )
THEN
438 ELSEIF( (wend.LT.dol).OR.(wbegin.GT.dou) )
THEN
445 gl = gers( 2*ibegin-1 )
446 gu = gers( 2*ibegin )
447 DO 20 i = ibegin+1 , iend
448 gl = min( gers( 2*i-1 ), gl )
449 gu = max( gers( 2*i ), gu )
456 in = iend - ibegin + 1
458 im = wend - wbegin + 1
461 IF( ibegin.EQ.iend )
THEN
463 z( ibegin, wbegin ) = cmplx( one, zero )
464 isuppz( 2*wbegin-1 ) = ibegin
465 isuppz( 2*wbegin ) = ibegin
466 w( wbegin ) = w( wbegin ) + sigma
467 work( wbegin ) = w( wbegin )
479 CALL scopy( im, w( wbegin ), 1,
480 $ work( wbegin ), 1 )
485 w(wbegin+i-1) = w(wbegin+i-1)+sigma
496 iwork( iindc1+1 ) = 1
497 iwork( iindc1+2 ) = im
506 IF( idone.LT.im )
THEN
508 IF( ndepth.GT.m )
THEN
519 IF( parity.EQ.0 )
THEN
532 oldfst = iwork( j-1 )
534 IF( ndepth.GT.0 )
THEN
540 IF((dol.EQ.1).AND.(dou.EQ.m))
THEN
543 j = wbegin + oldfst - 1
545 IF(wbegin+oldfst-1.LT.dol)
THEN
548 ELSEIF(wbegin+oldfst-1.GT.dou)
THEN
552 j = wbegin + oldfst - 1
556 d( ibegin+k-1 ) = real( z( ibegin+k-1,
558 l( ibegin+k-1 ) = real( z( ibegin+k-1,
561 d( iend ) = real( z( iend, j ) )
562 sigma = real( z( iend, j+1 ) )
565 CALL claset(
'Full', in, 2, czero, czero,
566 $ z( ibegin, j), ldz )
570 DO 50 j = ibegin, iend-1
572 work( indld-1+j ) = tmp
573 work( indlld-1+j ) = tmp*l( j )
576 IF( ndepth.GT.0 )
THEN
579 p = indexw( wbegin-1+oldfst )
580 q = indexw( wbegin-1+oldlst )
584 offset = indexw( wbegin ) - 1
587 CALL slarrb( in, d( ibegin ),
588 $ work(indlld+ibegin-1),
589 $ p, q, rtol1, rtol2, offset,
590 $ work(wbegin),wgap(wbegin),werr(wbegin),
591 $ work( indwrk ), iwork( iindwk ),
592 $ pivmin, spdiam, in, iinfo )
593 IF( iinfo.NE.0 )
THEN
604 IF( oldfst.GT.1)
THEN
605 wgap( wbegin+oldfst-2 ) =
606 $ max(wgap(wbegin+oldfst-2),
607 $ w(wbegin+oldfst-1)-werr(wbegin+oldfst-1)
608 $ - w(wbegin+oldfst-2)-werr(wbegin+oldfst-2) )
610 IF( wbegin + oldlst -1 .LT. wend )
THEN
611 wgap( wbegin+oldlst-1 ) =
612 $ max(wgap(wbegin+oldlst-1),
613 $ w(wbegin+oldlst)-werr(wbegin+oldlst)
614 $ - w(wbegin+oldlst-1)-werr(wbegin+oldlst-1) )
618 DO 53 j=oldfst,oldlst
619 w(wbegin+j-1) = work(wbegin+j-1)+sigma
625 DO 140 j = oldfst, oldlst
626 IF( j.EQ.oldlst )
THEN
630 ELSE IF ( wgap( wbegin + j -1).GE.
631 $ minrgp* abs( work(wbegin + j -1) ) )
THEN
642 newsiz = newlst - newfst + 1
646 IF((dol.EQ.1).AND.(dou.EQ.m))
THEN
649 newftt = wbegin + newfst - 1
651 IF(wbegin+newfst-1.LT.dol)
THEN
654 ELSEIF(wbegin+newfst-1.GT.dou)
THEN
658 newftt = wbegin + newfst - 1
662 IF( newsiz.GT.1)
THEN
677 IF( newfst.EQ.1 )
THEN
679 $ w(wbegin)-werr(wbegin) - vl )
681 lgap = wgap( wbegin+newfst-2 )
683 rgap = wgap( wbegin+newlst-1 )
692 p = indexw( wbegin-1+newfst )
694 p = indexw( wbegin-1+newlst )
696 offset = indexw( wbegin ) - 1
697 CALL slarrb( in, d(ibegin),
698 $ work( indlld+ibegin-1 ),p,p,
699 $ rqtol, rqtol, offset,
700 $ work(wbegin),wgap(wbegin),
701 $ werr(wbegin),work( indwrk ),
702 $ iwork( iindwk ), pivmin, spdiam,
706 IF((wbegin+newlst-1.LT.dol).OR.
707 $ (wbegin+newfst-1.GT.dou))
THEN
715 idone = idone + newlst - newfst + 1
723 CALL slarrf( in, d( ibegin ), l( ibegin ),
724 $ work(indld+ibegin-1),
725 $ newfst, newlst, work(wbegin),
726 $ wgap(wbegin), werr(wbegin),
727 $ spdiam, lgap, rgap, pivmin, tau,
728 $ work( indin1 ), work( indin2 ),
729 $ work( indwrk ), iinfo )
734 z( ibegin+k-1, newftt ) =
735 $ cmplx( work( indin1+k-1 ), zero )
736 z( ibegin+k-1, newftt+1 ) =
737 $ cmplx( work( indin2+k-1 ), zero )
740 $ cmplx( work( indin1+in-1 ), zero )
741 IF( iinfo.EQ.0 )
THEN
745 z( iend, newftt+1 ) = cmplx( ssigma, zero )
748 DO 116 k = newfst, newlst
750 $ three*eps*abs(work(wbegin+k-1))
751 work( wbegin + k - 1 ) =
752 $ work( wbegin + k - 1) - tau
754 $ four*eps*abs(work(wbegin+k-1))
756 werr( wbegin + k - 1 ) =
757 $ werr( wbegin + k - 1 ) + fudge
769 iwork( k-1 ) = newfst
781 tol = four * log(real(in)) * eps
784 windex = wbegin + k - 1
785 windmn = max(windex - 1,1)
786 windpl = min(windex + 1,m)
787 lambda = work( windex )
790 IF((windex.LT.dol).OR.
791 $ (windex.GT.dou))
THEN
797 left = work( windex ) - werr( windex )
798 right = work( windex ) + werr( windex )
799 indeig = indexw( windex )
814 lgap = eps*max(abs(left),abs(right))
824 rgap = eps*max(abs(left),abs(right))
828 gap = min( lgap, rgap )
829 IF(( k .EQ. 1).OR.(k .EQ. im))
THEN
844 savgap = wgap(windex)
861 itmp1 = iwork( iindr+windex )
862 offset = indexw( wbegin ) - 1
863 CALL slarrb( in, d(ibegin),
864 $ work(indlld+ibegin-1),indeig,indeig,
865 $ zero, two*eps, offset,
866 $ work(wbegin),wgap(wbegin),
867 $ werr(wbegin),work( indwrk ),
868 $ iwork( iindwk ), pivmin, spdiam,
870 IF( iinfo.NE.0 )
THEN
874 lambda = work( windex )
877 iwork( iindr+windex ) = 0
880 CALL clar1v( in, 1, in, lambda, d( ibegin ),
881 $ l( ibegin ), work(indld+ibegin-1),
882 $ work(indlld+ibegin-1),
883 $ pivmin, gaptol, z( ibegin, windex ),
884 $ .NOT.usedbs, negcnt, ztz, mingma,
885 $ iwork( iindr+windex ), isuppz( 2*windex-1 ),
886 $ nrminv, resid, rqcorr, work( indwrk ) )
890 ELSEIF(resid.LT.bstres)
THEN
894 isupmn = min(isupmn,isuppz( 2*windex-1 ))
895 isupmx = max(isupmx,isuppz( 2*windex ))
907 IF( resid.GT.tol*gap .AND. abs( rqcorr ).GT.
908 $ rqtol*abs( lambda ) .AND. .NOT. usedbs)
913 IF(indeig.LE.negcnt)
THEN
922 IF( ( rqcorr*sgndef.GE.zero )
923 $ .AND.( lambda + rqcorr.LE. right)
924 $ .AND.( lambda + rqcorr.GE. left)
928 IF(sgndef.EQ.one)
THEN
947 $ half * (right + left)
950 lambda = lambda + rqcorr
953 $ half * (right-left)
957 IF(right-left.LT.rqtol*abs(lambda))
THEN
962 ELSEIF( iter.LT.maxitr )
THEN
964 ELSEIF( iter.EQ.maxitr )
THEN
973 IF(usedrq .AND. usedbs .AND.
974 $ bstres.LE.resid)
THEN
980 CALL clar1v( in, 1, in, lambda,
981 $ d( ibegin ), l( ibegin ),
982 $ work(indld+ibegin-1),
983 $ work(indlld+ibegin-1),
984 $ pivmin, gaptol, z( ibegin, windex ),
985 $ .NOT.usedbs, negcnt, ztz, mingma,
986 $ iwork( iindr+windex ),
987 $ isuppz( 2*windex-1 ),
988 $ nrminv, resid, rqcorr, work( indwrk ) )
990 work( windex ) = lambda
995 isuppz( 2*windex-1 ) = isuppz( 2*windex-1 )+oldien
996 isuppz( 2*windex ) = isuppz( 2*windex )+oldien
997 zfrom = isuppz( 2*windex-1 )
998 zto = isuppz( 2*windex )
999 isupmn = isupmn + oldien
1000 isupmx = isupmx + oldien
1002 IF(isupmn.LT.zfrom)
THEN
1003 DO 122 ii = isupmn,zfrom-1
1004 z( ii, windex ) = zero
1007 IF(isupmx.GT.zto)
THEN
1008 DO 123 ii = zto+1,isupmx
1009 z( ii, windex ) = zero
1012 CALL csscal( zto-zfrom+1, nrminv,
1013 $ z( zfrom, windex ), 1 )
1016 w( windex ) = lambda+sigma
1025 wgap( windmn ) = max( wgap(windmn),
1026 $ w(windex)-werr(windex)
1027 $ - w(windmn)-werr(windmn) )
1029 IF( windex.LT.wend )
THEN
1030 wgap( windex ) = max( savgap,
1031 $ w( windpl )-werr( windpl )
1032 $ - w( windex )-werr( windex) )