6 #include <gsl/gsl_integration.h> 7 #include <gsl/gsl_errno.h> 8 #include <gsl/gsl_roots.h> 9 #include <gsl/gsl_spline.h> 10 #include <gsl/gsl_sf_bessel.h> 11 #include <gsl/gsl_sf_legendre.h> 23 static int taper_cl(
int n_ell,
double *ell,
double *cl,
double *ell_limits)
26 for(
int i=0;i<n_ell;i++) {
27 if(ell[i]<ell_limits[0] || ell[i]>ell_limits[3]) {
31 if(ell[i]>=ell_limits[1] && ell[i]<=ell_limits[2])
34 if(ell[i]<ell_limits[1])
35 cl[i]*=cos((ell[i]-ell_limits[1])/(ell_limits[1]-ell_limits[0])*
M_PI/2.);
37 if(ell[i]>ell_limits[2])
38 cl[i]*=cos((ell[i]-ell_limits[2])/(ell_limits[3]-ell_limits[2])*
M_PI/2.);
51 int n_ell,
double *ell,
double *cls,
52 int n_theta,
double *theta,
double *wtheta,
53 int corr_type,
int do_taper_cl,
double *taper_cl_limits,
57 double *l_arr,*cl_arr,*th_arr,*wth_arr;
83 double cl_tilt,l_edge,cl_edge;
85 if((cls[n_ell-1]*cls[n_ell-2]<0) || (cls[n_ell-2]==0)) {
90 cl_tilt=log(cls[n_ell-1]/cls[n_ell-2])/log(ell[n_ell-1]/ell[n_ell-2]);
95 cl_arr[i]=cl_edge*
pow(l_arr[i]/l_edge,cl_tilt);
114 free(l_arr); free(cl_arr); free(th_arr);
133 for(i=0;i<n_theta;i++)
137 free(l_arr); free(cl_arr);
138 free(th_arr); free(wth_arr);
179 jbes=gsl_sf_bessel_Jn(p->
i_bessel,x);
185 int n_ell,
double *ell,
double *cls,
186 int n_theta,
double *theta,
double *wtheta,
187 int corr_type,
int *status)
198 cp->
ellf=ell[n_ell-1];
200 cp->
clf=cls[n_ell-1];
227 cp->
tilt0=log10(cls[1]/cls[0])/log10(ell[1]/ell[0]);
230 if(cls[n_ell-2]*cls[n_ell-1]<=0)
234 cp->
tiltf=log10(cls[n_ell-1]/cls[n_ell-2])/log10(ell[n_ell-1]/ell[n_ell-2]);
238 double result,eresult;
241 for(ith=0;ith<n_theta;ith++) {
242 cp->
th=theta[ith]*
M_PI/180;
250 w, &result, &eresult);
251 if(gslstatus != GSL_SUCCESS) {
253 *status |= gslstatus;
255 wtheta[ith]=result/(2*
M_PI);
257 gsl_integration_workspace_free(w);
271 double cth=cos(theta*
M_PI/180);
274 for (j=0;j<=ell_max;j++)
278 gsl_sf_legendre_Pl_array(ell_max,cth,Pl_theta);
279 for (j=0;j<=ell_max;j++)
280 Pl_theta[j]*=(2*j+1);
283 for (j=2;j<=ell_max;j++) {
284 Pl_theta[j]=gsl_sf_legendre_Plm(j,2,cth);
285 Pl_theta[j]*=(2*j+1.)/((j+0.)*(j+1.));
296 int n_ell,
double *ell,
double *cls,
297 int n_theta,
double *theta,
double *wtheta,
298 int corr_type,
int do_taper_cl,
double *taper_cl_limits,
302 double *l_arr,*cl_arr,*Pl_theta;
307 ccl_cosmology_set_status_message(cosmo,
"ccl_correlation.c: CCL does not support full-sky xi+- calcuations.\nhttps://arxiv.org/abs/1702.05301 indicates flat-sky to be sufficient.\n");
336 double cl_tilt,l_edge,cl_edge;
338 if((cls[n_ell-1]*cls[n_ell-2]<0) || (cls[n_ell-2]==0)) {
343 cl_tilt=log(cls[n_ell-1]/cls[n_ell-2])/log(ell[n_ell-1]/ell[n_ell-2]);
344 cl_edge=cls[n_ell-1];
350 cl_arr[i]=cl_edge*
pow(l/l_edge,cl_tilt);
369 for (
int i=0;i<n_theta;i++) {
373 wtheta[i]+=cl_arr[i_L]*Pl_theta[i_L];
392 int n_ell,
double *ell,
double *cls,
393 int n_theta,
double *theta,
double *wtheta,
394 int corr_type,
int do_taper_cl,
double *taper_cl_limits,
int flag_method,
397 switch(flag_method) {
400 do_taper_cl,taper_cl_limits,status);
404 do_taper_cl,taper_cl_limits,status);
428 int n_r,
double *r,
double *xi,
429 int do_taper_pk,
double *taper_pk_limits,
433 double *k_arr,*pk_arr,*r_arr,*xi_arr;
445 pk_arr=malloc(N_ARR*
sizeof(
double));
453 for (i=0; i<N_ARR; i++)
457 taper_cl(N_ARR,k_arr,pk_arr,taper_pk_limits);
459 r_arr=malloc(
sizeof(
double)*N_ARR);
467 xi_arr=malloc(
sizeof(
double)*N_ARR);
469 free(k_arr); free(pk_arr); free(r_arr);
478 pk2xi(N_ARR,k_arr,pk_arr,r_arr,xi_arr);
486 free(k_arr); free(pk_arr);
487 free(r_arr); free(xi_arr);
static void ccl_tracer_corr_bessel(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int *status)
void ccl_correlation(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int flag_method, int *status)
void ccl_correlation_3d(ccl_cosmology *cosmo, double a, int n_r, double *r, double *xi, int do_taper_pk, double *taper_pk_limits, int *status)
void ccl_raise_gsl_warning(int gslstatus, const char *msg,...)
int INTEGRATION_GAUSS_KRONROD_POINTS
#define CCL_ERROR_NOT_IMPLEMENTED
double ccl_nonlin_matter_power(ccl_cosmology *cosmo, double k, double a, int *status)
double * ccl_log_spacing(double xmin, double xmax, int N)
void ccl_check_status(ccl_cosmology *cosmo, int *status)
void fftlog_ComputeXi2D(double bessel_order, int N, const double l[], const double cl[], double th[], double xi[])
ccl_spline_params * ccl_splines
static void ccl_tracer_corr_legendre(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int *status)
static void ccl_compute_legendre_polynomial(int corr_type, double theta, int ell_max, double *Pl_theta)
#define CCL_ERROR_LINSPACE
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
double INTEGRATION_EPSREL
double ccl_spline_eval(double x, SplPar *spl)
static CCL_BEGIN_DECLS double x[111][8]
void ccl_spline_free(SplPar *spl)
static void ccl_tracer_corr_fftlog(ccl_cosmology *cosmo, int n_ell, double *ell, double *cls, int n_theta, double *theta, double *wtheta, int corr_type, int do_taper_cl, double *taper_cl_limits, int *status)
#define CCL_ERROR_INCONSISTENT
float pow(float base, unsigned long int exp)
void pk2xi(int N, const double k[], const double pk[], double r[], double xi[])
static int taper_cl(int n_ell, double *ell, double *cl, double *ell_limits)
static double corr_bessel_integrand(double l, void *params)
static double w[2][28][111]
SplPar * ccl_spline_init(int n, double *x, double *y, double y0, double yf)