CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
FuncMultipoles.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2010 by Federico Marulli *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
35 #include "Func.h"
36 
37 using namespace std;
38 
39 using namespace cbl;
40 
41 
42 // =====================================================================================
43 
44 
45 double cbl::multipole_xi0 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> xi)
46 {
47  double bin = mu[1]-mu[0];
48  double xi0 = 0.;
49 
50  for (unsigned int j=0; j<xi[indexR].size(); j++)
51  xi0 += xi[indexR][j]*bin;
52 
53  return xi0;
54 }
55 
56 
57 // ============================================================================
58 
59 
60 double cbl::multipole_xi2 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> xi)
61 {
62  double bin = mu[1]-mu[0];
63  double xi2 = 0.;
64 
65  for (unsigned int j=0; j<xi[indexR].size(); j++)
66  xi2 += xi[indexR][j]*P_2(mu[j])*bin;
67 
68  return 5.*xi2;
69 }
70 
71 
72 // ============================================================================
73 
74 
75 double cbl::multipole_xi4 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> xi)
76 {
77  double bin = mu[1]-mu[0];
78  double xi4 = 0.;
79 
80  for (unsigned int j=0; j<xi[indexR].size(); j++)
81  xi4 += xi[indexR][j]*P_4(mu[j])*bin;
82 
83  return 9.*xi4;
84 }
85 
86 
87 // ============================================================================
88 
89 
90 double cbl::error_multipole_xi0 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> error)
91 {
92  double bin = mu[1]-mu[0];
93  double err = 0.;
94 
95  for (unsigned int j=0; j<error[indexR].size(); j++)
96  err += pow(error[indexR][j],2.);
97 
98  return sqrt(err)*bin;
99 }
100 
101 
102 // ============================================================================
103 
104 
105 double cbl::error_multipole_xi2 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> error)
106 {
107  double bin = mu[1]-mu[0];
108  double err = 0.;
109 
110  for (unsigned int j=0; j<error[indexR].size(); j++)
111  err += pow(error[indexR][j]*P_2(mu[j]),2.);
112 
113  return 5.*sqrt(err)*bin;
114 }
115 
116 
117 // ============================================================================
118 
119 
120 double cbl::error_multipole_xi4 (const int indexR, const std::vector<double> mu, const std::vector<std::vector<double>> error)
121 {
122  double bin = mu[1]-mu[0];
123  double err = 0.;
124 
125  for (unsigned int j=0; j<error[indexR].size(); j++)
126  err += pow(error[indexR][j]*P_4(mu[j]),2.);
127 
128  return 9.*sqrt(err)*bin;
129 }
130 
131 
132 // ============================================================================
133 
134 
135 double cbl::multipole_xi0 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> xi, const double delta_s)
136 {
137  double xi0 = 0.;
138  int Nbin = 0;
139 
140  for (unsigned int i=0; i<rp.size(); i++)
141  for (unsigned int j=0; j<pi.size(); j++) {
142 
143  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
144  double mu = pi[j]/sss;
145 
146  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
147  Nbin ++;
148  xi0 += xi[i][j]*sqrt(1.-mu*mu);
149  }
150  }
151 
152  return (Nbin>0) ? 0.5*par::pi*xi0/Nbin : -1000.;
153 }
154 
155 
156 // ============================================================================
157 
158 
159 double cbl::multipole_xi2 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> xi, const double delta_s)
160 {
161  double xi2 = 0.;
162  int Nbin = 0;
163 
164  for (unsigned int i=0; i<rp.size(); i++)
165  for (unsigned int j=0; j<pi.size(); j++) {
166 
167  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
168  double mu = pi[j]/sss;
169 
170  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
171  Nbin ++;
172  xi2 += xi[i][j]*P_2(mu)*sqrt(1.-mu*mu);
173  }
174  }
175 
176  return (Nbin>0) ? 0.5*par::pi*5.*xi2/Nbin : -1000.;
177 }
178 
179 
180 // ============================================================================
181 
182 
183 double cbl::multipole_xi4 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> xi, const double delta_s)
184 {
185  double xi4 = 0.;
186  int Nbin = 0;
187 
188  for (unsigned int i=0; i<rp.size(); i++)
189  for (unsigned int j=0; j<pi.size(); j++) {
190 
191  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
192  double mu = pi[j]/sss;
193 
194  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
195  Nbin ++;
196  xi4 += xi[i][j]*P_4(mu)*sqrt(1.-mu*mu);
197  }
198  }
199 
200  return (Nbin>0) ? 0.5*par::pi*9.*xi4/Nbin : -1000.;
201 }
202 
203 
204 // ============================================================================
205 
206 
207 double cbl::error_multipole_xi0 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> error, const double delta_s)
208 {
209  double err = 0.;
210  int Nbin = 0;
211 
212  for (unsigned int i=0; i<rp.size(); i++)
213  for (unsigned int j=0; j<pi.size(); j++) {
214 
215  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
216  double mu = pi[j]/sss;
217 
218  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
219  Nbin ++;
220  err += pow(error[i][j]*sqrt(1.-mu*mu),2.);
221  }
222  }
223 
224  return (Nbin>0) ? 0.5*par::pi*sqrt(err)/Nbin : -1000.;
225 }
226 
227 
228 // ============================================================================
229 
230 
231 double cbl::error_multipole_xi2 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> error, const double delta_s)
232 {
233  double err = 0.;
234  int Nbin = 0;
235 
236  for (unsigned int i=0; i<rp.size(); i++)
237  for (unsigned int j=0; j<pi.size(); j++) {
238 
239  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
240  double mu = pi[j]/sss;
241 
242  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
243  Nbin ++;
244  err += pow(error[i][j]*P_2(mu)*sqrt(1.-mu*mu),2.);
245  }
246  }
247 
248  return (Nbin>0) ? 0.5*par::pi*5.*sqrt(err)/Nbin : -1000.;
249 }
250 
251 
252 // ============================================================================
253 
254 
255 double cbl::error_multipole_xi4 (const double ss, const std::vector<double> rp, const std::vector<double> pi, const std::vector<std::vector<double>> error, const double delta_s)
256 {
257  double err = 0.;
258  int Nbin = 0;
259 
260  for (unsigned int i=0; i<rp.size(); i++)
261  for (unsigned int j=0; j<pi.size(); j++) {
262 
263  double sss = sqrt(rp[i]*rp[i]+pi[j]*pi[j]);
264  double mu = pi[j]/sss;
265 
266  if (ss-delta_s*0.5<sss && sss<ss+delta_s*0.5) {
267  Nbin ++;
268  err += pow(error[i][j]*P_4(mu)*sqrt(1.-mu*mu),2.);
269  }
270  }
271 
272  return (Nbin>0) ? 0.5*par::pi*9.*sqrt(err)/Nbin : -1000.;
273 }
274 
275 
276 // ============================================================================
277 
279 
280 double cbl::multipoles (double rr, shared_ptr<void> pp, std::vector<double> par)
281 {
282 
283  int index = par[par.size()-1];
284 
285 
286  // -----------------------------------------------------
287  // ---- compute xi(rp,pi) with the dispersion model ----
288  // -----------------------------------------------------
289 
290  shared_ptr<cbl::glob::STR_xi2D_model> vec = static_pointer_cast<cbl::glob::STR_xi2D_model >(pp);
291 
292  vector<vector<double>> Xi (vec->dim, vector<double> (vec->dim,-1.e30));
293 
294  int index2 = 0;
295 
296  for (int i=0; i<vec->dim; i++)
297  for (int j=0; j<vec->dim; j++) {
298  par[par.size()-1] = index2++;
299  Xi[i][j] = xi2D_model(vec->rp[i],vec->pi[j],pp,par);
300  }
301 
302  /*
303  // -----------------------------
304  // ---- eliminate null bins ----
305  // -----------------------------
306 
307  vector<vector<double>> XiR = Xi;
308  vector<double> rpp, pii;
309 
310  for (unsigned int i=0; i<vec->rp.size(); i++) {
311  rpp.push_back(vec->rp[i]);
312  pii.push_back(vec->pi[i]);
313  }
314 
315  SubMatrix(rpp, pii, XiR, -1);
316  */
317 
318 
319  // -------------------------------------------------
320  // ---- interpolate xi(rp,pi) in the r,mu plane ----
321  // -------------------------------------------------
322 
323  double cos_min = 0.;
324  double cos_max = 1.;
325  int step_cos = 3000;
326  vector<double> cos_lin = linear_bin_vector(step_cos, cos_min, cos_max);
327 
328  double rp, pi;
329  vector<vector<double>> xi_cos(1);
330 
331  for (unsigned int i=0; i<cos_lin.size(); i++) {
332  rp = rr*sqrt(1.-cos_lin[i]*cos_lin[i]);
333  pi = rr*cos_lin[i];
334  xi_cos[0].push_back(interpolated_2D(rp, pi, vec->rp, vec->pi, Xi, "Linear"));
335  }
336 
337 
338  // --------------------------------------------------
339  // ---- measure the multipole of the correlation ----
340  // --------------------------------------------------
341 
342  if (vec->type[index]==1) return multipole_xi0(0,cos_lin,xi_cos);
343  else if (vec->type[index]==2) return multipole_xi2(0,cos_lin,xi_cos);
344  else return ErrorCBL("vec->type[index]!=1 and !=2", "multipoles", "FuncMultipoles.cpp");
345 
346 }
347 
349 
350 // ============================================================================
351 
352 
353 double cbl::multipole_xi0_model (const double beta, const double xi_real)
354 {
355  return xi_ratio(beta)*xi_real;
356 }
357 
358 
359 // ============================================================================
360 
361 
362 double cbl::multipole_xi0_model (const double f_sigma8, const double bias_sigma8, const double sigma8z, const double xi_matter)
363 {
364  return xi_ratio(f_sigma8, bias_sigma8)*xi_matter*pow(bias_sigma8/sigma8z, 2);
365 }
366 
367 
368 // ============================================================================
369 
371 
372 double cbl::multipole_xi0_model (double xx, shared_ptr<void> pp, std::vector<double> par)
373 {
374  (void)xx;
375 
376  shared_ptr<cbl::glob::STR_xi0_model> vec = static_pointer_cast<cbl::glob::STR_xi0_model>(pp);
377 
378  if (par.size()==2) return multipole_xi0_model(par[0], vec->bias_sigma8, vec->sigma8z, vec->xi_matter[par[par.size()-1]]);
379 
380  else return ErrorCBL("par.size()!=2", "multipole_xi0_model", "FuncMultipoles.cpp");
381 }
382 
384 
385 // ============================================================================
386 
387 
388 double cbl::multipole_xi2_model (const double beta, const double xi_real, const double xi_)
389 {
390  return (4./3.*beta+4./7.*beta*beta)*(xi_real-xi_);
391 }
392 
393 
394 // ============================================================================
395 
396 
397 double cbl::multipole_xi4_model (const double beta, const double xi_real, const double xi_, const double xi__)
398 {
399  return (8./35.*beta*beta)*(xi_real+2.5*xi_-3.5*xi__);
400 }
401 
402 
403 // Multipoles from Pk
404 
405 
406 // ============================================================================
407 
408 
409 double cbl::Pkl_Kaiser_integrand (const double mu, void *parameters)
410 {
411  struct cbl::glob::STR_Pkl_Kaiser_integrand *pp = (struct cbl::glob::STR_Pkl_Kaiser_integrand *) parameters;
412 
413  return pow(pp->bias+pp->f*mu*mu,2)*gsl_sf_legendre_Pl(pp->l,mu);
414 }
415 
416 
417 // ============================================================================
418 
419 
420 double cbl::XiMultipoles_integrand (const double kk, void *parameters)
421 {
422  struct cbl::glob::STR_XiMultipoles_integrand *pp = (struct cbl::glob::STR_XiMultipoles_integrand *) parameters;
423  double pkl = pp->Pkl->operator()(kk);
424  double xx = kk*pp->r;
425  double k_cut = pp->k_cut;
426  double cut_pow = pp->cut_pow;
427 
428  return kk*kk*jl(xx,pp->l)*pkl*exp(-pow(kk/k_cut,cut_pow));
429 }
430 
431 
432 // ============================================================================
433 
434 
435 double cbl::XiMultipoles_from_Xi2D_integrand(const double mu, void *parameters)
436 {
437  struct cbl::glob::STR_xi2D_smu_integrand *pp = (struct cbl::glob::STR_xi2D_smu_integrand *) parameters;
438 
439  return legendre_polynomial(mu,pp->order)*pp->func->operator()(mu);
440 }
441 
442 
443 // ============================================================================
444 
445 
446 double cbl::sigma2_integrand(const double mu, void *parameters)
447 {
448 
449  struct cbl::glob::STR_sigma2_integrand *pp = (struct cbl::glob::STR_sigma2_integrand *) parameters;
450  int l1 = pp->l1;
451  int l2 = pp->l2;
452  vector<int> orders = pp->orders;
453  double density_inv = pp->density_inv;
454  double kk = pp->kk;
455  double val = 0;
456 
457  for(size_t i =0;i<orders.size();i++)
458  val += pp->Pk_multipoles_interp[i].operator()(kk)*gsl_sf_legendre_Pl(orders[i],mu);
459  return pow(val+density_inv,2)*gsl_sf_legendre_Pl(l1,mu)*gsl_sf_legendre_Pl(l2,mu);
460 }
461 
462 
463 // ============================================================================
464 
465 
466 double cbl::covariance_XiMultipoles_integrand (const double kk, void *parameters)
467 {
468  struct cbl::glob::STR_covariance_XiMultipoles_integrand *pp = (struct cbl::glob::STR_covariance_XiMultipoles_integrand *) parameters;
469  double s2 = pp->s2->operator()(kk);
470  double jl1k = pp->jl1r1->operator()(kk);
471  double jl2k = pp->jl2r2->operator()(kk);
472 
473  return kk*kk*s2*jl1k*jl2k;
474 }
475 
476 
477 // ============================================================================
478 
479 
480 double cbl::Pkl_Kaiser_integral(const int order, const double bias, const double f)
481 {
482  int limit_size = 1000;
483  double prec = 1.e-3;
484 
485  cbl::glob::STR_Pkl_Kaiser_integrand params;
486  params.l = order;
487  params.bias = bias;
488  params.f = f;
489 
490  gsl_function Func;
491  Func.function = &Pkl_Kaiser_integrand;
492  Func.params = &params;
493 
494  return 0.5*(2*order+1)*wrapper::gsl::GSL_integrate_qag(Func, -1., 1., prec, limit_size, 6);
495 }
496 
497 
498 // ============================================================================
499 
500 
501 std::vector<double> cbl::Pk0_Kaiser(const std::vector<double> kk, const std::vector<double> Pk, const double bias, const double f)
502 {
503  vector<double> Pk0(kk.size(),0);
504  double factor = Pkl_Kaiser_integral(0,bias,f);
505 
506  for(size_t i = 0;i<kk.size();i++)
507  Pk0[i]=Pk[i]*factor;
508 
509  return Pk0;
510 }
511 
512 
513 // ============================================================================
514 
515 
516 std::vector<double> cbl::Pk2_Kaiser(const std::vector<double> kk, const std::vector<double> Pk, const double bias, const double f)
517 {
518  vector<double> Pk2(kk.size(),0);
519  double factor = Pkl_Kaiser_integral(2,bias,f);
520 
521  for(size_t i = 0;i<kk.size();i++)
522  Pk2[i]=Pk[i]*factor;
523 
524  return Pk2;
525 }
526 
527 
528 // ============================================================================
529 
530 
531 std::vector<double> cbl::Pk4_Kaiser(const std::vector<double> kk, const std::vector<double> Pk, const double bias, const double f)
532 {
533  vector<double> Pk4(kk.size(),0);
534  double factor = Pkl_Kaiser_integral(4,bias,f);
535 
536  for(size_t i = 0;i<kk.size();i++)
537  Pk4[i]=Pk[i]*factor;
538 
539  return Pk4;
540 }
541 
542 
543 // ============================================================================
544 
545 
546 std::vector< std::vector<double>> cbl::Pkl_Kaiser(const std::vector<int> orders, const std::vector<double> kk, const std::vector<double> Pk, const double bias, const double f)
547 {
548  vector<vector<double>> Pk_multipoles(orders.size(),vector<double>(kk.size(),0));
549  size_t nbin_k = kk.size();
550 
551  for(size_t ll=0;ll<orders.size();ll++)
552  {
553  double integral= Pkl_Kaiser_integral(orders[ll],bias,f);
554 
555  for(size_t i=0;i<nbin_k;i++)
556  {
557  Pk_multipoles[ll][i] = Pk[i]*integral;;
558  }
559 
560  }
561 
562  return Pk_multipoles;
563 }
564 
565 
566 // ============================================================================
567 
568 
569 std::vector<double> cbl::Xi0 (const std::vector<double> r, const std::vector<double> kk, const std::vector<double> Pk0, const double k_cut, const double cut_pow, const int IntegrationMethod)
570 {
571  double f0 = 1./(2.*par::pi*par::pi);
572  int nbins = r.size();
573  int nbins_k = kk.size();
574 
575  vector<double> xi0(nbins, 0);
576 
577  if (IntegrationMethod==0) { // perform trapezoid integration
578 
579  for (int i=0; i<nbins; i++) {
580 
581  vector<double> i0(kk.size(), 0);
582 
583  for (int j=0; j<nbins_k; j++)
584  i0[j] = kk[j]*kk[j]*Pk0[j]*j0(kk[j]*r[i]);
585 
586  xi0[i] = trapezoid_integration(kk,i0)*f0;
587  }
588 
589  }
590  else if (IntegrationMethod==1) { // perform integration with GSL
591 
592  cbl::glob::STR_XiMultipoles_integrand params;
593  int limit_size = 1000;
594 
595  gsl_function Func;
596  Func.function = &XiMultipoles_integrand;
597  Func.params = &params;
598 
599  double k_min = Min(kk);
600  double k_max = Max(kk);
601  double prec = 1.e-3;
602 
603  glob::FuncGrid Pk0_interp(kk, Pk0, "Spline");
604  params.Pkl = &Pk0_interp;
605  params.l = 0;
606  params.k_cut = k_cut;
607  params.cut_pow = cut_pow;
608 
609  for (int i=0; i<nbins; i++) {
610  params.r = r[i];
611  xi0[i] = wrapper::gsl::GSL_integrate_qag(Func, k_min, k_max, prec, 0., limit_size, 6)*f0;
612  }
613 
614  Pk0_interp.free();
615  }
616 
617  return xi0;
618 }
619 
620 
621 // ============================================================================
622 
623 
624 std::vector<double> cbl::Xi2 (const std::vector<double> rr, const std::vector<double> kk, const std::vector<double> Pk2, const double k_cut, const double cut_pow, const int IntegrationMethod)
625 {
626  double f2 = -1./(2.*par::pi*par::pi); // f4=1./(2.*par::pi*par::pi);
627  int nbins = rr.size();
628  int nbins_k = kk.size();
629 
630  vector<double> xi2(nbins, 0);
631 
632  if (IntegrationMethod==0) // perform trapezoid integration
633  {
634  for (int i=0; i<nbins; i++) {
635 
636  vector<double> i2(kk.size(),0);
637 
638  for (int j=0; j<nbins_k; j++)
639  i2[j] = kk[j]*kk[j]*Pk2[j]*j2(kk[j]*rr[i]);
640 
641  xi2[i] = trapezoid_integration(kk, i2)*f2;
642  }
643 
644  }
645 
646  else if (IntegrationMethod==1) // perform integration with GSL
647  {
648  cbl::glob::STR_XiMultipoles_integrand params;
649  int limit_size = 1000;
650 
651  gsl_function Func;
652  Func.function = &XiMultipoles_integrand;
653  Func.params = &params;
654 
655  double k_min = Min(kk);
656  double k_max = Max(kk);
657  double prec = 1.e-3;
658 
659  glob::FuncGrid Pk2_interp(kk,Pk2,"Spline");
660  params.Pkl = &Pk2_interp;
661  params.l = 2;
662  params.k_cut = k_cut;
663  params.cut_pow = cut_pow;
664 
665  for (int i=0; i<nbins; i++) {
666  params.r = rr[i];
667  xi2[i] = wrapper::gsl::GSL_integrate_qag(Func, k_min, k_max, prec, 0., limit_size, 6)*f2;
668  }
669  Pk2_interp.free();
670 
671  }
672 
673  return xi2;
674 }
675 
676 
677 // ============================================================================
678 
679 
680 std::vector<double> cbl::Xi4(const std::vector<double> rr, const std::vector<double> kk, const std::vector<double> Pk4, const double k_cut, const double cut_pow, const int IntegrationMethod)
681 {
682  double f4 = 1./(2.*par::pi*par::pi);
683  int nbins = rr.size();
684  int nbins_k = kk.size();
685 
686  vector<double> xi4(nbins, 0);
687 
688  if (IntegrationMethod==0) //Perform trapezoid integration
689  {
690 
691  for (int i=0; i<nbins; i++) {
692 
693  vector<double> i4(kk.size(), 0);
694 
695  for (int j=0; j<nbins_k; j++)
696  i4[j] = kk[j]*kk[j]*Pk4[j]*j4(kk[j]*rr[i]);
697 
698  xi4[i] = trapezoid_integration(kk, i4)*f4;
699  }
700 
701  }
702  else if (IntegrationMethod==1) // perform integration with GSL
703  {
704  cbl::glob::STR_XiMultipoles_integrand params;
705  int limit_size = 1000;
706 
707  gsl_function Func;
708  Func.function = &XiMultipoles_integrand;
709  Func.params = &params;
710 
711  double k_min = Min(kk);
712  double k_max = Max(kk);
713  double prec = 1.e-3;
714 
715  glob::FuncGrid Pk4_interp(kk, Pk4, "Spline");
716  params.Pkl = &Pk4_interp;
717  params.l = 4;
718  params.k_cut = k_cut;
719  params.cut_pow = cut_pow;
720 
721  for (int i=0; i<nbins; i++) {
722  params.r = rr[i];
723  xi4[i] = wrapper::gsl::GSL_integrate_qag(Func, k_min, k_max, prec, 0., limit_size, 6)*f4;
724  }
725  Pk4_interp.free();
726 
727  }
728 
729  return xi4;
730 }
731 
732 
733 // ============================================================================
734 
735 
736 std::vector<std::vector<double>> cbl::Xi02_AP (const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::shared_ptr<glob::FuncGrid> xi0_interp, const std::shared_ptr<glob::FuncGrid> xi2_interp)
737 {
738  vector<double> xi0_new, xi2_new;
739 
740  if ((alpha_perpendicular-1)<1.e-30 && (alpha_parallel-1.)<1.e-30)
741  for (size_t i=0; i<rr.size(); i++) {
742  xi0_new.push_back(xi0_interp->operator()(rr[i]));
743  xi2_new.push_back(xi2_interp->operator()(rr[i]));
744  }
745 
746  else {
747 
748  double nbin_mu = 50.;
749  vector<double> mu = linear_bin_vector(nbin_mu, 0., 1.);
750  vector<double> xismu_0(nbin_mu, 0), xismu_2(nbin_mu, 0);
751 
752  for (size_t j=0; j<rr.size(); j++) {
753  for (size_t i=0; i<nbin_mu; i++) {
754  double alpha = sqrt(pow(alpha_parallel*mu[i], 2)+pow(alpha_perpendicular, 2)*(1.-mu[i]*mu[i]));
755  double mu_new = mu[i]*alpha_parallel/alpha;
756  double s_new = alpha*rr[i];
757  xismu_0[i] = xi0_interp->operator()(s_new)+xi2_interp->operator()(s_new)*legendre_polynomial(mu_new, 2);
758  xismu_2[i] = xismu_0[i]*legendre_polynomial(mu[i], 2);
759  }
760  xi0_new.push_back(trapezoid_integration(mu, xismu_0));
761  xi2_new.push_back(5*trapezoid_integration(mu, xismu_2));
762  }
763  }
764 
765  return {xi0_new, xi2_new};
766 }
767 
768 
769 // ============================================================================
770 
771 
772 std::vector<std::vector<double>> cbl::Xi024_AP (const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::shared_ptr<glob::FuncGrid> xi0_interp, const std::shared_ptr<glob::FuncGrid> xi2_interp, const std::shared_ptr<glob::FuncGrid> xi4_interp)
773 {
774  vector<double> xi0_new, xi2_new, xi4_new;
775 
776  if ((alpha_perpendicular)==1 && (alpha_parallel)==1)
777  for (size_t i=0; i<rr.size(); i++) {
778  xi0_new.push_back(xi0_interp->operator()(rr[i]));
779  xi2_new.push_back(xi2_interp->operator()(rr[i]));
780  xi4_new.push_back(xi4_interp->operator()(rr[i]));
781  }
782 
783  else {
784 
785  double nbin_mu = 50.;
786  vector<double> mu = linear_bin_vector(nbin_mu, 0., 1.);
787  vector<double> xismu_0(nbin_mu, 0), xismu_2(nbin_mu, 0), xismu_4(nbin_mu, 0);
788 
789  for (size_t j=0; j<rr.size(); j++) {
790  for (size_t i=0; i<nbin_mu; i++) {
791  double alpha = sqrt(pow(alpha_parallel*mu[i], 2)+pow(alpha_perpendicular, 2)*(1.-mu[i]*mu[i]));
792  double mu_new = mu[i]*alpha_parallel/alpha;
793  double s_new = alpha*rr[j];
794  xismu_0[i] = xi0_interp->operator()(s_new)+xi2_interp->operator()(s_new)*legendre_polynomial(mu_new, 2)+xi4_interp->operator()(s_new)*legendre_polynomial(mu_new, 4);
795  xismu_2[i] = xismu_0[i]*legendre_polynomial(mu[i], 2);
796  xismu_4[i] = xismu_0[i]*legendre_polynomial(mu[i], 4);
797  }
798  xi0_new.push_back(trapezoid_integration(mu, xismu_0));
799  xi2_new.push_back(5*trapezoid_integration(mu, xismu_2));
800  xi4_new.push_back(9*trapezoid_integration(mu, xismu_4));
801 
802  }
803  }
804 
805  return {xi0_new, xi2_new, xi4_new};
806 }
807 
808 // ============================================================================
809 
810 
811 std::vector<std::vector<double>> cbl::Xi02_AP (const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::vector<double> rl, const std::vector<double> Xi0, const std::vector<double> Xi2)
812 {
813  glob::FuncGrid xi0_interp(rl, Xi0, "Spline");
814  glob::FuncGrid xi2_interp(rl, Xi2, "Spline");
815 
816  vector<double> xi0_new, xi2_new;
817 
818  if (alpha_perpendicular == 1 && alpha_parallel == 1)
819  for (size_t i=0; i<rr.size(); i++) {
820  xi0_new.push_back(xi0_interp(rr[i]));
821  xi2_new.push_back(xi2_interp(rr[i]));
822  }
823 
824  else {
825 
826  double nbin_mu = 50.;
827  vector<double> mu = linear_bin_vector(nbin_mu, 0., 1.);
828  vector<double> xismu_0(nbin_mu, 0), xismu_2(nbin_mu, 0);
829 
830  for (size_t j=0; j<rr.size(); j++) {
831  for (size_t i=0; i<nbin_mu; i++) {
832  double alpha = sqrt(pow(alpha_parallel*mu[i], 2)+pow(alpha_perpendicular, 2)*(1.-mu[i]*mu[i]));
833  double mu_new = mu[i]*alpha_parallel/alpha;
834  double s_new = alpha*rr[i];
835  xismu_0[i] = xi0_interp(s_new)+xi2_interp(s_new)*legendre_polynomial(mu_new, 2);
836  xismu_2[i] = xismu_0[i]*legendre_polynomial(mu[i], 2);
837  }
838  xi0_new.push_back(trapezoid_integration(mu, xismu_0));
839  xi2_new.push_back(5*trapezoid_integration(mu, xismu_2));
840  }
841  }
842 
843  xi0_interp.free();
844  xi2_interp.free();
845 
846  return {xi0_new, xi2_new};
847 }
848 
849 
850 // ============================================================================
851 
852 
853 std::vector<std::vector<double>> cbl::Xi024_AP (const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::vector<double> rl, const std::vector<double> Xi0, const std::vector<double> Xi2, const std::vector<double> Xi4)
854 {
855  glob::FuncGrid xi0_interp(rl, Xi0, "Spline");
856  glob::FuncGrid xi2_interp(rl, Xi2, "Spline");
857  glob::FuncGrid xi4_interp(rl, Xi4, "Spline");
858 
859  vector<double> xi0_new, xi2_new, xi4_new;
860 
861  if ((alpha_perpendicular)==1 && (alpha_parallel)==1)
862  for (size_t i=0; i<rr.size(); i++) {
863  xi0_new.push_back(xi0_interp(rr[i]));
864  xi2_new.push_back(xi2_interp(rr[i]));
865  xi4_new.push_back(xi4_interp(rr[i]));
866  }
867 
868  else {
869 
870  double nbin_mu = 50.;
871  vector<double> mu = linear_bin_vector(nbin_mu, 0., 1.);
872  vector<double> xismu_0(nbin_mu, 0), xismu_2(nbin_mu, 0), xismu_4(nbin_mu, 0);
873 
874  for (size_t j=0; j<rr.size(); j++) {
875  for (size_t i=0; i<nbin_mu; i++) {
876  double alpha = sqrt(pow(alpha_parallel*mu[i], 2)+pow(alpha_perpendicular, 2)*(1.-mu[i]*mu[i]));
877  double mu_new = mu[i]*alpha_parallel/alpha;
878  double s_new = alpha*rr[j];
879  xismu_0[i] = xi0_interp(s_new)+xi2_interp(s_new)*legendre_polynomial(mu_new, 2)+xi4_interp(s_new)*legendre_polynomial(mu_new, 4);
880  xismu_2[i] = xismu_0[i]*legendre_polynomial(mu[i], 2);
881  xismu_4[i] = xismu_0[i]*legendre_polynomial(mu[i], 4);
882  }
883  xi0_new.push_back(trapezoid_integration(mu, xismu_0));
884  xi2_new.push_back(5*trapezoid_integration(mu, xismu_2));
885  xi4_new.push_back(9*trapezoid_integration(mu, xismu_4));
886 
887  }
888  }
889 
890  xi0_interp.free();
891  xi2_interp.free();
892  xi4_interp.free();
893 
894  return {xi0_new, xi2_new, xi4_new};
895 }
896 
897 
898 // ============================================================================
899 
900 
901 std::vector<std::vector<double>> cbl::XiWedges_AP (const std::vector<double> mu_min, const std::vector<double> delta_mu, const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::shared_ptr<glob::FuncGrid> xi0_interp, const std::shared_ptr<glob::FuncGrid> xi2_interp, const std::shared_ptr<glob::FuncGrid> xi4_interp)
902 {
903  vector<vector<double>> xi_multipoles = cbl::Xi024_AP(alpha_perpendicular, alpha_parallel, rr, xi0_interp, xi2_interp, xi4_interp);
904  vector<vector<double>> xi_wedges(mu_min.size(), vector<double>(rr.size(), 0));
905 
906  vector<vector<double>> legendre_integral(mu_min.size(), vector<double>(3, 0));
907 
908  for(size_t j=0; j<mu_min.size(); j++) {
909  double leg_int_0 = Legendre_polynomial_mu_average(0, mu_min[j], delta_mu[j]);
910  double leg_int_2 = Legendre_polynomial_mu_average(2, mu_min[j], delta_mu[j]);
911  double leg_int_4 = Legendre_polynomial_mu_average(4, mu_min[j], delta_mu[j]);
912  for (size_t i=0; i<rr.size(); i++)
913  xi_wedges[j][i] = xi_multipoles[0][i]*leg_int_0+xi_multipoles[1][i]*leg_int_2+xi_multipoles[2][i]*leg_int_4;
914  }
915 
916  return xi_wedges;
917 }
918 
919 
920 // ============================================================================
921 
922 
923 std::vector<std::vector<double>> cbl::XiWedges_AP (const std::vector<double> mu_min, const std::vector<double> delta_mu, const double alpha_perpendicular, const double alpha_parallel, const std::vector<double> rr, const std::vector<double> rl, const std::vector<double> Xi0, const std::vector<double> Xi2, const std::vector<double> Xi4)
924 {
925  vector<vector<double>> xi_multipoles = cbl::Xi024_AP(alpha_perpendicular, alpha_parallel, rr, rl, Xi0, Xi2, Xi4);
926  vector<vector<double>> xi_wedges(mu_min.size(), vector<double>(rr.size(), 0));
927 
928  vector<vector<double>> legendre_integral(mu_min.size(), vector<double>(3, 0));
929 
930  for(size_t j=0; j<mu_min.size(); j++) {
931  double leg_int_0 = Legendre_polynomial_mu_average(0, mu_min[j], delta_mu[j]);
932  double leg_int_2 = Legendre_polynomial_mu_average(2, mu_min[j], delta_mu[j]);
933  double leg_int_4 = Legendre_polynomial_mu_average(4, mu_min[j], delta_mu[j]);
934  for (size_t i=0; i<rr.size(); i++)
935  xi_wedges[j][i] = xi_multipoles[0][i]*leg_int_0+xi_multipoles[1][i]*leg_int_2+xi_multipoles[2][i]*leg_int_4;
936  }
937 
938  return xi_wedges;
939 }
940 
941 // ============================================================================
942 
943 
944 std::vector< std::vector<double>> cbl::sigma2_k (const double nObjects, const double Volume, const std::vector<double> kk, const std::vector<std::vector<double>> Pk_multipoles, const std::vector<int> orders)
945 {
946  double prec = 1.e-3;
947  size_t n_orders = orders.size();
948  size_t nbin_k = kk.size();
949 
950  vector<vector<double>> sigma2(n_orders*n_orders, vector<double>(nbin_k,0));
951  double density_inv = Volume/nObjects;
952 
953  int limit_size = 100;
954 
955  cbl::glob::STR_sigma2_integrand params;
956 
957  params.orders = orders;
958 
959  vector<glob::FuncGrid> Pk_multipoles_interp;
960  for(size_t i=0;i<n_orders;i++){
961  Pk_multipoles_interp.push_back(glob::FuncGrid(kk,Pk_multipoles[i],"Spline"));
962  }
963 
964  params.Pk_multipoles_interp = Pk_multipoles_interp;
965  params.density_inv = density_inv;
966 
967  gsl_function Func;
968  Func.function = &sigma2_integrand;
969  Func.params = &params;
970 
971  for (size_t i=0;i<n_orders;i++){
972  params.l1 = orders[i];
973  for (size_t j=0;j<n_orders;j++){
974  params.l2 = orders[j];
975  int index = j+n_orders*i;
976  for(size_t k=0;k<kk.size();k++){
977  params.kk = kk[k];
978  double Int = wrapper::gsl::GSL_integrate_qag(Func, -1, 1., prec, limit_size, 6);
979  sigma2[index][k] = (2*orders[i]+1)*(2*orders[j]+1)*Int/Volume;
980  }
981  }
982  }
983 
984  for(size_t i=0;i<n_orders;i++)
985  Pk_multipoles_interp[i].free();
986 
987  return sigma2;
988 }
989 
990 
991 // ============================================================================
992 
993 
994 void cbl::Covariance_XiMultipoles (std::vector<double> &rr, std::vector<std::vector<double>> &covariance, const int nbins, const double rMin, const double rMax, const double nObjects, const double Volume, const std::vector<double> kk, const std::vector<std::vector<double>> Pk_multipoles, const std::vector<int> orders, const cbl::BinType bin_type)
995 {
996  int n_orders = orders.size();
997  int nbins_k = kk.size();
998 
999  const double binSize = (bin_type==cbl::BinType::_linear_) ? (rMax-rMin)/nbins : (log10(rMax)-log10(rMin))/nbins;
1000 
1001  vector<double> rad(nbins, 0), edges(nbins+1,0);
1002  for(int i=0; i<nbins; i++){
1003  rad[i] = (bin_type==cbl::BinType::_linear_) ? (i+0.5)*binSize+rMin : pow(10.,(i+0.5)*binSize+log10(rMin));
1004  edges[i] = (bin_type==cbl::BinType::_linear_) ? i*binSize+rMin : pow(10., i*binSize+log10(rMin));
1005  }
1006  edges[nbins] = (bin_type==cbl::BinType::_linear_) ? nbins*binSize+rMin : pow(10., nbins*binSize+log10(rMin));
1007 
1008  covariance.erase(covariance.begin(), covariance.end());
1009  covariance.resize(n_orders*nbins,vector<double>(n_orders*nbins, 0));
1010 
1011  vector<vector<double>> sigma2 = sigma2_k(nObjects, Volume, kk, Pk_multipoles, orders);
1012 
1013  vector<vector<vector<double>>> jr(n_orders,vector<vector<double>>(nbins,vector<double>(nbins_k, 0)));
1014 
1015  for (int l=0; l<n_orders; l++)
1016  for (int i=0; i<nbins; i++)
1017  for (int j=0; j<nbins_k; j++)
1018  jr[l][i][j] = jl_distance_average(kk[j], orders[l], edges[i], edges[i+1]);
1019 
1020  cbl::glob::STR_covariance_XiMultipoles_integrand params;
1021  int limit_size = 1000;
1022 
1023  gsl_function Func;
1024  Func.function = &covariance_XiMultipoles_integrand;
1025  Func.params = &params;
1026 
1027  double k_min= max(1.e-4, cbl::Min(kk));
1028  double k_max = min(Max(kk),1.); //1.e0;
1029  double prec = 1.e-2;
1030  complex<double> ii = complex<double>(0., 1.);
1031 
1032  // auto-correlation terms
1033  for (int l=0; l<n_orders; l++) {
1034  int index = l+n_orders*l;
1035 
1036  glob::FuncGrid s2(kk, sigma2[index], "Spline");
1037  params.s2 = &s2;
1038  for (int i=0; i<nbins; i++) {
1039  glob::FuncGrid jl1r1(kk, jr[l][i], "Spline");
1040  for (int j=i; j<nbins; j++) {
1041  glob::FuncGrid jl2r2(kk, jr[l][j], "Spline");
1042  params.jl1r1 = &jl1r1;
1043  params.jl2r2 = &jl2r2;
1044 
1045  double Int = wrapper::gsl::GSL_integrate_qag(Func, k_min, k_max, prec, limit_size, 6);
1046  Int = Int/(2.*par::pi*par::pi);
1047  covariance[i+nbins*l][j+nbins*l] = Int;
1048  covariance[j+nbins*l][i+nbins*l] = Int;
1049  jl2r2.free();
1050  }
1051  jl1r1.free();
1052  }
1053  s2.free();
1054  }
1055 
1056  // cross-correlation terms
1057 
1058  for (int l1=0; l1<n_orders; l1++) {
1059  for (int l2=l1+1; l2<n_orders; l2++) {
1060  int index = l2+n_orders*l1;
1061  int sign = pow(ii,orders[l1]+orders[l2]).real();
1062 
1063  glob::FuncGrid s2(kk, sigma2[index], "Spline");
1064  params.s2 = &s2;
1065 
1066  for (int i=0; i<nbins; i++) {
1067  glob::FuncGrid jl1r1(kk, jr[l1][i], "Spline");
1068  for (int j=0; j<nbins; j++) {
1069  glob::FuncGrid jl2r2(kk, jr[l2][j], "Spline");
1070  params.jl1r1 = &jl1r1;
1071  params.jl2r2 = &jl2r2;
1072 
1073  double Int = wrapper::gsl::GSL_integrate_qag(Func, k_min, k_max, prec, limit_size, 6);
1074  Int = sign*Int/(2.*par::pi*par::pi);
1075  covariance[i+nbins*l1][j+nbins*l2] = Int;
1076  covariance[j+nbins*l2][i+nbins*l1] = Int;
1077  jl2r2.free();
1078  }
1079  jl1r1.free();
1080  }
1081  s2.free();
1082  }
1083  }
1084 
1085  rr.erase(rr.begin(), rr.end());
1086 
1087  for (int i=0; i<n_orders; i++)
1088  for (int j=0; j<nbins; j++)
1089  rr.push_back(rad[j]);
1090 }
1091 
1092 
1093 // ============================================================================
1094 
1095 
1096 void cbl::Covariance_XiWedges (std::vector<double> &rr, std::vector<std::vector<double>> &covariance, const std::vector<double> mu, const std::vector<double> delta_mu, const int nbins, const double rMin, const double rMax, const double nObjects, const double Volume, const std::vector<double> kk, const std::vector<std::vector<double>> Pk_multipoles, const std::vector<int> orders, const cbl::BinType bin_type)
1097 {
1098  int n_wedges = mu.size();
1099  vector<int> ord = orders;
1100  vector<vector<double>> Pkl = Pk_multipoles;
1101 
1102  if (n_wedges>2 && ord.size()==3) {
1103  vector<double> Pk6(kk.size(), 0);
1104  ord.push_back(6);
1105  Pkl.push_back(Pk6);
1106  }
1107 
1108  int n_orders = ord.size();
1109 
1110  vector<vector<double>> covariance_multipoles;
1111 
1112  covariance.erase(covariance.begin(), covariance.end());
1113  covariance.resize(n_wedges*nbins, vector<double>(n_wedges*nbins, 0));
1114 
1115  vector<double> r_multipoles;
1116  cbl::Covariance_XiMultipoles(r_multipoles, covariance_multipoles, nbins, rMin, rMax, nObjects, Volume, kk, Pkl, ord, bin_type);
1117 
1118  for (int w1=0; w1<n_wedges; w1++) {
1119  for (int w2=0; w2<n_wedges; w2++) {
1120 
1121  for (int r1 =0; r1<nbins; r1++) {
1122  for (int r2 =0; r2<nbins; r2++) {
1123  double VV = 0;
1124 
1125  for (int l1=0; l1<n_orders; l1++) {
1126  double leg_integral1 = Legendre_polynomial_mu_average(mu[w1], mu[w1]+delta_mu[w1], ord[l1]);
1127  for (int l2=0; l2<n_orders; l2++) {
1128  double leg_integral2 = Legendre_polynomial_mu_average(mu[w2], mu[w2]+delta_mu[w2], ord[l2]);
1129  VV += covariance_multipoles[r1+nbins*l1][r2+nbins*l2]*leg_integral1*leg_integral2;
1130  }
1131  }
1132  covariance[r1+nbins*w1][r2+nbins*w2] = VV;
1133  }
1134  }
1135 
1136  }
1137  }
1138 
1139  vector<double> r = linear_bin_vector(nbins, rMin, rMax);
1140  rr.erase(rr.begin(), rr.end());
1141 
1142  for (int i=0; i<n_wedges; i++)
1143  for (int j=0; j<nbins; j++)
1144  rr.push_back(r[j]);
1145 }
Useful generic functions.
The class FuncGrid.
Definition: FuncGrid.h:55
void free()
free the GSL objects
Definition: FuncGrid.cpp:110
static const double pi
: the ratio of a circle's circumference to its diameter
Definition: Constants.h:199
static const double alpha
: the fine-structure constant
Definition: Constants.h:233
double bias(const double Mmin, const double sigmalgM, const double M0, const double M1, const double alpha, const std::shared_ptr< void > inputs)
the mean galaxy bias
double GSL_integrate_qag(gsl_function Func, const double a, const double b, const double rel_err=1.e-3, const double abs_err=0, const int limit_size=1000, const int rule=6)
integral, computed using the GSL qag method
Definition: GSLwrapper.cpp:180
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
T Min(const std::vector< T > vect)
minimum element of a std::vector
Definition: Kernel.h:1324
double sigma2_integrand(const double mu, void *parameters)
integrand of the 2d power spectrum to obtain sigma^2(k)
std::vector< double > Pk0_Kaiser(const std::vector< double > kk, const std::vector< double > Pk, const double bias, const double f)
function to obtain the linear RSD power spectrum monopole
double error_multipole_xi2(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> error)
error on xi2(s) from ξ(r,μ)
double Legendre_polynomial_mu_average(const int ll, const double mu, const double delta_mu)
the average of the Legendre polynomial of the l-th order over the mu range
Definition: Func.cpp:1806
std::vector< std::vector< double > > XiWedges_AP(const std::vector< double > mu_min, const std::vector< double > delta_mu, const double alpha_perpendicular, const double alpha_parallel, const std::vector< double > rr, const std::vector< double > rl, const std::vector< double > Xi0, const std::vector< double > Xi2, const std::vector< double > Xi4)
function to obtain the 2pcf wedges
double error_multipole_xi4(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> error)
error on xi4(s) from ξ(r,μ)
double Pkl_Kaiser_integral(const int order, const double bias, const double f)
function to obtain the Kaiser factor
double j2(const double xx)
the l=2 spherical Bessel function
Definition: Func.cpp:2048
std::vector< std::vector< double > > Xi02_AP(const double alpha_perpendicular, const double alpha_parallel, const std::vector< double > rr, const std::vector< double > rl, const std::vector< double > Xi0, const std::vector< double > Xi2)
function to obtain the monopole and quadrupole of the two point correlation function
double multipole_xi0(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> xi)
xi0(s) from ξ(r,μ)
std::vector< double > Xi2(const std::vector< double > rr, const std::vector< double > kk, const std::vector< double > Pk2, const double k_cut=0.58, const double cut_pow=4, const int IntegrationMethod=1)
function to obtain the two point correlation function quadrupole
std::vector< T > linear_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with linearly spaced values
Definition: Kernel.h:1604
double multipole_xi0_model(const double beta, const double xi_real)
the model multipole ξ0 of the two-point correlation function
double XiMultipoles_integrand(const double kk, void *parameters)
integrand to obtain covariance for the 2PCF multipoles
double interpolated_2D(const double _x1, const double _x2, const std::vector< double > x1, const std::vector< double > x2, const std::vector< std::vector< double >> yy, const std::string type)
2D interpolation
Definition: Func.cpp:502
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780
double multipole_xi2(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> xi)
xi2(s) from ξ(r,μ)
double multipole_xi4(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> xi)
xi4(s) from ξ(r,μ)
double multipole_xi4_model(const double beta, const double xi_real, const double xi_, const double xi__)
the model multipole ξ4 of the two-point correlation function
std::vector< std::vector< double > > Pkl_Kaiser(const std::vector< int > orders, const std::vector< double > kk, const std::vector< double > Pk, const double bias, const double f)
function to obtain Pk multipoles from linear RSD (Kaiser)
T P_4(const T x)
the Legendre polynomial P4
Definition: Func.h:1280
std::vector< std::vector< double > > sigma2_k(const double nObjects, const double Volume, const std::vector< double > kk, const std::vector< std::vector< double >> Pk_multipoles, const std::vector< int > orders)
multipole expansion of the per-mode covariance sigma2_k (see Grieb et al. 2016, eq....
T Max(const std::vector< T > vect)
maximum element of a std::vector
Definition: Kernel.h:1336
std::vector< double > Pk4_Kaiser(const std::vector< double > kk, const std::vector< double > Pk, const double bias, const double f)
function to obtain the linear RSD power spectrum hexadecapole
double j0(const double xx)
the l=0 spherical Bessel function
Definition: Func.cpp:2039
double trapezoid_integration(const std::vector< double > xx, const std::vector< double > yy)
integral, computed with the trapezoid rule, using ordered data
Definition: Func.cpp:2203
double xi2D_model(const double rp, const double pi, const double beta, const double bias, const double sigmav, const std::vector< double > rad_real, const std::vector< double > xi_real, const std::vector< double > xi_, const std::vector< double > xi__, const double var, const int FV, int index=-1, const bool bias_nl=0, const double bA=0., const double v_min=-3000., const double v_max=3000., const int step_v=500)
the non-linear dispersion model for ξ(rp,π)
Definition: FuncXi.cpp:574
double xi_ratio(const double beta)
the ratio between the redshift-space and real-space correlation functions
Definition: FuncXi.cpp:287
std::vector< std::vector< double > > Xi024_AP(const double alpha_perpendicular, const double alpha_parallel, const std::vector< double > rr, const std::vector< double > rl, const std::vector< double > Xi0, const std::vector< double > Xi2, const std::vector< double > Xi4)
function to obtain the monopole, quadrupole and hexadecapole of the two-point correlation function
double multipole_xi2_model(const double beta, const double xi_real, const double xi_)
the model multipole ξ2 of the two-point correlation function
double Pkl_Kaiser_integrand(const double mu, void *parameters)
integrand of the 2d power spectrum to obtain power spectrum multipole
std::vector< double > Pk2_Kaiser(const std::vector< double > kk, const std::vector< double > Pk, const double bias, const double f)
function to obtain the linear RSD power spectrum quadrupole
void Covariance_XiMultipoles(std::vector< double > &rr, std::vector< std::vector< double >> &covariance, const int nbins, const double rMin, const double rMax, const double nObjects, const double Volume, const std::vector< double > kk, const std::vector< std::vector< double >> Pk_multipoles, const std::vector< int > orders, const cbl::BinType bin_type=cbl::BinType::_linear_)
Covariance matrix for two-point correlation multipoles (see Grieb et al. 2016, Eq....
void Covariance_XiWedges(std::vector< double > &rr, std::vector< std::vector< double >> &covariance, const std::vector< double > mu, const std::vector< double > delta_mu, const int nbins, const double rMin, const double rMax, const double nObjects, const double Volume, const std::vector< double > kk, const std::vector< std::vector< double >> Pk_multipoles, const std::vector< int > orders, const cbl::BinType bin_type=cbl::BinType::_linear_)
Covariance matrix for two-point correlation wedges (see Grieb et al. 2016, Eq. 19 https://arxiv....
T P_2(const T x)
the Legendre polynomial P2
Definition: Func.h:1269
double error_multipole_xi0(const int indexR, const std::vector< double > mu, const std::vector< std::vector< double >> error)
error on xi0(s) from ξ(r,μ)
std::vector< double > Xi4(const std::vector< double > rr, const std::vector< double > kk, const std::vector< double > Pk4, const double k_cut=0.6, const double cut_pow=2, const int IntegrationMethod=1)
function to obtain the two point correlation function hexadecapole
double j4(const double xx)
the l=4 spherical Bessel function
Definition: Func.cpp:2057
double jl_distance_average(const double kk, const int order, const double r_down, const double r_up)
the distance average for the order l-th spherical Bessel function
Definition: Func.cpp:2109
BinType
the binning type
Definition: Kernel.h:505
@ _linear_
linear binning
double covariance_XiMultipoles_integrand(const double kk, void *parameters)
integrand to obtain the 2PCF multipoles
double XiMultipoles_from_Xi2D_integrand(const double mu, void *parameters)
integrand to obtain the 2PCF multipoles from 2D 2pcf in polar coordinates
double legendre_polynomial(const double mu, const int l)
the order l Legendre polynomial
Definition: Func.cpp:1786
std::vector< double > Xi0(const std::vector< double > r, const std::vector< double > kk, const std::vector< double > Pk0, const double k_cut=0.7, const double cut_pow=2, const int IntegrationMethod=1)
function to obtain the two point correlation funciton monopole
double jl(const double xx, const int order)
the order l spherical Bessel function
Definition: Func.cpp:2066