diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-03 15:45:29 -0300 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-04-03 15:45:29 -0300 |
commit | 8364b9a96b8f60a3effbe8843c89717a89a8fc5e (patch) | |
tree | daf2c354746cf85499ceca67f324325574e59f6a /fourier.hpp | |
parent | 60e0f9b63c9825a265a93a278bf018d301063ea2 (diff) | |
download | code-8364b9a96b8f60a3effbe8843c89717a89a8fc5e.tar.gz code-8364b9a96b8f60a3effbe8843c89717a89a8fc5e.tar.bz2 code-8364b9a96b8f60a3effbe8843c89717a89a8fc5e.zip |
Split functions into library to deduplicate code
Diffstat (limited to 'fourier.hpp')
-rw-r--r-- | fourier.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fourier.hpp b/fourier.hpp new file mode 100644 index 0000000..86335f7 --- /dev/null +++ b/fourier.hpp @@ -0,0 +1,32 @@ +#pragma once +#include <cmath> +#include <fftw3.h> +#include <complex> +#include <vector> + +using Real = double; +using Complex = std::complex<Real>; +using namespace std::complex_literals; + +Real f(Real λ, unsigned p, unsigned s, Real q); +Real df(Real λ, unsigned p, unsigned s, Real q); +Real ddf(Real λ, unsigned p, unsigned s, Real q); + +class FourierTransform { +private: + std::vector<Real> a; + std::vector<Complex> â; + fftw_plan plan_r2c; + fftw_plan plan_c2r; + Real Δω; + Real Δτ; +public: + FourierTransform(unsigned n, Real Δω, Real Δτ, unsigned flags = 0); + ~FourierTransform(); + std::vector<Complex> fourier(const std::vector<Real>& c); + std::vector<Real> inverse(const std::vector<Complex>& ĉ); +}; + +std::string fourierFile(std::string prefix, unsigned p, unsigned s, Real λ, Real τ₀, Real y, unsigned log2n, Real τₘₐₓ); +Real energy(const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real y, Real Δτ); +std::tuple<std::vector<Complex>, std::vector<Complex>> RddfCtdfCt(FourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ); |