Xiao Fang
2D-FFTLog code for efficiently computing integrals containing two Bessel or spherical Bessel functions, in the context of transforming covariance matrices from Fourier space to real space.
This code has been adapted and used in CosmoCov.
The code is independently written and tested in python (./python/twobessel.py) and C (./C/). Examples of calling the routines are given in ./C/test1.c, ./C/test2.c, and ./python/test.py. In the examples, input arrays k
and P(k)
are read in, with k
sampled logarithmically. k3 P(k) is set as f(k)
in the integrand of the Gaussian covariance. The code then builds a matrix with diagonal elements , and then performs 2D-FFTLog. For non-Gaussian covariance, one may read in the covariance and apply 2D-FFTLog directly.
For non-bin averaged case, the transformed covariances are evaluated at points given by array 1/k
. For bin-averaged case, one needs to specify bin-width in log-space, but note that the output r
array is always at bin edges.
To run python examples, go to (./python/) directory, and run
python test.py
To run C examples, go to (./C/) directory, and compile with command
make tests
then run tests:
./test1
./test2
See more details of the algorithm in Fang et al (2020); arXiv:2004.04833.
Please feel free to use and adapt the code for your own purpose, and let me know if you are confused or find a bug (just open an issue) or throw me an email (address shown on the profile page). 2DFFTLog is open source and distributed with the MIT license.
Please cite the following paper if you use 2D-FFTLog in your research: