154 SUBROUTINE slasd4( N, I, D, Z, DELTA, RHO, SIGMA, WORK, INFO )
166 REAL d( * ), delta( * ), work( * ), z( * )
173 parameter( maxit = 64 )
174 REAL zero, one, two, three, four, eight, ten
175 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0,
176 $ three = 3.0e+0, four = 4.0e+0, eight = 8.0e+0,
180 LOGICAL orgati, swtch, swtch3
181 INTEGER ii, iim1, iip1, ip1, iter, j, niter
182 REAL a, b, c, delsq, delsq2, dphi, dpsi, dtiim,
183 $ dtiip, dtipsq, dtisq, dtnsq, dtnsq1, dw, eps,
184 $ erretm, eta, phi, prew, psi, rhoinv, sg2lb,
185 $ sg2ub, tau, temp, temp1, temp2, w
188 REAL dd( 3 ), zz( 3 )
198 INTRINSIC abs, max, min, sqrt
212 sigma = sqrt( d( 1 )*d( 1 )+rho*z( 1 )*z( 1 ) )
218 CALL
slasd5( i, d, z, delta, rho, sigma, work )
243 temp1 = temp / ( d( n )+sqrt( d( n )*d( n )+temp ) )
245 work( j ) = d( j ) + d( n ) + temp1
246 delta( j ) = ( d( j )-d( n ) ) - temp1
251 psi = psi + z( j )*z( j ) / ( delta( j )*work( j ) )
255 w = c + z( ii )*z( ii ) / ( delta( ii )*work( ii ) ) +
256 $ z( n )*z( n ) / ( delta( n )*work( n ) )
259 temp1 = sqrt( d( n )*d( n )+rho )
260 temp = z( n-1 )*z( n-1 ) / ( ( d( n-1 )+temp1 )*
261 $ ( d( n )-d( n-1 )+rho / ( d( n )+temp1 ) ) ) +
262 $ z( n )*z( n ) / rho
270 delsq = ( d( n )-d( n-1 ) )*( d( n )+d( n-1 ) )
271 a = -c*delsq + z( n-1 )*z( n-1 ) + z( n )*z( n )
272 b = z( n )*z( n )*delsq
274 tau = two*b / ( sqrt( a*a+four*b*c )-a )
276 tau = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
284 delsq = ( d( n )-d( n-1 ) )*( d( n )+d( n-1 ) )
285 a = -c*delsq + z( n-1 )*z( n-1 ) + z( n )*z( n )
286 b = z( n )*z( n )*delsq
292 tau = two*b / ( sqrt( a*a+four*b*c )-a )
294 tau = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
304 eta = tau / ( d( n )+sqrt( d( n )*d( n )+tau ) )
308 delta( j ) = ( d( j )-d( i ) ) - eta
309 work( j ) = d( j ) + d( i ) + eta
318 temp = z( j ) / ( delta( j )*work( j ) )
319 psi = psi + z( j )*temp
320 dpsi = dpsi + temp*temp
321 erretm = erretm + psi
323 erretm = abs( erretm )
327 temp = z( n ) / ( delta( n )*work( n ) )
330 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
331 $ abs( tau )*( dpsi+dphi )
333 w = rhoinv + phi + psi
337 IF( abs( w ).LE.eps*erretm )
THEN
344 dtnsq1 = work( n-1 )*delta( n-1 )
345 dtnsq = work( n )*delta( n )
346 c = w - dtnsq1*dpsi - dtnsq*dphi
347 a = ( dtnsq+dtnsq1 )*w - dtnsq*dtnsq1*( dpsi+dphi )
352 eta = rho - sigma*sigma
353 ELSE IF( a.GE.zero )
THEN
354 eta = ( a+sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
356 eta = two*b / ( a-sqrt( abs( a*a-four*b*c ) ) )
366 $ eta = -w / ( dpsi+dphi )
372 eta = eta / ( sigma+sqrt( eta+sigma*sigma ) )
374 delta( j ) = delta( j ) - eta
375 work( j ) = work( j ) + eta
386 temp = z( j ) / ( work( j )*delta( j ) )
387 psi = psi + z( j )*temp
388 dpsi = dpsi + temp*temp
389 erretm = erretm + psi
391 erretm = abs( erretm )
395 temp = z( n ) / ( work( n )*delta( n ) )
398 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
399 $ abs( tau )*( dpsi+dphi )
401 w = rhoinv + phi + psi
407 DO 90 niter = iter, maxit
411 IF( abs( w ).LE.eps*erretm )
THEN
417 dtnsq1 = work( n-1 )*delta( n-1 )
418 dtnsq = work( n )*delta( n )
419 c = w - dtnsq1*dpsi - dtnsq*dphi
420 a = ( dtnsq+dtnsq1 )*w - dtnsq1*dtnsq*( dpsi+dphi )
423 eta = ( a+sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
425 eta = two*b / ( a-sqrt( abs( a*a-four*b*c ) ) )
435 $ eta = -w / ( dpsi+dphi )
441 eta = eta / ( sigma+sqrt( eta+sigma*sigma ) )
443 delta( j ) = delta( j ) - eta
444 work( j ) = work( j ) + eta
455 temp = z( j ) / ( work( j )*delta( j ) )
456 psi = psi + z( j )*temp
457 dpsi = dpsi + temp*temp
458 erretm = erretm + psi
460 erretm = abs( erretm )
464 temp = z( n ) / ( work( n )*delta( n ) )
467 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
468 $ abs( tau )*( dpsi+dphi )
470 w = rhoinv + phi + psi
489 delsq = ( d( ip1 )-d( i ) )*( d( ip1 )+d( i ) )
491 temp = delsq2 / ( d( i )+sqrt( d( i )*d( i )+delsq2 ) )
493 work( j ) = d( j ) + d( i ) + temp
494 delta( j ) = ( d( j )-d( i ) ) - temp
499 psi = psi + z( j )*z( j ) / ( work( j )*delta( j ) )
503 DO 120 j = n, i + 2, -1
504 phi = phi + z( j )*z( j ) / ( work( j )*delta( j ) )
506 c = rhoinv + psi + phi
507 w = c + z( i )*z( i ) / ( work( i )*delta( i ) ) +
508 $ z( ip1 )*z( ip1 ) / ( work( ip1 )*delta( ip1 ) )
519 a = c*delsq + z( i )*z( i ) + z( ip1 )*z( ip1 )
520 b = z( i )*z( i )*delsq
522 tau = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
524 tau = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
531 eta = tau / ( d( i )+sqrt( d( i )*d( i )+tau ) )
541 a = c*delsq - z( i )*z( i ) - z( ip1 )*z( ip1 )
542 b = z( ip1 )*z( ip1 )*delsq
544 tau = two*b / ( a-sqrt( abs( a*a+four*b*c ) ) )
546 tau = -( a+sqrt( abs( a*a+four*b*c ) ) ) / ( two*c )
553 eta = tau / ( d( ip1 )+sqrt( abs( d( ip1 )*d( ip1 )+
561 work( j ) = d( j ) + d( i ) + eta
562 delta( j ) = ( d( j )-d( i ) ) - eta
566 sigma = d( ip1 ) + eta
568 work( j ) = d( j ) + d( ip1 ) + eta
569 delta( j ) = ( d( j )-d( ip1 ) ) - eta
581 temp = z( j ) / ( work( j )*delta( j ) )
582 psi = psi + z( j )*temp
583 dpsi = dpsi + temp*temp
584 erretm = erretm + psi
586 erretm = abs( erretm )
592 DO 160 j = n, iip1, -1
593 temp = z( j ) / ( work( j )*delta( j ) )
594 phi = phi + z( j )*temp
595 dphi = dphi + temp*temp
596 erretm = erretm + phi
599 w = rhoinv + phi + psi
612 IF( ii.EQ.1 .OR. ii.EQ.n )
615 temp = z( ii ) / ( work( ii )*delta( ii ) )
616 dw = dpsi + dphi + temp*temp
619 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
620 $ three*abs( temp ) + abs( tau )*dw
624 IF( abs( w ).LE.eps*erretm )
THEN
629 sg2lb = max( sg2lb, tau )
631 sg2ub = min( sg2ub, tau )
637 IF( .NOT.swtch3 )
THEN
638 dtipsq = work( ip1 )*delta( ip1 )
639 dtisq = work( i )*delta( i )
641 c = w - dtipsq*dw + delsq*( z( i ) / dtisq )**2
643 c = w - dtisq*dw - delsq*( z( ip1 ) / dtipsq )**2
645 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
650 a = z( i )*z( i ) + dtipsq*dtipsq*( dpsi+dphi )
652 a = z( ip1 )*z( ip1 ) + dtisq*dtisq*( dpsi+dphi )
656 ELSE IF( a.LE.zero )
THEN
657 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
659 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
665 dtiim = work( iim1 )*delta( iim1 )
666 dtiip = work( iip1 )*delta( iip1 )
667 temp = rhoinv + psi + phi
669 temp1 = z( iim1 ) / dtiim
671 c = ( temp - dtiip*( dpsi+dphi ) ) -
672 $ ( d( iim1 )-d( iip1 ) )*( d( iim1 )+d( iip1 ) )*temp1
673 zz( 1 ) = z( iim1 )*z( iim1 )
674 IF( dpsi.LT.temp1 )
THEN
675 zz( 3 ) = dtiip*dtiip*dphi
677 zz( 3 ) = dtiip*dtiip*( ( dpsi-temp1 )+dphi )
680 temp1 = z( iip1 ) / dtiip
682 c = ( temp - dtiim*( dpsi+dphi ) ) -
683 $ ( d( iip1 )-d( iim1 ) )*( d( iim1 )+d( iip1 ) )*temp1
684 IF( dphi.LT.temp1 )
THEN
685 zz( 1 ) = dtiim*dtiim*dpsi
687 zz( 1 ) = dtiim*dtiim*( dpsi+( dphi-temp1 ) )
689 zz( 3 ) = z( iip1 )*z( iip1 )
691 zz( 2 ) = z( ii )*z( ii )
693 dd( 2 ) = delta( ii )*work( ii )
695 CALL
slaed6( niter, orgati, c, dd, zz, w, eta, info )
709 temp1 = work( i )*delta( i )
712 temp1 = work( ip1 )*delta( ip1 )
715 IF( temp.GT.sg2ub .OR. temp.LT.sg2lb )
THEN
717 eta = ( sg2ub-tau ) / two
719 eta = ( sg2lb-tau ) / two
724 eta = eta / ( sigma+sqrt( sigma*sigma+eta ) )
730 work( j ) = work( j ) + eta
731 delta( j ) = delta( j ) - eta
740 temp = z( j ) / ( work( j )*delta( j ) )
741 psi = psi + z( j )*temp
742 dpsi = dpsi + temp*temp
743 erretm = erretm + psi
745 erretm = abs( erretm )
751 DO 190 j = n, iip1, -1
752 temp = z( j ) / ( work( j )*delta( j ) )
753 phi = phi + z( j )*temp
754 dphi = dphi + temp*temp
755 erretm = erretm + phi
758 temp = z( ii ) / ( work( ii )*delta( ii ) )
759 dw = dpsi + dphi + temp*temp
761 w = rhoinv + phi + psi + temp
762 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
763 $ three*abs( temp ) + abs( tau )*dw
766 sg2lb = max( sg2lb, tau )
768 sg2ub = min( sg2ub, tau )
773 IF( -w.GT.abs( prew ) / ten )
776 IF( w.GT.abs( prew ) / ten )
784 DO 230 niter = iter, maxit
788 IF( abs( w ).LE.eps*erretm )
THEN
794 IF( .NOT.swtch3 )
THEN
795 dtipsq = work( ip1 )*delta( ip1 )
796 dtisq = work( i )*delta( i )
797 IF( .NOT.swtch )
THEN
799 c = w - dtipsq*dw + delsq*( z( i ) / dtisq )**2
801 c = w - dtisq*dw - delsq*( z( ip1 ) / dtipsq )**2
804 temp = z( ii ) / ( work( ii )*delta( ii ) )
806 dpsi = dpsi + temp*temp
808 dphi = dphi + temp*temp
810 c = w - dtisq*dpsi - dtipsq*dphi
812 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
816 IF( .NOT.swtch )
THEN
818 a = z( i )*z( i ) + dtipsq*dtipsq*
821 a = z( ip1 )*z( ip1 ) +
822 $ dtisq*dtisq*( dpsi+dphi )
825 a = dtisq*dtisq*dpsi + dtipsq*dtipsq*dphi
829 ELSE IF( a.LE.zero )
THEN
830 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
832 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
838 dtiim = work( iim1 )*delta( iim1 )
839 dtiip = work( iip1 )*delta( iip1 )
840 temp = rhoinv + psi + phi
842 c = temp - dtiim*dpsi - dtiip*dphi
843 zz( 1 ) = dtiim*dtiim*dpsi
844 zz( 3 ) = dtiip*dtiip*dphi
847 temp1 = z( iim1 ) / dtiim
849 temp2 = ( d( iim1 )-d( iip1 ) )*
850 $ ( d( iim1 )+d( iip1 ) )*temp1
851 c = temp - dtiip*( dpsi+dphi ) - temp2
852 zz( 1 ) = z( iim1 )*z( iim1 )
853 IF( dpsi.LT.temp1 )
THEN
854 zz( 3 ) = dtiip*dtiip*dphi
856 zz( 3 ) = dtiip*dtiip*( ( dpsi-temp1 )+dphi )
859 temp1 = z( iip1 ) / dtiip
861 temp2 = ( d( iip1 )-d( iim1 ) )*
862 $ ( d( iim1 )+d( iip1 ) )*temp1
863 c = temp - dtiim*( dpsi+dphi ) - temp2
864 IF( dphi.LT.temp1 )
THEN
865 zz( 1 ) = dtiim*dtiim*dpsi
867 zz( 1 ) = dtiim*dtiim*( dpsi+( dphi-temp1 ) )
869 zz( 3 ) = z( iip1 )*z( iip1 )
873 dd( 2 ) = delta( ii )*work( ii )
875 CALL
slaed6( niter, orgati, c, dd, zz, w, eta, info )
889 temp1 = work( i )*delta( i )
892 temp1 = work( ip1 )*delta( ip1 )
895 IF( temp.GT.sg2ub .OR. temp.LT.sg2lb )
THEN
897 eta = ( sg2ub-tau ) / two
899 eta = ( sg2lb-tau ) / two
904 eta = eta / ( sigma+sqrt( sigma*sigma+eta ) )
908 work( j ) = work( j ) + eta
909 delta( j ) = delta( j ) - eta
920 temp = z( j ) / ( work( j )*delta( j ) )
921 psi = psi + z( j )*temp
922 dpsi = dpsi + temp*temp
923 erretm = erretm + psi
925 erretm = abs( erretm )
931 DO 220 j = n, iip1, -1
932 temp = z( j ) / ( work( j )*delta( j ) )
933 phi = phi + z( j )*temp
934 dphi = dphi + temp*temp
935 erretm = erretm + phi
938 temp = z( ii ) / ( work( ii )*delta( ii ) )
939 dw = dpsi + dphi + temp*temp
941 w = rhoinv + phi + psi + temp
942 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
943 $ three*abs( temp ) + abs( tau )*dw
944 IF( w*prew.GT.zero .AND. abs( w ).GT.abs( prew ) / ten )
948 sg2lb = max( sg2lb, tau )
950 sg2ub = min( sg2ub, tau )