150 SUBROUTINE slasd4( N, I, D, Z, DELTA, RHO, SIGMA, WORK, INFO )
161 REAL D( * ), DELTA( * ), WORK( * ), Z( * )
168 parameter( maxit = 400 )
169 REAL ZERO, ONE, TWO, THREE, FOUR, EIGHT, TEN
170 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0,
171 $ three = 3.0e+0, four = 4.0e+0, eight = 8.0e+0,
175 LOGICAL ORGATI, SWTCH, SWTCH3, GEOMAVG
176 INTEGER II, IIM1, IIP1, IP1, ITER, J, NITER
177 REAL A, B, C, DELSQ, DELSQ2, SQ2, DPHI, DPSI, DTIIM,
178 $ DTIIP, DTIPSQ, DTISQ, DTNSQ, DTNSQ1, DW, EPS,
179 $ ERRETM, ETA, PHI, PREW, PSI, RHOINV, SGLB,
180 $ SGUB, TAU, TAU2, TEMP, TEMP1, TEMP2, W
183 REAL DD( 3 ), ZZ( 3 )
193 INTRINSIC abs, max, min, sqrt
207 sigma = sqrt( d( 1 )*d( 1 )+rho*z( 1 )*z( 1 ) )
213 CALL slasd5( i, d, z, delta, rho, sigma, work )
219 eps = slamch(
'Epsilon' )
239 temp1 = temp / ( d( n )+sqrt( d( n )*d( n )+temp ) )
241 work( j ) = d( j ) + d( n ) + temp1
242 delta( j ) = ( d( j )-d( n ) ) - temp1
247 psi = psi + z( j )*z( j ) / ( delta( j )*work( j ) )
251 w = c + z( ii )*z( ii ) / ( delta( ii )*work( ii ) ) +
252 $ z( n )*z( n ) / ( delta( n )*work( n ) )
255 temp1 = sqrt( d( n )*d( n )+rho )
256 temp = z( n-1 )*z( n-1 ) / ( ( d( n-1 )+temp1 )*
257 $ ( d( n )-d( n-1 )+rho / ( d( n )+temp1 ) ) ) +
258 $ z( n )*z( n ) / rho
266 delsq = ( d( n )-d( n-1 ) )*( d( n )+d( n-1 ) )
267 a = -c*delsq + z( n-1 )*z( n-1 ) + z( n )*z( n )
268 b = z( n )*z( n )*delsq
270 tau2 = two*b / ( sqrt( a*a+four*b*c )-a )
272 tau2 = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
274 tau = tau2 / ( d( n )+sqrt( d( n )*d( n )+tau2 ) )
281 delsq = ( d( n )-d( n-1 ) )*( d( n )+d( n-1 ) )
282 a = -c*delsq + z( n-1 )*z( n-1 ) + z( n )*z( n )
283 b = z( n )*z( n )*delsq
289 tau2 = two*b / ( sqrt( a*a+four*b*c )-a )
291 tau2 = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
293 tau = tau2 / ( d( n )+sqrt( d( n )*d( n )+tau2 ) )
307 delta( j ) = ( d( j )-d( n ) ) - tau
308 work( j ) = d( j ) + d( n ) + tau
317 temp = z( j ) / ( delta( j )*work( j ) )
318 psi = psi + z( j )*temp
319 dpsi = dpsi + temp*temp
320 erretm = erretm + psi
322 erretm = abs( erretm )
326 temp = z( n ) / ( delta( n )*work( n ) )
329 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv
332 w = rhoinv + phi + psi
336 IF( abs( w ).LE.eps*erretm )
THEN
343 dtnsq1 = work( n-1 )*delta( n-1 )
344 dtnsq = work( n )*delta( n )
345 c = w - dtnsq1*dpsi - dtnsq*dphi
346 a = ( dtnsq+dtnsq1 )*w - dtnsq*dtnsq1*( dpsi+dphi )
351 eta = rho - sigma*sigma
352 ELSE IF( a.GE.zero )
THEN
353 eta = ( a+sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
355 eta = two*b / ( a-sqrt( abs( a*a-four*b*c ) ) )
365 $ eta = -w / ( dpsi+dphi )
370 eta = eta / ( sigma+sqrt( eta+sigma*sigma ) )
375 delta( j ) = delta( j ) - eta
376 work( j ) = work( j ) + eta
385 temp = z( j ) / ( work( j )*delta( j ) )
386 psi = psi + z( j )*temp
387 dpsi = dpsi + temp*temp
388 erretm = erretm + psi
390 erretm = abs( erretm )
394 tau2 = work( n )*delta( n )
398 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv
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 )
440 eta = eta / ( sigma+sqrt( eta+sigma*sigma ) )
445 delta( j ) = delta( j ) - eta
446 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 tau2 = work( n )*delta( n )
468 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv
471 w = rhoinv + phi + psi
490 delsq = ( d( ip1 )-d( i ) )*( d( ip1 )+d( i ) )
492 sq2=sqrt( ( d( i )*d( i )+d( ip1 )*d( ip1 ) ) / two )
493 temp = delsq2 / ( d( i )+sq2 )
495 work( j ) = d( j ) + d( i ) + temp
496 delta( j ) = ( d( j )-d( i ) ) - temp
501 psi = psi + z( j )*z( j ) / ( work( j )*delta( j ) )
505 DO 120 j = n, i + 2, -1
506 phi = phi + z( j )*z( j ) / ( work( j )*delta( j ) )
508 c = rhoinv + psi + phi
509 w = c + z( i )*z( i ) / ( work( i )*delta( i ) ) +
510 $ z( ip1 )*z( ip1 ) / ( work( ip1 )*delta( ip1 ) )
522 sgub = delsq2 / ( d( i )+sq2 )
523 a = c*delsq + z( i )*z( i ) + z( ip1 )*z( ip1 )
524 b = z( i )*z( i )*delsq
526 tau2 = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
528 tau2 = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
535 tau = tau2 / ( d( i )+sqrt( d( i )*d( i )+tau2 ) )
537 IF( (d(i).LE.temp*d(ip1)).AND.(abs(z(i)).LE.temp)
538 $ .AND.(d(i).GT.zero) )
THEN
539 tau = min( ten*d(i), sgub )
550 sglb = -delsq2 / ( d( ii )+sq2 )
552 a = c*delsq - z( i )*z( i ) - z( ip1 )*z( ip1 )
553 b = z( ip1 )*z( ip1 )*delsq
555 tau2 = two*b / ( a-sqrt( abs( a*a+four*b*c ) ) )
557 tau2 = -( a+sqrt( abs( a*a+four*b*c ) ) ) / ( two*c )
564 tau = tau2 / ( d( ip1 )+sqrt( abs( d( ip1 )*d( ip1 )+
568 sigma = d( ii ) + tau
570 work( j ) = d( j ) + d( ii ) + tau
571 delta( j ) = ( d( j )-d( ii ) ) - tau
582 temp = z( j ) / ( work( j )*delta( j ) )
583 psi = psi + z( j )*temp
584 dpsi = dpsi + temp*temp
585 erretm = erretm + psi
587 erretm = abs( erretm )
593 DO 160 j = n, iip1, -1
594 temp = z( j ) / ( work( j )*delta( j ) )
595 phi = phi + z( j )*temp
596 dphi = dphi + temp*temp
597 erretm = erretm + phi
600 w = rhoinv + phi + psi
613 IF( ii.EQ.1 .OR. ii.EQ.n )
616 temp = z( ii ) / ( work( ii )*delta( ii ) )
617 dw = dpsi + dphi + temp*temp
620 erretm = eight*( phi-psi ) + erretm + two*rhoinv
621 $ + three*abs( temp )
626 IF( abs( w ).LE.eps*erretm )
THEN
631 sglb = max( sglb, tau )
633 sgub = min( sgub, tau )
639 IF( .NOT.swtch3 )
THEN
640 dtipsq = work( ip1 )*delta( ip1 )
641 dtisq = work( i )*delta( i )
643 c = w - dtipsq*dw + delsq*( z( i ) / dtisq )**2
645 c = w - dtisq*dw - delsq*( z( ip1 ) / dtipsq )**2
647 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
652 a = z( i )*z( i ) + dtipsq*dtipsq*( dpsi+dphi )
654 a = z( ip1 )*z( ip1 ) + dtisq*dtisq*( dpsi+dphi )
658 ELSE IF( a.LE.zero )
THEN
659 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
661 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
667 dtiim = work( iim1 )*delta( iim1 )
668 dtiip = work( iip1 )*delta( iip1 )
669 temp = rhoinv + psi + phi
671 temp1 = z( iim1 ) / dtiim
673 c = ( temp - dtiip*( dpsi+dphi ) ) -
674 $ ( d( iim1 )-d( iip1 ) )*( d( iim1 )+d( iip1 ) )*temp1
675 zz( 1 ) = z( iim1 )*z( iim1 )
676 IF( dpsi.LT.temp1 )
THEN
677 zz( 3 ) = dtiip*dtiip*dphi
679 zz( 3 ) = dtiip*dtiip*( ( dpsi-temp1 )+dphi )
682 temp1 = z( iip1 ) / dtiip
684 c = ( temp - dtiim*( dpsi+dphi ) ) -
685 $ ( d( iip1 )-d( iim1 ) )*( d( iim1 )+d( iip1 ) )*temp1
686 IF( dphi.LT.temp1 )
THEN
687 zz( 1 ) = dtiim*dtiim*dpsi
689 zz( 1 ) = dtiim*dtiim*( dpsi+( dphi-temp1 ) )
691 zz( 3 ) = z( iip1 )*z( iip1 )
693 zz( 2 ) = z( ii )*z( ii )
695 dd( 2 ) = delta( ii )*work( ii )
697 CALL slaed6( niter, orgati, c, dd, zz, w, eta, info )
706 dtipsq = work( ip1 )*delta( ip1 )
707 dtisq = work( i )*delta( i )
709 c = w - dtipsq*dw + delsq*( z( i ) / dtisq )**2
711 c = w - dtisq*dw - delsq*( z( ip1 ) / dtipsq )**2
713 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
718 a = z( i )*z( i ) + dtipsq*dtipsq*( dpsi+dphi )
720 a = z( ip1 )*z( ip1 ) + dtisq*dtisq*( dpsi+dphi)
724 ELSE IF( a.LE.zero )
THEN
725 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
727 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
741 eta = eta / ( sigma+sqrt( sigma*sigma+eta ) )
743 IF( temp.GT.sgub .OR. temp.LT.sglb )
THEN
745 eta = ( sgub-tau ) / two
747 eta = ( sglb-tau ) / two
750 IF( w .LT. zero )
THEN
751 IF( tau .GT. zero )
THEN
752 eta = sqrt(sgub*tau)-tau
755 IF( sglb .GT. zero )
THEN
756 eta = sqrt(sglb*tau)-tau
768 work( j ) = work( j ) + eta
769 delta( j ) = delta( j ) - eta
778 temp = z( j ) / ( work( j )*delta( j ) )
779 psi = psi + z( j )*temp
780 dpsi = dpsi + temp*temp
781 erretm = erretm + psi
783 erretm = abs( erretm )
789 DO 190 j = n, iip1, -1
790 temp = z( j ) / ( work( j )*delta( j ) )
791 phi = phi + z( j )*temp
792 dphi = dphi + temp*temp
793 erretm = erretm + phi
796 tau2 = work( ii )*delta( ii )
797 temp = z( ii ) / tau2
798 dw = dpsi + dphi + temp*temp
800 w = rhoinv + phi + psi + temp
801 erretm = eight*( phi-psi ) + erretm + two*rhoinv
802 $ + three*abs( temp )
807 IF( -w.GT.abs( prew ) / ten )
810 IF( w.GT.abs( prew ) / ten )
818 DO 230 niter = iter, maxit
822 IF( abs( w ).LE.eps*erretm )
THEN
828 sglb = max( sglb, tau )
830 sgub = min( sgub, tau )
835 IF( .NOT.swtch3 )
THEN
836 dtipsq = work( ip1 )*delta( ip1 )
837 dtisq = work( i )*delta( i )
838 IF( .NOT.swtch )
THEN
840 c = w - dtipsq*dw + delsq*( z( i ) / dtisq )**2
842 c = w - dtisq*dw - delsq*( z( ip1 ) / dtipsq )**2
845 temp = z( ii ) / ( work( ii )*delta( ii ) )
847 dpsi = dpsi + temp*temp
849 dphi = dphi + temp*temp
851 c = w - dtisq*dpsi - dtipsq*dphi
853 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
857 IF( .NOT.swtch )
THEN
859 a = z( i )*z( i ) + dtipsq*dtipsq*
862 a = z( ip1 )*z( ip1 ) +
863 $ dtisq*dtisq*( dpsi+dphi )
866 a = dtisq*dtisq*dpsi + dtipsq*dtipsq*dphi
870 ELSE IF( a.LE.zero )
THEN
871 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
873 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
879 dtiim = work( iim1 )*delta( iim1 )
880 dtiip = work( iip1 )*delta( iip1 )
881 temp = rhoinv + psi + phi
883 c = temp - dtiim*dpsi - dtiip*dphi
884 zz( 1 ) = dtiim*dtiim*dpsi
885 zz( 3 ) = dtiip*dtiip*dphi
888 temp1 = z( iim1 ) / dtiim
890 temp2 = ( d( iim1 )-d( iip1 ) )*
891 $ ( d( iim1 )+d( iip1 ) )*temp1
892 c = temp - dtiip*( dpsi+dphi ) - temp2
893 zz( 1 ) = z( iim1 )*z( iim1 )
894 IF( dpsi.LT.temp1 )
THEN
895 zz( 3 ) = dtiip*dtiip*dphi
897 zz( 3 ) = dtiip*dtiip*( ( dpsi-temp1 )+dphi )
900 temp1 = z( iip1 ) / dtiip
902 temp2 = ( d( iip1 )-d( iim1 ) )*
903 $ ( d( iim1 )+d( iip1 ) )*temp1
904 c = temp - dtiim*( dpsi+dphi ) - temp2
905 IF( dphi.LT.temp1 )
THEN
906 zz( 1 ) = dtiim*dtiim*dpsi
908 zz( 1 ) = dtiim*dtiim*( dpsi+( dphi-temp1 ) )
910 zz( 3 ) = z( iip1 )*z( iip1 )
914 dd( 2 ) = delta( ii )*work( ii )
916 CALL slaed6( niter, orgati, c, dd, zz, w, eta, info )
925 dtipsq = work( ip1 )*delta( ip1 )
926 dtisq = work( i )*delta( i )
927 IF( .NOT.swtch )
THEN
929 c = w - dtipsq*dw + delsq*( z( i )/dtisq )**2
931 c = w - dtisq*dw - delsq*( z( ip1 )/dtipsq )**2
934 temp = z( ii ) / ( work( ii )*delta( ii ) )
936 dpsi = dpsi + temp*temp
938 dphi = dphi + temp*temp
940 c = w - dtisq*dpsi - dtipsq*dphi
942 a = ( dtipsq+dtisq )*w - dtipsq*dtisq*dw
946 IF( .NOT.swtch )
THEN
948 a = z( i )*z( i ) + dtipsq*dtipsq*
951 a = z( ip1 )*z( ip1 ) +
952 $ dtisq*dtisq*( dpsi+dphi )
955 a = dtisq*dtisq*dpsi + dtipsq*dtipsq*dphi
959 ELSE IF( a.LE.zero )
THEN
960 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
962 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
976 eta = eta / ( sigma+sqrt( sigma*sigma+eta ) )
978 IF( temp.GT.sgub .OR. temp.LT.sglb )
THEN
980 eta = ( sgub-tau ) / two
982 eta = ( sglb-tau ) / two
985 IF( w .LT. zero )
THEN
986 IF( tau .GT. zero )
THEN
987 eta = sqrt(sgub*tau)-tau
990 IF( sglb .GT. zero )
THEN
991 eta = sqrt(sglb*tau)-tau
1003 work( j ) = work( j ) + eta
1004 delta( j ) = delta( j ) - eta
1013 temp = z( j ) / ( work( j )*delta( j ) )
1014 psi = psi + z( j )*temp
1015 dpsi = dpsi + temp*temp
1016 erretm = erretm + psi
1018 erretm = abs( erretm )
1024 DO 220 j = n, iip1, -1
1025 temp = z( j ) / ( work( j )*delta( j ) )
1026 phi = phi + z( j )*temp
1027 dphi = dphi + temp*temp
1028 erretm = erretm + phi
1031 tau2 = work( ii )*delta( ii )
1032 temp = z( ii ) / tau2
1033 dw = dpsi + dphi + temp*temp
1035 w = rhoinv + phi + psi + temp
1036 erretm = eight*( phi-psi ) + erretm + two*rhoinv
1037 $ + three*abs( temp )
1040 IF( w*prew.GT.zero .AND. abs( w ).GT.abs( prew ) / ten )
1041 $ swtch = .NOT.swtch