Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
ccl_cls.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CCL_ClTracer
 
struct  CCL_ClWorkspace
 

Typedefs

typedef enum ccl_tracer_t ccl_tracer_t
 
typedef enum ccl_tracer_func_t ccl_tracer_func_t
 

Enumerations

enum  ccl_tracer_t { ccl_number_counts_tracer = 1, ccl_weak_lensing_tracer = 2, ccl_cmb_lensing_tracer = 3 }
 
enum  ccl_tracer_func_t {
  ccl_trf_nz = 201, ccl_trf_bz = 202, ccl_trf_sz = 203, ccl_trf_rf = 204,
  ccl_trf_ba = 205, ccl_trf_wL = 206, ccl_trf_wM = 207
}
 

Functions

CCL_ClTracerccl_cl_tracer (ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
 
CCL_ClTracerccl_cl_tracer_number_counts (ccl_cosmology *cosmo, int has_rsd, int has_magnification, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int *status)
 
CCL_ClTracerccl_cl_tracer_number_counts_simple (ccl_cosmology *cosmo, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int *status)
 
CCL_ClTracerccl_cl_tracer_lensing (ccl_cosmology *cosmo, int has_alignment, int nz_n, double *z_n, double *n, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, int *status)
 
CCL_ClTracerccl_cl_tracer_lensing_simple (ccl_cosmology *cosmo, int nz_n, double *z_n, double *n, int *status)
 
CCL_ClTracerccl_cl_tracer_cmblens (ccl_cosmology *cosmo, double z_source, int *status)
 
void ccl_cl_tracer_free (CCL_ClTracer *clt)
 
double ccl_get_tracer_fa (ccl_cosmology *cosmo, CCL_ClTracer *clt, double a, int func_code, int *status)
 
int ccl_get_tracer_fas (ccl_cosmology *cosmo, CCL_ClTracer *clt, int na, double *a, double *fa, int func_code, int *status)
 
CCL_ClWorkspaceccl_cl_workspace_new (int lmax, int l_limber, double l_logstep, int l_linstep, int *status)
 
CCL_ClWorkspaceccl_cl_workspace_new_limber (int lmax, double l_logstep, int l_linstep, int *status)
 
void ccl_cl_workspace_free (CCL_ClWorkspace *w)
 
void ccl_angular_cls (ccl_cosmology *cosmo, CCL_ClWorkspace *w, CCL_ClTracer *clt1, CCL_ClTracer *clt2, int nl_out, int *l, double *cl, int *status)
 

Typedef Documentation

typedef enum ccl_tracer_t ccl_tracer_t

Enumeration Type Documentation

Enumerator
ccl_trf_nz 
ccl_trf_bz 
ccl_trf_sz 
ccl_trf_rf 
ccl_trf_ba 
ccl_trf_wL 
ccl_trf_wM 

Definition at line 12 of file ccl_cls.h.

13 {
14  ccl_trf_nz = 201, //Redshift distribution
15  ccl_trf_bz = 202, //Clustering bias
16  ccl_trf_sz = 203, //Magnification bias
17  ccl_trf_rf = 204, //Aligned fraction
18  ccl_trf_ba = 205, //Alignment bias
19  ccl_trf_wL = 206, //Weak lensing window function
20  ccl_trf_wM = 207, //Magnification window function
ccl_tracer_func_t
Definition: ccl_cls.h:12
Enumerator
ccl_number_counts_tracer 
ccl_weak_lensing_tracer 
ccl_cmb_lensing_tracer 

Definition at line 5 of file ccl_cls.h.

Function Documentation

void ccl_angular_cls ( ccl_cosmology cosmo,
CCL_ClWorkspace w,
CCL_ClTracer clt1,
CCL_ClTracer clt2,
int  nl_out,
int *  l,
double cl,
int *  status 
)

Computes limber or non-limber power spectrum for two different tracers

Parameters
cosmoCosmological parameters
wa ClWorkspace
clt1a Cltracer
clt2a Cltracer
nl_outthe maximum to ell to compute C_ell
lan array of ell values
clthe C_ell output array
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
void

Definition at line 943 of file ccl_cls.c.

References ccl_angular_cl_native(), ccl_check_status(), ccl_cosmology_set_status_message(), CCL_ERROR_MEMORY, CCL_ERROR_SPLINE_EV, ccl_spline_eval(), ccl_spline_free(), ccl_spline_init(), ccl_weak_lensing_tracer, CCL_ClTracer::has_magnification, CCL_ClWorkspace::l_arr, CCL_ClWorkspace::l_limber, CCL_ClWorkspace::lmax, CCL_ClWorkspace::n_ls, and CCL_ClTracer::tracer_type.

Referenced by compare_cls(), compare_corr(), main(), and test_angpow_precision().

946 {
947  int ii,do_angpow;
948  double *l_nodes,*cl_nodes;
949  SplPar *spcl_nodes;
950 
951  //First check if ell range is within workspace
952  for(ii=0;ii<nl_out;ii++) {
953  if(l_out[ii]>w->lmax) {
954  *status=CCL_ERROR_SPLINE_EV;
955  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: ccl_angular_cls(); "
956  "requested l beyond range allowed by workspace\n");
957  return;
958  }
959  }
960 
961  if(*status==0) {
962  //Allocate array for power spectrum at interpolation nodes
963  l_nodes=(double *)malloc(w->n_ls*sizeof(double));
964  if(l_nodes==NULL) {
965  *status=CCL_ERROR_MEMORY;
966  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: ccl_angular_cls(); memory allocation\n");
967  }
968  }
969 
970  if(*status==0) {
971  cl_nodes=(double *)malloc(w->n_ls*sizeof(double));
972  if(cl_nodes==NULL) {
973  *status=CCL_ERROR_MEMORY;
974  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: ccl_cl_angular_cls(); memory allocation\n");
975  }
976  }
977 
978  if(*status==0) {
979  for(ii=0;ii<w->n_ls;ii++)
980  l_nodes[ii]=(double)(w->l_arr[ii]);
981 
982  do_angpow=0;
983  //Now check if angpow is needed at all
984  if(w->l_limber>0) {
985  for(ii=0;ii<w->n_ls;ii++) {
986  if(w->l_arr[ii]<=w->l_limber)
987  do_angpow=1;
988  }
989  }
990 #ifndef HAVE_ANGPOW
991  do_angpow=0;
992 #endif //HAVE_ANGPOW
993 
994  //Resort to Limber if we have lensing (this will hopefully only be temporary)
996  clt1->has_magnification || clt2->has_magnification) {
997  do_angpow=0;
998  }
999 
1000  //Use angpow if non-limber is needed
1001  if(do_angpow)
1002  ccl_angular_cls_angpow(cosmo,w,clt1,clt2,cl_nodes,status);
1003  ccl_check_status(cosmo,status);
1004  }
1005 
1006  if(*status==0) {
1007  //Compute limber nodes
1008  for(ii=0;ii<w->n_ls;ii++) {
1009  if((!do_angpow) || (w->l_arr[ii]>w->l_limber))
1010  cl_nodes[ii]=ccl_angular_cl_native(cosmo,w,ii,clt1,clt2,status);
1011  }
1012 
1013  //Interpolate into ells requested by user
1014  spcl_nodes=ccl_spline_init(w->n_ls,l_nodes,cl_nodes,0,0);
1015  if(spcl_nodes==NULL) {
1016  *status=CCL_ERROR_MEMORY;
1017  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: ccl_cl_angular_cls(); memory allocation\n");
1018  }
1019  }
1020 
1021  if(*status==0) {
1022  for(ii=0;ii<nl_out;ii++)
1023  cl_out[ii]=ccl_spline_eval((double)(l_out[ii]),spcl_nodes);
1024  }
1025 
1026  //Cleanup
1027  ccl_spline_free(spcl_nodes);
1028  free(cl_nodes);
1029  free(l_nodes);
1030 }
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
int has_magnification
Definition: ccl_cls.h:40
#define CCL_ERROR_SPLINE_EV
Definition: ccl_error.h:14
static double ccl_angular_cl_native(ccl_cosmology *cosmo, CCL_ClWorkspace *cw, int il, CCL_ClTracer *clt1, CCL_ClTracer *clt2, int *status)
Definition: ccl_cls.c:889
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double ccl_spline_eval(double x, SplPar *spl)
Definition: ccl_utils.c:170
void ccl_spline_free(SplPar *spl)
Definition: ccl_utils.c:316
int tracer_type
Definition: ccl_cls.h:32
#define CCL_ERROR_MEMORY
Definition: ccl_error.h:10
SplPar * ccl_spline_init(int n, double *x, double *y, double y0, double yf)
Definition: ccl_utils.c:146
CCL_ClTracer* ccl_cl_tracer ( ccl_cosmology cosmo,
int  tracer_type,
int  has_rsd,
int  has_magnification,
int  has_intrinsic_alignment,
int  nz_n,
double z_n,
double n,
int  nz_b,
double z_b,
double b,
int  nz_s,
double z_s,
double s,
int  nz_ba,
double z_ba,
double ba,
int  nz_rf,
double z_rf,
double rf,
double  z_source,
int *  status 
)

Constructor for a ClTracer.

Parameters
Tracer_typepass ccl_number_counts_tracer (number counts), ccl_weak_lensing_tracer (weak lensing) or ccl_cmb_lensing_tracer (CMB lensing)
has_rsdSet to 1 if you want to compute the RSD contribution to number counts (0 otherwise)
has_magnificationSet to 1 if you want to compute the magnification contribution to number counts (0 otherwise)
has_intrinsic_alignmentSet to 1 if you want to compute the IA contribution to shear
nz_nNumber of bins in z_n and n
z_nRedshifts for each redshift interval of n
nNumber count of objects per redshift interval (Note: arbitrary normalization - renormalized inside)
nz_bNumber of bins in z_b and b
z_bRedshifts for each redshift interval of b
bClustering bias in each redshift bin
nz_sNumber of bins in z_s and s
z_sRedshifts for each redshift interval of s
sMagnification bias in each redshift bin
nz_baNumber of bins in z_ba and ba
z_baRedshifts for each redshift interval of ba
baAlignment bias in each redshift bin
nz_rfNumber of bins in z_f and f
z_rfRedshifts for each redshift interval of rf
rfAligned red fraction in each redshift bin
z_sourceRedshift of source plane for CMB lensing (z~1100 for CMB lensing).
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 575 of file ccl_cls.c.

References ccl_check_status(), and cl_tracer().

Referenced by ccl_cl_tracer_cmblens(), ccl_cl_tracer_lensing(), ccl_cl_tracer_lensing_simple(), ccl_cl_tracer_number_counts(), and ccl_cl_tracer_number_counts_simple().

583 {
584  CCL_ClTracer *clt=cl_tracer(cosmo,tracer_type,has_rsd,has_magnification,has_intrinsic_alignment,
585  nz_n,z_n,n,nz_b,z_b,b,nz_s,z_s,s,
586  nz_ba,z_ba,ba,nz_rf,z_rf,rf,z_source,status);
587  ccl_check_status(cosmo,status);
588  return clt;
589 }
void ccl_check_status(ccl_cosmology *cosmo, int *status)
Definition: ccl_error.c:88
static CCL_ClTracer * cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:515
CCL_ClTracer* ccl_cl_tracer_cmblens ( ccl_cosmology cosmo,
double  z_source,
int *  status 
)

Simplified constructor for a CMB lensing ClTracer.

Parameters
z_sourceRedshift of source plane (z~1100 for CMB lensing).
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 614 of file ccl_cls.c.

References ccl_cl_tracer(), and ccl_cmb_lensing_tracer.

Referenced by compare_cls(), and main().

615 {
617  0,0,0,
618  0,NULL,NULL,0,NULL,NULL,0,NULL,NULL,
619  0,NULL,NULL,0,NULL,NULL,z_source,status);
620 }
CCL_ClTracer * ccl_cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:575
void ccl_cl_tracer_free ( CCL_ClTracer clt)

Destructor for a Cltracer

Parameters
clta Cltracer
Returns
void

Definition at line 592 of file ccl_cls.c.

References ccl_number_counts_tracer, ccl_spline_free(), ccl_weak_lensing_tracer, CCL_ClTracer::has_intrinsic_alignment, CCL_ClTracer::has_magnification, CCL_ClTracer::spl_ba, CCL_ClTracer::spl_bz, CCL_ClTracer::spl_nz, CCL_ClTracer::spl_rf, CCL_ClTracer::spl_sz, CCL_ClTracer::spl_wL, CCL_ClTracer::spl_wM, and CCL_ClTracer::tracer_type.

Referenced by compare_cls(), main(), and test_angpow_precision().

593 {
595  ccl_spline_free(clt->spl_nz);
596 
598  ccl_spline_free(clt->spl_bz);
599  if(clt->has_magnification) {
600  ccl_spline_free(clt->spl_sz);
601  ccl_spline_free(clt->spl_wM);
602  }
603  }
604  else if(clt->tracer_type==ccl_weak_lensing_tracer) {
605  ccl_spline_free(clt->spl_wL);
606  if(clt->has_intrinsic_alignment) {
607  ccl_spline_free(clt->spl_ba);
608  ccl_spline_free(clt->spl_rf);
609  }
610  }
611  free(clt);
612 }
SplPar * spl_rf
Definition: ccl_cls.h:45
int has_intrinsic_alignment
Definition: ccl_cls.h:41
int has_magnification
Definition: ccl_cls.h:40
SplPar * spl_nz
Definition: ccl_cls.h:42
SplPar * spl_bz
Definition: ccl_cls.h:43
SplPar * spl_sz
Definition: ccl_cls.h:44
SplPar * spl_wL
Definition: ccl_cls.h:47
void ccl_spline_free(SplPar *spl)
Definition: ccl_utils.c:316
int tracer_type
Definition: ccl_cls.h:32
SplPar * spl_ba
Definition: ccl_cls.h:46
SplPar * spl_wM
Definition: ccl_cls.h:48
CCL_ClTracer* ccl_cl_tracer_lensing ( ccl_cosmology cosmo,
int  has_alignment,
int  nz_n,
double z_n,
double n,
int  nz_ba,
double z_ba,
double ba,
int  nz_rf,
double z_rf,
double rf,
int *  status 
)

Simplified constructor for a lensing ClTracer.

Parameters
has_intrinsic_alignmentSet to 1 if you want to compute the IA contribution to shear
nz_nNumber of bins in z_n and n
z_nRedshifts for each redshift interval of n
nNumber count of objects per redshift interval (Note: arbitrary normalization - renormalized inside)
nz_baNumber of bins in z_ba and ba
z_baRedshifts for each redshift interval of ba
baAlignment bias in each redshift bin
nz_rfNumber of bins in z_f and f
z_rfRedshifts for each redshift interval of rf
rfAligned red fraction in each redshift bin
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 642 of file ccl_cls.c.

References ccl_cl_tracer(), and ccl_weak_lensing_tracer.

Referenced by compare_cls(), and compare_corr().

647 {
648  return ccl_cl_tracer(cosmo,ccl_weak_lensing_tracer,0,0,has_alignment,
649  nz_n,z_n,n,-1,NULL,NULL,-1,NULL,NULL,
650  nz_ba,z_ba,ba,nz_rf,z_rf,rf,0, status);
651 }
CCL_ClTracer * ccl_cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:575
CCL_ClTracer* ccl_cl_tracer_lensing_simple ( ccl_cosmology cosmo,
int  nz_n,
double z_n,
double n,
int *  status 
)

Simplified constructor for a lensing ClTracer without intrinsic alignment.

Parameters
nz_nNumber of bins in z_n and n
z_nRedshifts for each redshift interval of n
nNumber count of objects per redshift interval (Note: arbitrary normalization - renormalized inside)
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 653 of file ccl_cls.c.

References ccl_cl_tracer(), and ccl_weak_lensing_tracer.

Referenced by compare_cls(), compare_corr(), and main().

655 {
656  return ccl_cl_tracer(cosmo,ccl_weak_lensing_tracer,0,0,0,
657  nz_n,z_n,n,-1,NULL,NULL,-1,NULL,NULL,
658  -1,NULL,NULL,-1,NULL,NULL,0, status);
659 }
CCL_ClTracer * ccl_cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:575
CCL_ClTracer* ccl_cl_tracer_number_counts ( ccl_cosmology cosmo,
int  has_rsd,
int  has_magnification,
int  nz_n,
double z_n,
double n,
int  nz_b,
double z_b,
double b,
int  nz_s,
double z_s,
double s,
int *  status 
)

Simplified constructor for a clustering ClTracer.

Parameters
cosmoCosmological parameters
has_rsdSet to 1 if you want to compute the RSD contribution to number counts (0 otherwise)
has_magnificationSet to 1 if you want to compute the magnification contribution to number counts (0 otherwise)
nz_nNumber of bins in z_n and n
z_nRedshifts for each redshift interval of n
nNumber count of objects per redshift interval (Note: arbitrary normalization - renormalized inside)
nz_bNumber of bins in z_b and b
z_bRedshifts for each redshift interval of b
bClustering bias in each redshift bin
nz_sNumber of bins in z_s and s
z_sRedshifts for each redshift interval of s
sMagnification bias in each redshift bin
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 622 of file ccl_cls.c.

References ccl_cl_tracer(), and ccl_number_counts_tracer.

Referenced by main(), and test_angpow_precision().

627 {
628  return ccl_cl_tracer(cosmo,ccl_number_counts_tracer,has_rsd,has_magnification,0,
629  nz_n,z_n,n,nz_b,z_b,b,nz_s,z_s,s,
630  -1,NULL,NULL,-1,NULL,NULL,0, status);
631 }
CCL_ClTracer * ccl_cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:575
CCL_ClTracer* ccl_cl_tracer_number_counts_simple ( ccl_cosmology cosmo,
int  nz_n,
double z_n,
double n,
int  nz_b,
double z_b,
double b,
int *  status 
)

Simplified constructor for a ClTracer without magnification nor RSD.

Parameters
nz_nNumber of bins in z_n and n
z_nRedshifts for each redshift interval of n
nNumber count of objects per redshift interval (Note: arbitrary normalization - renormalized inside)
nz_bNumber of bins in z_b and b
z_bRedshifts for each redshift interval of b
bClustering bias in each redshift bin
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
CCL_ClTracer object

Definition at line 633 of file ccl_cls.c.

References ccl_cl_tracer(), and ccl_number_counts_tracer.

Referenced by compare_cls(), compare_corr(), and main().

636 {
637  return ccl_cl_tracer(cosmo,ccl_number_counts_tracer,0,0,0,
638  nz_n,z_n,n,nz_b,z_b,b,-1,NULL,NULL,
639  -1,NULL,NULL,-1,NULL,NULL,0, status);
640 }
CCL_ClTracer * ccl_cl_tracer(ccl_cosmology *cosmo, int tracer_type, int has_rsd, int has_magnification, int has_intrinsic_alignment, int nz_n, double *z_n, double *n, int nz_b, double *z_b, double *b, int nz_s, double *z_s, double *s, int nz_ba, double *z_ba, double *ba, int nz_rf, double *z_rf, double *rf, double z_source, int *status)
Definition: ccl_cls.c:575
void ccl_cl_workspace_free ( CCL_ClWorkspace w)

Definition at line 59 of file ccl_cls.c.

References CCL_ClWorkspace::l_arr.

Referenced by compare_cls(), compare_corr(), main(), and test_angpow_precision().

60 {
61  free(w->l_arr);
62  free(w);
63 }
CCL_ClWorkspace* ccl_cl_workspace_new ( int  lmax,
int  l_limber,
double  l_logstep,
int  l_linstep,
int *  status 
)

Definition at line 65 of file ccl_cls.c.

References CCL_ERROR_MEMORY, CCL_MAX, CCL_ClWorkspace::l_arr, CCL_ClWorkspace::l_limber, CCL_ClWorkspace::l_linstep, CCL_ClWorkspace::l_logstep, CCL_ClWorkspace::lmax, CCL_ClWorkspace::n_ls, and w.

Referenced by ccl_cl_workspace_new_limber(), and test_angpow_precision().

67 {
68  int i_l,l0,increment;
70  if(w==NULL)
71  *status=CCL_ERROR_MEMORY;
72 
73  if(*status==0) {
74  //Set params
75  w->lmax=lmax;
76  w->l_limber=l_limber;
77  w->l_logstep=l_logstep;
78  w->l_linstep=l_linstep;
79 
80  //Compute number of multipoles
81  i_l=0; l0=0;
82  increment=CCL_MAX(((int)(l0*(w->l_logstep-1.))),1);
83  while((l0 < w->lmax) && (increment < w->l_linstep)) {
84  i_l++;
85  l0+=increment;
86  increment=CCL_MAX(((int)(l0*(w->l_logstep-1))),1);
87  }
88  increment=w->l_linstep;
89  while(l0 < w->lmax) {
90  i_l++;
91  l0+=increment;
92  }
93 
94  //Allocate array of multipoles
95  w->n_ls=i_l+1;
96  w->l_arr=(int *)malloc(w->n_ls*sizeof(int));
97  if(w->l_arr==NULL)
98  *status=CCL_ERROR_MEMORY;
99  }
100 
101  if(*status==0) {
102  //Redo the computation above and store values of ell
103  i_l=0; l0=0;
104  increment=CCL_MAX(((int)(l0*(w->l_logstep-1.))),1);
105  while((l0 < w->lmax) && (increment < w->l_linstep)) {
106  w->l_arr[i_l]=l0;
107  i_l++;
108  l0+=increment;
109  increment=CCL_MAX(((int)(l0*(w->l_logstep-1))),1);
110  }
111  increment=w->l_linstep;
112  while(l0 < w->lmax) {
113  w->l_arr[i_l]=l0;
114  i_l++;
115  l0+=increment;
116  }
117  //Don't go further than lmaw
118  w->l_arr[w->n_ls-1]=w->lmax;
119  }
120 
121  return w;
122 }
#define CCL_MAX(a, b)
Definition: ccl_utils.h:8
#define CCL_ERROR_MEMORY
Definition: ccl_error.h:10
double l_logstep
Definition: ccl_cls.h:216
static double w[2][28][111]
Definition: ccl_emu17.c:33
CCL_ClWorkspace* ccl_cl_workspace_new_limber ( int  lmax,
double  l_logstep,
int  l_linstep,
int *  status 
)

Definition at line 124 of file ccl_cls.c.

References ccl_cl_workspace_new().

Referenced by compare_cls(), compare_corr(), and main().

125 {
126  return ccl_cl_workspace_new(lmax,-1,l_logstep,l_linstep,status);
127 }
CCL_ClWorkspace * ccl_cl_workspace_new(int lmax, int l_limber, double l_logstep, int l_linstep, int *status)
Definition: ccl_cls.c:65
double ccl_get_tracer_fa ( ccl_cosmology cosmo,
CCL_ClTracer clt,
double  a,
int  func_code,
int *  status 
)

Method to return certain redshift or distance-dependent internal quantities for a given tracer.

Parameters
cosmoCosmological parameters
cltClTracer object
ascale factor at which the function is to be evaluated
func_codeinteger defining which internal function to evaluate. Choose between: ccl_trf_nz (redshift distribution), ccl_trf_bz (clustering bias), ccl_trf_sz (magnification bias), ccl_trf_rf (aligned fraction), ccl_trf_ba (alignment bias), ccl_trf_wL (weak lensing window function), ccl_trf_wM (magnification window function)
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
interpolated value of the requested function

Definition at line 1048 of file ccl_cls.c.

References ccl_comoving_radial_distance(), ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, ccl_spline_eval(), ccl_trf_ba, ccl_trf_bz, ccl_trf_nz, ccl_trf_rf, ccl_trf_sz, ccl_trf_wL, ccl_trf_wM, check_clt_fa_inconsistency(), CCL_ClTracer::spl_ba, CCL_ClTracer::spl_bz, CCL_ClTracer::spl_nz, CCL_ClTracer::spl_rf, CCL_ClTracer::spl_sz, CCL_ClTracer::spl_wL, CCL_ClTracer::spl_wM, and x.

1049 {
1050  SplPar *spl;
1051 
1052  if(check_clt_fa_inconsistency(clt,func_code)) {
1053  *status=CCL_ERROR_INCONSISTENT;
1054  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: inconsistent combination of tracer and internal function to be evaluated");
1055  return -1;
1056  }
1057 
1058  switch(func_code) {
1059  case ccl_trf_nz :
1060  spl=clt->spl_nz;
1061  break;
1062  case ccl_trf_bz :
1063  spl=clt->spl_bz;
1064  break;
1065  case ccl_trf_sz :
1066  spl=clt->spl_sz;
1067  break;
1068  case ccl_trf_rf :
1069  spl=clt->spl_rf;
1070  break;
1071  case ccl_trf_ba :
1072  spl=clt->spl_ba;
1073  break;
1074  case ccl_trf_wL :
1075  spl=clt->spl_wL;
1076  break;
1077  case ccl_trf_wM :
1078  spl=clt->spl_wM;
1079  break;
1080  }
1081 
1082  double x;
1083  if((func_code==ccl_trf_wL) || (func_code==ccl_trf_wM))
1084  x=ccl_comoving_radial_distance(cosmo,a,status); //x-variable is comoving distance for lensing kernels
1085  else
1086  x=1./a-1; //x-variable is redshift by default
1087 
1088  return ccl_spline_eval(x,spl);
1089 }
SplPar * spl_rf
Definition: ccl_cls.h:45
SplPar * spl_nz
Definition: ccl_cls.h:42
static int check_clt_fa_inconsistency(CCL_ClTracer *clt, int func_code)
Definition: ccl_cls.c:1032
SplPar * spl_bz
Definition: ccl_cls.h:43
SplPar * spl_sz
Definition: ccl_cls.h:44
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double ccl_spline_eval(double x, SplPar *spl)
Definition: ccl_utils.c:170
static CCL_BEGIN_DECLS double x[111][8]
SplPar * spl_wL
Definition: ccl_cls.h:47
#define CCL_ERROR_INCONSISTENT
Definition: ccl_error.h:12
SplPar * spl_ba
Definition: ccl_cls.h:46
SplPar * spl_wM
Definition: ccl_cls.h:48
double ccl_comoving_radial_distance(ccl_cosmology *cosmo, double a, int *status)
int ccl_get_tracer_fas ( ccl_cosmology cosmo,
CCL_ClTracer clt,
int  na,
double a,
double fa,
int  func_code,
int *  status 
)

Method to return certain redshift or distance-dependent internal quantities for a given tracer.

Parameters
cosmoCosmological parameters
cltClTracer object
nanumber of points at which the function will be evaluated
ana values of the scale factor at which the function is to be evaluated
faoutput array with na values that will store the interpolated function values
func_codeinteger defining which internal function to evaluate. Choose between: ccl_trf_nz (redshift distribution), ccl_trf_bz (clustering bias), ccl_trf_sz (magnification bias), ccl_trf_rf (aligned fraction), ccl_trf_ba (alignment bias), ccl_trf_wL (weak lensing window function), ccl_trf_wM (magnification window function)
statusStatus flag. 0 if there are no errors, nonzero otherwise. For specific cases see documentation for ccl_error.c
Returns
void

Definition at line 1091 of file ccl_cls.c.

References ccl_comoving_radial_distance(), ccl_cosmology_set_status_message(), CCL_ERROR_INCONSISTENT, ccl_spline_eval(), ccl_trf_ba, ccl_trf_bz, ccl_trf_nz, ccl_trf_rf, ccl_trf_sz, ccl_trf_wL, ccl_trf_wM, check_clt_fa_inconsistency(), CCL_ClTracer::spl_ba, CCL_ClTracer::spl_bz, CCL_ClTracer::spl_nz, CCL_ClTracer::spl_rf, CCL_ClTracer::spl_sz, CCL_ClTracer::spl_wL, CCL_ClTracer::spl_wM, and x.

Referenced by main().

1093 {
1094  SplPar *spl;
1095 
1096  if(check_clt_fa_inconsistency(clt,func_code)) {
1097  *status=CCL_ERROR_INCONSISTENT;
1098  ccl_cosmology_set_status_message(cosmo, "ccl_cls.c: inconsistent combination of tracer and internal function to be evaluated");
1099  return -1;
1100  }
1101 
1102  switch(func_code) {
1103  case ccl_trf_nz :
1104  spl=clt->spl_nz;
1105  break;
1106  case ccl_trf_bz :
1107  spl=clt->spl_bz;
1108  break;
1109  case ccl_trf_sz :
1110  spl=clt->spl_sz;
1111  break;
1112  case ccl_trf_rf :
1113  spl=clt->spl_rf;
1114  break;
1115  case ccl_trf_ba :
1116  spl=clt->spl_ba;
1117  break;
1118  case ccl_trf_wL :
1119  spl=clt->spl_wL;
1120  break;
1121  case ccl_trf_wM :
1122  spl=clt->spl_wM;
1123  break;
1124  }
1125 
1126  int compchi = (func_code==ccl_trf_wL) || (func_code==ccl_trf_wM);
1127 
1128  int ia;
1129  for(ia=0;ia<na;ia++) {
1130  double x;
1131  if(compchi) //x-variable is comoving distance for lensing kernels
1132  x=ccl_comoving_radial_distance(cosmo,a[ia],status);
1133  else //x-variable is redshift by default
1134  x=1./a[ia]-1;
1135  fa[ia]=ccl_spline_eval(x,spl);
1136  }
1137 
1138  return 0;
1139 }
SplPar * spl_rf
Definition: ccl_cls.h:45
SplPar * spl_nz
Definition: ccl_cls.h:42
static int check_clt_fa_inconsistency(CCL_ClTracer *clt, int func_code)
Definition: ccl_cls.c:1032
SplPar * spl_bz
Definition: ccl_cls.h:43
SplPar * spl_sz
Definition: ccl_cls.h:44
void ccl_cosmology_set_status_message(ccl_cosmology *cosmo, const char *status_message,...)
Definition: ccl_core.c:792
double ccl_spline_eval(double x, SplPar *spl)
Definition: ccl_utils.c:170
static CCL_BEGIN_DECLS double x[111][8]
SplPar * spl_wL
Definition: ccl_cls.h:47
#define CCL_ERROR_INCONSISTENT
Definition: ccl_error.h:12
SplPar * spl_ba
Definition: ccl_cls.h:46
SplPar * spl_wM
Definition: ccl_cls.h:48
double ccl_comoving_radial_distance(ccl_cosmology *cosmo, double a, int *status)