예제 #1
0
파일: xi2d_interp.c 프로젝트: rmredd/HOD_MN
double xi2d_interp(double rs1, double rp1, double rs2, double rp2)
{
  static double **xi2d,rmax,rmin,*rsig,*rpi,**yy2d;
  static int flag=1,n,prev;
  int i,j,ng=20;
  double dx,dy,dlogr,xsum,rs,rp,x;

  if(flag || prev!=RESET_COSMOLOGY)
    {
      two_halo(1,1);

      prev=RESET_COSMOLOGY;
      n=35;
      if(flag)
	{
	  xi2d=dmatrix(1,n,1,n);
	  yy2d=dmatrix(1,n,1,n);
	  rsig=dvector(1,n);
	  rpi=dvector(1,n);
	}
      flag=0;
      rmax=log(40.5);
      rmin=log(0.05);
      dlogr = (rmax-rmin)/(n-1);
      for(i=1;i<=n;++i)
	rsig[i]=rpi[i]=exp((i-1)*dlogr+rmin);
      calc_xi2d(xi2d,n,rmax,rmin);
      splie2(rsig,rpi,xi2d,n,n,yy2d);
    }
  if(rs2<0 && rp2<0)
    {
      splin2(rsig,rpi,xi2d,yy2d,n,n,(rs1),(rp1),&x);
      return(x);
    }
  

  dx=(rs2-rs1)/ng;
  dy=(rp2-rp1)/ng;
  xsum=0;
  for(i=1;i<=ng;++i)
    for(j=1;j<=ng;++j)
      {
	rs=rs1+(i-0.5)*dx;
	rp=rp1+(j-0.5)*dy;
	splin2(rsig,rpi,xi2d,yy2d,n,n,(rs),(rp),&x);
	xsum+=2*dy*rs*dx*(x);
      }
  xsum/=((rs2*rs2-rs1*rs1)*(rp2-rp1));

  return(xsum);

}
예제 #2
0
파일: xi2d_interp.c 프로젝트: rmredd/HOD_MN
/* The angular grid here is set such that
 * it's only used for the small-r SDSS multipoles, i<=3, or r<~ 1 Mpc/h
 */
double xi2d_interp_polar(double rs1, double rs2, double phi1, double phi2)
{
  static double **xi2d,rmax,rmin,*rsig,*rpi,**yy2d;
  static int flag=1,n,prev;
  int i,j,ng=20;
  double dx,dy,dlogr,xsum,rs,rp,x,vsum,dr,dphi,phi,r;

  if(flag || prev!=RESET_COSMOLOGY)
    {
      two_halo(1,1);

      prev=RESET_COSMOLOGY;
      n=15;
      if(flag)
	{
	  xi2d=dmatrix(1,n,1,n);
	  yy2d=dmatrix(1,n,1,n);
	  rsig=dvector(1,n);
	  rpi=dvector(1,n);
	}
      flag=0;
      rmax=log(2.5);
      rmin=log(0.05);
      dlogr = (rmax-rmin)/(n-1);
      for(i=1;i<=n;++i)
	rsig[i]=rpi[i]=exp((i-1)*dlogr+rmin);
      calc_xi2d(xi2d,n,rmax,rmin);
      splie2(rsig,rpi,xi2d,n,n,yy2d);
    }

  rs1 = log(rs1);
  rs2 = log(rs2);
  dr=(rs2-rs1)/ng;
  dphi=(phi2-phi1)/ng;
  xsum=vsum=0;
  for(i=1;i<=ng;++i)
    for(j=1;j<=ng;++j)
      {
	r=exp(rs1+(i-0.5)*dr);
	phi=phi1+(j-0.5)*dphi;
	rp = r*sin(phi);
	rs = r*cos(phi);
	splin2(rsig,rpi,xi2d,yy2d,n,n,(rs),(rp),&x);
	xsum+=sin(phi)*r*r*r*(x);
	vsum+=r*r*r*sin(phi);
      }
  xsum/=vsum;

  return(xsum);

}
예제 #3
0
파일: Spline.cpp 프로젝트: hsxavier/flask
/*** Returns the 2D cubic spline interpolated value ***/
double Spline::operator()(double x1pt, double x2pt) const {
  double result;
  if (dim!=2) error("Spline.operator(): wrong dimension (expected 2) or not initialized.");
  splin2(x1, x2, f2d, d2fdxdy, N1, N2, x1pt, x2pt, &result);
  return result;
}