Triumvirate C++ API 0.5.0.post1.dev301+g026f21751
Three-point clustering measurements in large-scale structure analyses.
Loading...
Searching...
No Matches
fftlog.hpp
Go to the documentation of this file.
1// Triumvirate: Three-Point Clustering Measurements in LSS
2//
3// Copyright (C) 2023 Mike S Wang & Naonori S Sugiyama [GPL-3.0-or-later]
4//
5// This file is part of the Triumvirate program. See the COPYRIGHT
6// and LICENCE files at the top-level directory of this distribution
7// for details of copyright and licensing.
8//
9// This program is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17// See the GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program. If not, see <https://www.gnu.org/licenses/>.
21
30
31#ifndef TRIUMVIRATE_INCLUDE_FFTLOG_HPP_INCLUDED_
32#define TRIUMVIRATE_INCLUDE_FFTLOG_HPP_INCLUDED_
33
34#if defined(TRV_USE_HIP)
35#include <hipfft/hipfftXt.h>
36#elif defined(TRV_USE_CUDA) // !TRV_USE_HIP && TRV_USE_CUDA
37#include <cufftXt.h>
38#endif // TRV_USE_HIP
39#include <fftw3.h>
40
41#include <cmath>
42#include <complex>
43#include <cstring>
44#include <vector>
45
46#include "maths.hpp"
47#include "arrayops.hpp"
48
49#if defined(TRV_USE_HIP)
50using fft_double_complex = hipfftDoubleComplex;
51using fftHandle = hipfftHandle;
52#elif defined(TRV_USE_CUDA) // !TRV_USE_HIP && TRV_USE_CUDA
53using fft_double_complex = cufftDoubleComplex;
54using fftHandle = cufftHandle;
55#endif // TRV_USE_HIP
56
57namespace trva = trv::array;
58
59namespace trv {
60
61namespace maths {
62
69 public:
70 double order;
71 double bias;
72 int nsamp = 0;
73 int nsamp_trans = 0;
74 double logres = 0.;
75 double pivot = 1.;
76
78 std::vector<double> pre_sampts;
79
81 std::vector<double> post_sampts;
82
90 HankelTransform(double mu, double q, bool threaded = true);
91
96
132 void initialise(
133 std::vector<double> sample_pts, double kr_c,
134 bool lowring = true,
136 double extrap_exp = 2.
137 );
138
164 void initialise(
165 std::vector<double> sample_pts, double kr_c,
166 bool lowring = true,
167 int extrap = 0,
168 double extrap_exp = 2.
169 );
170
187 void biased_transform(std::complex<double>* a, std::complex<double>* b);
188
194 std::vector< std::complex<double> > compute_kernel_coeff();
195
209 double calc_lowring_pivot(double delta, double kr_c = 1.);
210
211 private:
214
216 int n_ext = 0;
217
219 std::vector<double> pre_sampts_extrap;
220
222 std::vector<double> post_sampts_extrap;
223
225 std::vector< std::complex<double> > kernel;
226
228 fftw_plan pre_plan{};
229 fftw_plan post_plan{};
230#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
231 fftHandle plan_gpu{};
232#endif // TRV_USE_HIP || TRV_USE_CUDA
233
235 fftw_complex* pre_buffer = nullptr;
236 fftw_complex* post_buffer = nullptr;
237#if defined(TRV_USE_HIP) || defined(TRV_USE_CUDA)
238 fft_double_complex* d_buffer = nullptr;
239#endif // TRV_USE_HIP || TRV_USE_CUDA
240
241#ifdef _CUDA_STREAM
243 cudaStream_t custream{};
244#endif // _CUDA_STREAM
245
247 bool plan_init = false;
248
250 bool threaded = true;
251
256 void reset();
257};
258
260 public:
261 int degree;
262
270 SphericalBesselTransform(int ell, int n, bool threaded = true);
271
297 void initialise(
298 std::vector<double> sample_pts, double kr_c,
299 bool lowring = true,
301 double extrap_exp = 2.
302 );
303
330 void initialise(
331 std::vector<double> sample_pts, double kr_c,
332 bool lowring = true,
333 int extrap = 0,
334 double extrap_exp = 2.
335 );
336
358 void biased_transform(
359 std::vector< std::complex<double> >& a,
360 std::vector< std::complex<double> >& b
361 );
362
378 int dir,
379 std::vector< std::complex<double> >& pre_samples,
380 std::vector< std::complex<double> >& post_samples
381 );
382};
383
384} // namespace trv::maths
385
386} // namespace trv
387
388#endif // !TRIUMVIRATE_INCLUDE_FFTLOG_HPP_INCLUDED_
Array operations.
HankelTransform(double mu, double q, bool threaded=true)
Construct the Hankel transform.
Definition fftlog.cpp:39
int nsamp
number of samples provided
Definition fftlog.hpp:72
std::vector< double > post_sampts
logarithmically linearly-spaced sample points post-transform
Definition fftlog.hpp:81
void biased_transform(std::complex< double > *a, std::complex< double > *b)
Perform the (forward biased) Hankel transform.
Definition fftlog.cpp:346
double order
order of the Hankel transform
Definition fftlog.hpp:70
void initialise(std::vector< double > sample_pts, double kr_c, bool lowring=true, trva::ExtrapOption extrap=trva::ExtrapOption::NONE, double extrap_exp=2.)
Initialise the Hankel transform.
Definition fftlog.cpp:102
double calc_lowring_pivot(double delta, double kr_c=1.)
Calculate a low-ringing FFTLog transform pivot value .
Definition fftlog.cpp:255
double bias
power-law bias index
Definition fftlog.hpp:71
int nsamp_trans
number of samples transformed
Definition fftlog.hpp:73
~HankelTransform()
Destruct the Hankel transform.
Definition fftlog.cpp:65
double pivot
pivot value
Definition fftlog.hpp:75
double logres
logarithmic interval sample spacing
Definition fftlog.hpp:74
std::vector< std::complex< double > > compute_kernel_coeff()
Compute the FFTLog transform kernel coefficients .
Definition fftlog.cpp:287
std::vector< double > pre_sampts
logarithmically linearly-spaced sample points pre-transform
Definition fftlog.hpp:78
void biased_transform(std::vector< std::complex< double > > &a, std::vector< std::complex< double > > &b)
Perform the (forward biased) spherical Bessel transform.
Definition fftlog.cpp:523
void initialise(std::vector< double > sample_pts, double kr_c, bool lowring=true, trva::ExtrapOption extrap=trva::ExtrapOption::NONE, double extrap_exp=2.)
Initialise the spherical Bessel transform.
Definition fftlog.cpp:509
void transform_cosmological_multipole(int dir, std::vector< std::complex< double > > &pre_samples, std::vector< std::complex< double > > &post_samples)
Transform csomological multipole samples.
Definition fftlog.cpp:553
int degree
degree of the spherical Bessel transform
Definition fftlog.hpp:261
SphericalBesselTransform(int ell, int n, bool threaded=true)
Construct the spherical Bessel transform.
Definition fftlog.cpp:503
Mathematical calculations.
ExtrapOption
Extrapolation scheme.
Definition arrayops.hpp:102
@ NONE
0: none
Definition arrayops.hpp:103