285 SUBROUTINE dlarrv( N, VL, VU, D, L, PIVMIN,
286 $ ISPLIT, M, DOL, DOU, MINRGP,
287 $ RTOL1, RTOL2, W, WERR, WGAP,
288 $ IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ,
289 $ WORK, IWORK, INFO )
296 INTEGER DOL, DOU, INFO, LDZ, M, N
297 DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU
300 INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ),
301 $ isuppz( * ), iwork( * )
302 DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ),
303 $ WGAP( * ), WORK( * )
304 DOUBLE PRECISION Z( LDZ, * )
311 PARAMETER ( MAXITR = 10 )
312 double precision zero, one, two, three, four, half
313 parameter( zero = 0.0d0, one = 1.0d0,
314 $ two = 2.0d0, three = 3.0d0,
315 $ four = 4.0d0, half = 0.5d0)
318 LOGICAL ESKIP, NEEDBS, STP2II, TRYRQC, USEDBS, USEDRQ
319 INTEGER DONE, I, IBEGIN, IDONE, IEND, II, IINDC1,
320 $ IINDC2, IINDR, IINDWK, IINFO, IM, IN, INDEIG,
321 $ INDLD, INDLLD, INDWRK, ISUPMN, ISUPMX, ITER,
322 $ itmp1, j, jblk, k, miniwsize, minwsize, nclus,
323 $ ndepth, negcnt, newcls, newfst, newftt, newlst,
324 $ newsiz, offset, oldcls, oldfst, oldien, oldlst,
325 $ oldncl, p, parity, q, wbegin, wend, windex,
326 $ windmn, windpl, zfrom, zto, zusedl, zusedu,
328 DOUBLE PRECISION BSTRES, BSTW, EPS, FUDGE, GAP, GAPTOL, GL, GU,
329 $ LAMBDA, LEFT, LGAP, MINGMA, NRMINV, RESID,
330 $ RGAP, RIGHT, RQCORR, RQTOL, SAVGAP, SGNDEF,
331 $ SIGMA, SPDIAM, SSIGMA, TAU, TMP, TOL, ZTZ
334 DOUBLE PRECISION DLAMCH
343 INTRINSIC abs, dble, max, min
352 IF( (n.LE.0).OR.(m.LE.0) )
THEN
391 zusedw = zusedu - zusedl + 1
394 CALL dlaset(
'Full', n, zusedw, zero, zero,
397 eps = dlamch(
'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 ) = one
464 isuppz( 2*wbegin-1 ) = ibegin
465 isuppz( 2*wbegin ) = ibegin
466 w( wbegin ) = w( wbegin ) + sigma
467 work( wbegin ) = w( wbegin )
479 CALL dcopy( 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
555 CALL dcopy( in, z( ibegin, j ), 1, d( ibegin ), 1 )
556 CALL dcopy( in-1, z( ibegin, j+1 ), 1, l( ibegin ),
558 sigma = z( iend, j+1 )
561 CALL dlaset(
'Full', in, 2, zero, zero,
562 $ z( ibegin, j), ldz )
566 DO 50 j = ibegin, iend-1
568 work( indld-1+j ) = tmp
569 work( indlld-1+j ) = tmp*l( j )
572 IF( ndepth.GT.0 )
THEN
575 p = indexw( wbegin-1+oldfst )
576 q = indexw( wbegin-1+oldlst )
580 offset = indexw( wbegin ) - 1
583 CALL dlarrb( in, d( ibegin ),
584 $ work(indlld+ibegin-1),
585 $ p, q, rtol1, rtol2, offset,
586 $ work(wbegin),wgap(wbegin),werr(wbegin),
587 $ work( indwrk ), iwork( iindwk ),
588 $ pivmin, spdiam, in, iinfo )
589 IF( iinfo.NE.0 )
THEN
600 IF( oldfst.GT.1)
THEN
601 wgap( wbegin+oldfst-2 ) =
602 $ max(wgap(wbegin+oldfst-2),
603 $ w(wbegin+oldfst-1)-werr(wbegin+oldfst-1)
604 $ - w(wbegin+oldfst-2)-werr(wbegin+oldfst-2) )
606 IF( wbegin + oldlst -1 .LT. wend )
THEN
607 wgap( wbegin+oldlst-1 ) =
608 $ max(wgap(wbegin+oldlst-1),
609 $ w(wbegin+oldlst)-werr(wbegin+oldlst)
610 $ - w(wbegin+oldlst-1)-werr(wbegin+oldlst-1) )
614 DO 53 j=oldfst,oldlst
615 w(wbegin+j-1) = work(wbegin+j-1)+sigma
621 DO 140 j = oldfst, oldlst
622 IF( j.EQ.oldlst )
THEN
626 ELSE IF ( wgap( wbegin + j -1).GE.
627 $ minrgp* abs( work(wbegin + j -1) ) )
THEN
638 newsiz = newlst - newfst + 1
642 IF((dol.EQ.1).AND.(dou.EQ.m))
THEN
645 newftt = wbegin + newfst - 1
647 IF(wbegin+newfst-1.LT.dol)
THEN
650 ELSEIF(wbegin+newfst-1.GT.dou)
THEN
654 newftt = wbegin + newfst - 1
658 IF( newsiz.GT.1)
THEN
673 IF( newfst.EQ.1 )
THEN
675 $ w(wbegin)-werr(wbegin) - vl )
677 lgap = wgap( wbegin+newfst-2 )
679 rgap = wgap( wbegin+newlst-1 )
688 p = indexw( wbegin-1+newfst )
690 p = indexw( wbegin-1+newlst )
692 offset = indexw( wbegin ) - 1
693 CALL dlarrb( in, d(ibegin),
694 $ work( indlld+ibegin-1 ),p,p,
695 $ rqtol, rqtol, offset,
696 $ work(wbegin),wgap(wbegin),
697 $ werr(wbegin),work( indwrk ),
698 $ iwork( iindwk ), pivmin, spdiam,
702 IF((wbegin+newlst-1.LT.dol).OR.
703 $ (wbegin+newfst-1.GT.dou))
THEN
711 idone = idone + newlst - newfst + 1
719 CALL dlarrf( in, d( ibegin ), l( ibegin ),
720 $ work(indld+ibegin-1),
721 $ newfst, newlst, work(wbegin),
722 $ wgap(wbegin), werr(wbegin),
723 $ spdiam, lgap, rgap, pivmin, tau,
724 $ z(ibegin, newftt),z(ibegin, newftt+1),
725 $ work( indwrk ), iinfo )
726 IF( iinfo.EQ.0 )
THEN
730 z( iend, newftt+1 ) = ssigma
733 DO 116 k = newfst, newlst
735 $ three*eps*abs(work(wbegin+k-1))
736 work( wbegin + k - 1 ) =
737 $ work( wbegin + k - 1) - tau
739 $ four*eps*abs(work(wbegin+k-1))
741 werr( wbegin + k - 1 ) =
742 $ werr( wbegin + k - 1 ) + fudge
754 iwork( k-1 ) = newfst
766 tol = four * log(dble(in)) * eps
769 windex = wbegin + k - 1
770 windmn = max(windex - 1,1)
771 windpl = min(windex + 1,m)
772 lambda = work( windex )
775 IF((windex.LT.dol).OR.
776 $ (windex.GT.dou))
THEN
782 left = work( windex ) - werr( windex )
783 right = work( windex ) + werr( windex )
784 indeig = indexw( windex )
799 lgap = eps*max(abs(left),abs(right))
809 rgap = eps*max(abs(left),abs(right))
813 gap = min( lgap, rgap )
814 IF(( k .EQ. 1).OR.(k .EQ. im))
THEN
829 savgap = wgap(windex)
846 itmp1 = iwork( iindr+windex )
847 offset = indexw( wbegin ) - 1
848 CALL dlarrb( in, d(ibegin),
849 $ work(indlld+ibegin-1),indeig,indeig,
850 $ zero, two*eps, offset,
851 $ work(wbegin),wgap(wbegin),
852 $ werr(wbegin),work( indwrk ),
853 $ iwork( iindwk ), pivmin, spdiam,
855 IF( iinfo.NE.0 )
THEN
859 lambda = work( windex )
862 iwork( iindr+windex ) = 0
865 CALL dlar1v( in, 1, in, lambda, d( ibegin ),
866 $ l( ibegin ), work(indld+ibegin-1),
867 $ work(indlld+ibegin-1),
868 $ pivmin, gaptol, z( ibegin, windex ),
869 $ .NOT.usedbs, negcnt, ztz, mingma,
870 $ iwork( iindr+windex ), isuppz( 2*windex-1 ),
871 $ nrminv, resid, rqcorr, work( indwrk ) )
875 ELSEIF(resid.LT.bstres)
THEN
879 isupmn = min(isupmn,isuppz( 2*windex-1 ))
880 isupmx = max(isupmx,isuppz( 2*windex ))
892 IF( resid.GT.tol*gap .AND. abs( rqcorr ).GT.
893 $ rqtol*abs( lambda ) .AND. .NOT. usedbs)
898 IF(indeig.LE.negcnt)
THEN
907 IF( ( rqcorr*sgndef.GE.zero )
908 $ .AND.( lambda + rqcorr.LE. right)
909 $ .AND.( lambda + rqcorr.GE. left)
913 IF(sgndef.EQ.one)
THEN
932 $ half * (right + left)
935 lambda = lambda + rqcorr
938 $ half * (right-left)
942 IF(right-left.LT.rqtol*abs(lambda))
THEN
947 ELSEIF( iter.LT.maxitr )
THEN
949 ELSEIF( iter.EQ.maxitr )
THEN
958 IF(usedrq .AND. usedbs .AND.
959 $ bstres.LE.resid)
THEN
965 CALL dlar1v( in, 1, in, lambda,
966 $ d( ibegin ), l( ibegin ),
967 $ work(indld+ibegin-1),
968 $ work(indlld+ibegin-1),
969 $ pivmin, gaptol, z( ibegin, windex ),
970 $ .NOT.usedbs, negcnt, ztz, mingma,
971 $ iwork( iindr+windex ),
972 $ isuppz( 2*windex-1 ),
973 $ nrminv, resid, rqcorr, work( indwrk ) )
975 work( windex ) = lambda
980 isuppz( 2*windex-1 ) = isuppz( 2*windex-1 )+oldien
981 isuppz( 2*windex ) = isuppz( 2*windex )+oldien
982 zfrom = isuppz( 2*windex-1 )
983 zto = isuppz( 2*windex )
984 isupmn = isupmn + oldien
985 isupmx = isupmx + oldien
987 IF(isupmn.LT.zfrom)
THEN
988 DO 122 ii = isupmn,zfrom-1
989 z( ii, windex ) = zero
992 IF(isupmx.GT.zto)
THEN
993 DO 123 ii = zto+1,isupmx
994 z( ii, windex ) = zero
997 CALL dscal( zto-zfrom+1, nrminv,
998 $ z( zfrom, windex ), 1 )
1001 w( windex ) = lambda+sigma
1010 wgap( windmn ) = max( wgap(windmn),
1011 $ w(windex)-werr(windex)
1012 $ - w(windmn)-werr(windmn) )
1014 IF( windex.LT.wend )
THEN
1015 wgap( windex ) = max( savgap,
1016 $ w( windpl )-werr( windpl )
1017 $ - w( windex )-werr( windex) )