142 SUBROUTINE dlaed4( N, I, D, Z, DELTA, RHO, DLAM, INFO )
150 DOUBLE PRECISION DLAM, RHO
153 DOUBLE PRECISION D( * ), DELTA( * ), Z( * )
160 parameter( maxit = 30 )
161 DOUBLE PRECISION ZERO, ONE, TWO, THREE, FOUR, EIGHT, TEN
162 parameter( zero = 0.0d0, one = 1.0d0, two = 2.0d0,
163 $ three = 3.0d0, four = 4.0d0, eight = 8.0d0,
167 LOGICAL ORGATI, SWTCH, SWTCH3
168 INTEGER II, IIM1, IIP1, IP1, ITER, J, NITER
169 DOUBLE PRECISION A, B, C, DEL, DLTLB, DLTUB, DPHI, DPSI, DW,
170 $ EPS, ERRETM, ETA, MIDPT, PHI, PREW, PSI,
171 $ RHOINV, TAU, TEMP, TEMP1, W
174 DOUBLE PRECISION ZZ( 3 )
177 DOUBLE PRECISION DLAMCH
184 INTRINSIC abs, max, min, sqrt
198 dlam = d( 1 ) + rho*z( 1 )*z( 1 )
203 CALL dlaed5( i, d, z, delta, rho, dlam )
209 eps = dlamch(
'Epsilon' )
229 delta( j ) = ( d( j )-d( i ) ) - midpt
234 psi = psi + z( j )*z( j ) / delta( j )
238 w = c + z( ii )*z( ii ) / delta( ii ) +
239 $ z( n )*z( n ) / delta( n )
242 temp = z( n-1 )*z( n-1 ) / ( d( n )-d( n-1 )+rho ) +
243 $ z( n )*z( n ) / rho
247 del = d( n ) - d( n-1 )
248 a = -c*del + z( n-1 )*z( n-1 ) + z( n )*z( n )
249 b = z( n )*z( n )*del
251 tau = two*b / ( sqrt( a*a+four*b*c )-a )
253 tau = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
263 del = d( n ) - d( n-1 )
264 a = -c*del + z( n-1 )*z( n-1 ) + z( n )*z( n )
265 b = z( n )*z( n )*del
267 tau = two*b / ( sqrt( a*a+four*b*c )-a )
269 tau = ( a+sqrt( a*a+four*b*c ) ) / ( two*c )
280 delta( j ) = ( d( j )-d( i ) ) - tau
289 temp = z( j ) / delta( j )
290 psi = psi + z( j )*temp
291 dpsi = dpsi + temp*temp
292 erretm = erretm + psi
294 erretm = abs( erretm )
298 temp = z( n ) / delta( n )
301 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
302 $ abs( tau )*( dpsi+dphi )
304 w = rhoinv + phi + psi
308 IF( abs( w ).LE.eps*erretm )
THEN
314 dltlb = max( dltlb, tau )
316 dltub = min( dltub, tau )
322 c = w - delta( n-1 )*dpsi - delta( n )*dphi
323 a = ( delta( n-1 )+delta( n ) )*w -
324 $ delta( n-1 )*delta( n )*( dpsi+dphi )
325 b = delta( n-1 )*delta( n )*w
334 eta = -w / ( dpsi+dphi )
335 ELSE IF( a.GE.zero )
THEN
336 eta = ( a+sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
338 eta = two*b / ( a-sqrt( abs( a*a-four*b*c ) ) )
348 $ eta = -w / ( dpsi+dphi )
350 IF( temp.GT.dltub .OR. temp.LT.dltlb )
THEN
352 eta = ( dltub-tau ) / two
354 eta = ( dltlb-tau ) / two
358 delta( j ) = delta( j ) - eta
369 temp = z( j ) / delta( j )
370 psi = psi + z( j )*temp
371 dpsi = dpsi + temp*temp
372 erretm = erretm + psi
374 erretm = abs( erretm )
378 temp = z( n ) / delta( n )
381 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
382 $ abs( tau )*( dpsi+dphi )
384 w = rhoinv + phi + psi
390 DO 90 niter = iter, maxit
394 IF( abs( w ).LE.eps*erretm )
THEN
400 dltlb = max( dltlb, tau )
402 dltub = min( dltub, tau )
407 c = w - delta( n-1 )*dpsi - delta( n )*dphi
408 a = ( delta( n-1 )+delta( n ) )*w -
409 $ delta( n-1 )*delta( n )*( dpsi+dphi )
410 b = delta( n-1 )*delta( n )*w
412 eta = ( a+sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
414 eta = two*b / ( a-sqrt( abs( a*a-four*b*c ) ) )
424 $ eta = -w / ( dpsi+dphi )
426 IF( temp.GT.dltub .OR. temp.LT.dltlb )
THEN
428 eta = ( dltub-tau ) / two
430 eta = ( dltlb-tau ) / two
434 delta( j ) = delta( j ) - eta
445 temp = z( j ) / delta( j )
446 psi = psi + z( j )*temp
447 dpsi = dpsi + temp*temp
448 erretm = erretm + psi
450 erretm = abs( erretm )
454 temp = z( n ) / delta( n )
457 erretm = eight*( -phi-psi ) + erretm - phi + rhoinv +
458 $ abs( tau )*( dpsi+dphi )
460 w = rhoinv + phi + psi
480 del = d( ip1 ) - d( i )
483 delta( j ) = ( d( j )-d( i ) ) - midpt
488 psi = psi + z( j )*z( j ) / delta( j )
492 DO 120 j = n, i + 2, -1
493 phi = phi + z( j )*z( j ) / delta( j )
495 c = rhoinv + psi + phi
496 w = c + z( i )*z( i ) / delta( i ) +
497 $ z( ip1 )*z( ip1 ) / delta( ip1 )
506 a = c*del + z( i )*z( i ) + z( ip1 )*z( ip1 )
507 b = z( i )*z( i )*del
509 tau = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
511 tau = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
522 a = c*del - z( i )*z( i ) - z( ip1 )*z( ip1 )
523 b = z( ip1 )*z( ip1 )*del
525 tau = two*b / ( a-sqrt( abs( a*a+four*b*c ) ) )
527 tau = -( a+sqrt( abs( a*a+four*b*c ) ) ) / ( two*c )
535 delta( j ) = ( d( j )-d( i ) ) - tau
539 delta( j ) = ( d( j )-d( ip1 ) ) - tau
556 temp = z( j ) / delta( j )
557 psi = psi + z( j )*temp
558 dpsi = dpsi + temp*temp
559 erretm = erretm + psi
561 erretm = abs( erretm )
567 DO 160 j = n, iip1, -1
568 temp = z( j ) / delta( j )
569 phi = phi + z( j )*temp
570 dphi = dphi + temp*temp
571 erretm = erretm + phi
574 w = rhoinv + phi + psi
587 IF( ii.EQ.1 .OR. ii.EQ.n )
590 temp = z( ii ) / delta( ii )
591 dw = dpsi + dphi + temp*temp
594 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
595 $ three*abs( temp ) + abs( tau )*dw
599 IF( abs( w ).LE.eps*erretm )
THEN
603 dlam = d( ip1 ) + tau
609 dltlb = max( dltlb, tau )
611 dltub = min( dltub, tau )
617 IF( .NOT.swtch3 )
THEN
619 c = w - delta( ip1 )*dw - ( d( i )-d( ip1 ) )*
620 $ ( z( i ) / delta( i ) )**2
622 c = w - delta( i )*dw - ( d( ip1 )-d( i ) )*
623 $ ( z( ip1 ) / delta( ip1 ) )**2
625 a = ( delta( i )+delta( ip1 ) )*w -
626 $ delta( i )*delta( ip1 )*dw
627 b = delta( i )*delta( ip1 )*w
631 a = z( i )*z( i ) + delta( ip1 )*delta( ip1 )*
634 a = z( ip1 )*z( ip1 ) + delta( i )*delta( i )*
639 ELSE IF( a.LE.zero )
THEN
640 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
642 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
648 temp = rhoinv + psi + phi
650 temp1 = z( iim1 ) / delta( iim1 )
652 c = temp - delta( iip1 )*( dpsi+dphi ) -
653 $ ( d( iim1 )-d( iip1 ) )*temp1
654 zz( 1 ) = z( iim1 )*z( iim1 )
655 zz( 3 ) = delta( iip1 )*delta( iip1 )*
656 $ ( ( dpsi-temp1 )+dphi )
658 temp1 = z( iip1 ) / delta( iip1 )
660 c = temp - delta( iim1 )*( dpsi+dphi ) -
661 $ ( d( iip1 )-d( iim1 ) )*temp1
662 zz( 1 ) = delta( iim1 )*delta( iim1 )*
663 $ ( dpsi+( dphi-temp1 ) )
664 zz( 3 ) = z( iip1 )*z( iip1 )
666 zz( 2 ) = z( ii )*z( ii )
667 CALL dlaed6( niter, orgati, c, delta( iim1 ), zz, w, eta,
682 IF( temp.GT.dltub .OR. temp.LT.dltlb )
THEN
684 eta = ( dltub-tau ) / two
686 eta = ( dltlb-tau ) / two
693 delta( j ) = delta( j ) - eta
702 temp = z( j ) / delta( j )
703 psi = psi + z( j )*temp
704 dpsi = dpsi + temp*temp
705 erretm = erretm + psi
707 erretm = abs( erretm )
713 DO 200 j = n, iip1, -1
714 temp = z( j ) / delta( j )
715 phi = phi + z( j )*temp
716 dphi = dphi + temp*temp
717 erretm = erretm + phi
720 temp = z( ii ) / delta( ii )
721 dw = dpsi + dphi + temp*temp
723 w = rhoinv + phi + psi + temp
724 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
725 $ three*abs( temp ) + abs( tau+eta )*dw
729 IF( -w.GT.abs( prew ) / ten )
732 IF( w.GT.abs( prew ) / ten )
742 DO 240 niter = iter, maxit
746 IF( abs( w ).LE.eps*erretm )
THEN
750 dlam = d( ip1 ) + tau
756 dltlb = max( dltlb, tau )
758 dltub = min( dltub, tau )
763 IF( .NOT.swtch3 )
THEN
764 IF( .NOT.swtch )
THEN
766 c = w - delta( ip1 )*dw -
767 $ ( d( i )-d( ip1 ) )*( z( i ) / delta( i ) )**2
769 c = w - delta( i )*dw - ( d( ip1 )-d( i ) )*
770 $ ( z( ip1 ) / delta( ip1 ) )**2
773 temp = z( ii ) / delta( ii )
775 dpsi = dpsi + temp*temp
777 dphi = dphi + temp*temp
779 c = w - delta( i )*dpsi - delta( ip1 )*dphi
781 a = ( delta( i )+delta( ip1 ) )*w -
782 $ delta( i )*delta( ip1 )*dw
783 b = delta( i )*delta( ip1 )*w
786 IF( .NOT.swtch )
THEN
788 a = z( i )*z( i ) + delta( ip1 )*
789 $ delta( ip1 )*( dpsi+dphi )
791 a = z( ip1 )*z( ip1 ) +
792 $ delta( i )*delta( i )*( dpsi+dphi )
795 a = delta( i )*delta( i )*dpsi +
796 $ delta( ip1 )*delta( ip1 )*dphi
800 ELSE IF( a.LE.zero )
THEN
801 eta = ( a-sqrt( abs( a*a-four*b*c ) ) ) / ( two*c )
803 eta = two*b / ( a+sqrt( abs( a*a-four*b*c ) ) )
809 temp = rhoinv + psi + phi
811 c = temp - delta( iim1 )*dpsi - delta( iip1 )*dphi
812 zz( 1 ) = delta( iim1 )*delta( iim1 )*dpsi
813 zz( 3 ) = delta( iip1 )*delta( iip1 )*dphi
816 temp1 = z( iim1 ) / delta( iim1 )
818 c = temp - delta( iip1 )*( dpsi+dphi ) -
819 $ ( d( iim1 )-d( iip1 ) )*temp1
820 zz( 1 ) = z( iim1 )*z( iim1 )
821 zz( 3 ) = delta( iip1 )*delta( iip1 )*
822 $ ( ( dpsi-temp1 )+dphi )
824 temp1 = z( iip1 ) / delta( iip1 )
826 c = temp - delta( iim1 )*( dpsi+dphi ) -
827 $ ( d( iip1 )-d( iim1 ) )*temp1
828 zz( 1 ) = delta( iim1 )*delta( iim1 )*
829 $ ( dpsi+( dphi-temp1 ) )
830 zz( 3 ) = z( iip1 )*z( iip1 )
833 CALL dlaed6( niter, orgati, c, delta( iim1 ), zz, w,
849 IF( temp.GT.dltub .OR. temp.LT.dltlb )
THEN
851 eta = ( dltub-tau ) / two
853 eta = ( dltlb-tau ) / two
858 delta( j ) = delta( j ) - eta
870 temp = z( j ) / delta( j )
871 psi = psi + z( j )*temp
872 dpsi = dpsi + temp*temp
873 erretm = erretm + psi
875 erretm = abs( erretm )
881 DO 230 j = n, iip1, -1
882 temp = z( j ) / delta( j )
883 phi = phi + z( j )*temp
884 dphi = dphi + temp*temp
885 erretm = erretm + phi
888 temp = z( ii ) / delta( ii )
889 dw = dpsi + dphi + temp*temp
891 w = rhoinv + phi + psi + temp
892 erretm = eight*( phi-psi ) + erretm + two*rhoinv +
893 $ three*abs( temp ) + abs( tau )*dw
894 IF( w*prew.GT.zero .AND. abs( w ).GT.abs( prew ) / ten )
905 dlam = d( ip1 ) + tau