Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
fftlog.h
Go to the documentation of this file.
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 
5 #ifndef FFTLOG_H
6 #define FFTLOG_H
7 
8 /****************************************************************
9 
10 This is the famous FFTLog.
11 
12 First imlplemented by the living legend Andrew Hamilton:
13 
14 http://casa.colorado.edu/~ajsh/FFTLog/
15 
16 This version is a C version that was adapted from the C++ version found
17 in Copter JWG Carlson, another big loss for the cosmology community.
18 
19 https://github.com/jwgcarlson/Copter
20 
21 I've transformed this from C++ to C99 as the lowest common denominator
22 and provided bindings for C++ and python.
23 
24 These are the C++ bindings
25 
26 *****************************************************************/
27 
28 /* Compute the correlation function xi(r) from a power spectrum P(k), sampled
29  * at logarithmically spaced points k[j]. */
30 void pk2xi(int N, const double k[], const double pk[], double r[], double xi[]);
31 
32 /* Compute the power spectrum P(k) from a correlation function xi(r), sampled
33  * at logarithmically spaced points r[i]. */
34 void xi2pk(int N, const double r[], const double xi[], double k[], double pk[]);
35 
36 /* Compute the function
37  * \xi_l^m(r) = \int_0^\infty \frac{dk}{2\pi^2} k^m j_l(kr) P(k)
38  * Note that the usual 2-point correlation function xi(r) is just xi_0^2(r)
39  * in this notation. The input k-values must be logarithmically spaced. The
40  * resulting xi_l^m(r) will be evaluated at the dual r-values
41  * r[0] = 1/k[N-1], ..., r[N-1] = 1/k[0]. */
42 void fftlog_ComputeXiLM(double l, double m, int N, const double k[], const double pk[],
43  double r[], double xi[]);
44 
45 /* Compute the function
46  * \xi_\alpha(\theta) = \int_0^\infty \frac{d\ell}{2\pi} \ell J_\alpha(\ell\theta) C_\ell
47  * The input l-values must be logarithmically spaced. The
48  * resulting xi_alpha(th) will be evaluated at the dual th-values
49  * th[0] = 1/l[N-1], ..., th[N-1] = 1/l[0]. */
50 void fftlog_ComputeXi2D(double bessel_order,int N,const double l[],const double cl[],
51  double th[], double xi[]);
52 #include <complex.h>
53 
54 /* Compute the discrete Hankel transform of the function a(r). See the FFTLog
55  * documentation (or the Fortran routine of the same name in the FFTLog
56  * sources) for a description of exactly what this function computes.
57  * If u is NULL, the transform coefficients will be computed anew and discarded
58  * afterwards. If you plan on performing many consecutive transforms, it is
59  * more efficient to pre-compute the u coefficients. */
60 void fht(int N, const double r[], const double complex a[], double k[], double complex b[], double mu,
61  double q, double kcrc, int noring, double complex* u);
62 // double q = 0, double kcrc = 1, bool noring = true, double complex* u = NULL);
63 
64 /* Pre-compute the coefficients that appear in the FFTLog implementation of
65  * the discrete Hankel transform. The parameters N, mu, and q here are the
66  * same as for the function fht(). The parameter L is defined (for whatever
67  * reason) to be N times the logarithmic spacing of the input array, i.e.
68  * L = N * log(r[N-1]/r[0])/(N-1) */
69 void compute_u_coefficients(int N, double mu, double q, double L, double kcrc, double complex u[]);
70 
71 
72 #endif // FFTLOG_H
73 
74 #ifdef __cplusplus
75 }
76 #endif
void fftlog_ComputeXi2D(double bessel_order, int N, const double l[], const double cl[], double th[], double xi[])
Definition: fftlog.c:144
void fht(int N, const double r[], const double _Complex a[], double k[], double _Complex b[], double mu, double q, double kcrc, int noring, double _Complex *u)
void pk2xi(int N, const double k[], const double pk[], double r[], double xi[])
Definition: fftlog.c:176
static int m[2]
Definition: ccl_emu17.c:25
void compute_u_coefficients(int N, double mu, double q, double L, double kcrc, double _Complex u[])
void fftlog_ComputeXiLM(double l, double m, int N, const double k[], const double pk[], double r[], double xi[])
Definition: fftlog.c:160
void xi2pk(int N, const double r[], const double xi[], double k[], double pk[])
Definition: fftlog.c:181