subroutine elipsdp(nt90,n,x,y,a,b,xc,yc,e) c c subroutine for parmila to fit an elipse to a set of phase space c points. c n = no of points c x,y = coordinates c a,b = alpha & beta of ellipse c xc,yc = mean for x and y c e = emittance c e = gamma*x**2 + 2*alpha*x*y + beta*y**2 c note that we do not let the centroid shift from the minimum e value c c-------------------------------------------------------------------------- implicit double precision (a,b,e,f,r,s,x,y) c include 'ucom.h' c dimension x(n),y(n) c-------------------------------------------------------------------------- c* fx=0. fy=0. sx=0. sy=0. sxy=0. c minimize e do 10 i = 1,n fx = fx + x(i) fy = fy + y(i) sx = sx + x(i)*x(i) sxy = sxy + x(i)*y(i) sy = sy + y(i)*y(i) 10 continue xc = fx/n yc = fy/n scx = sx/n - xc*xc scy = sy/n - yc*yc scxy = sxy/n - xc*yc rbm=(scx*scy - scxy*scxy) if(rbm.le.0.) then if(nt90.eq.1) then write(nemit,*) *' no calculation of emittances for (x,xp): negative square root' else write(nemit,*) *' no calculation of emittances for (y,yp): negative square root' endif else e = dsqrt(rbm) a = -scxy/e b = scx/e endif return end c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*