diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-05-08 18:11:35 -0300 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2025-05-08 18:11:35 -0300 |
commit | 73f4eaba3a08a5e1b85512868c3916c7fd4e4571 (patch) | |
tree | 999ceaa31419e37590309e3ccb4a8e9ec0a9c536 /log-fourier.cpp | |
parent | 21a99431f02e799de9a811f9f02ad006fe27df6d (diff) | |
download | code-73f4eaba3a08a5e1b85512868c3916c7fd4e4571.tar.gz code-73f4eaba3a08a5e1b85512868c3916c7fd4e4571.tar.bz2 code-73f4eaba3a08a5e1b85512868c3916c7fd4e4571.zip |
Updated to work with shift
Diffstat (limited to 'log-fourier.cpp')
-rw-r--r-- | log-fourier.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/log-fourier.cpp b/log-fourier.cpp index 2e93e87..5b5955a 100644 --- a/log-fourier.cpp +++ b/log-fourier.cpp @@ -4,9 +4,9 @@ #include <fstream> #include <types.hpp> -LogarithmicFourierTransform::LogarithmicFourierTransform(unsigned N, Real k, Real Δτ, unsigned pad) : N(N), pad(pad), k(k), Δτ(Δτ) { - τₛ = -0.5 * N; - ωₛ = -0.5 * N; +LogarithmicFourierTransform::LogarithmicFourierTransform(unsigned N, Real k, Real Δτ, unsigned pad, Real shift) : N(N), pad(pad), k(k), Δτ(Δτ) { + τₛ = -shift * N; + ωₛ = -(1-shift) * N; sₛ = -0.5 * pad * N; a = reinterpret_cast<Complex*>(FFTW_ALLOC_COMPLEX(pad*N)); â = reinterpret_cast<Complex*>(FFTW_ALLOC_COMPLEX(pad*N)); @@ -70,7 +70,7 @@ std::vector<Complex> LogarithmicFourierTransform::fourier(const std::vector<Real } FFTW_EXECUTE(a_to_â); for (unsigned n = 0; n < pad*N; n++) { - â[(pad*N / 2 + n) % (pad*N)] *= std::pow(II * σ, II * s(n) - k) * Γ(k - II * s(n)); + â[(pad*N / 2 + n) % (pad*N)] *= std::exp(II*(0.5 * N + τₛ) * s(n) / Δτ) * std::pow(II * σ, II * s(n) - k) * Γ(k - II * s(n)); } FFTW_EXECUTE(â_to_a); for (unsigned n = 0; n < N; n++) { @@ -98,7 +98,7 @@ std::vector<Real> LogarithmicFourierTransform::inverse(const std::vector<Complex } FFTW_EXECUTE(a_to_â); for (unsigned n = 0; n < pad*N; n++) { - â[(pad*N / 2 + n) % (pad*N)] *= std::pow(-II * σ, II * s(n) - k) * Γ(k - II * s(n)); + â[(pad*N / 2 + n) % (pad*N)] *= std::exp(-II*(0.5 * N + τₛ) * s(n) / Δτ) * std::pow(-II * σ, II * s(n) - k) * Γ(k - II * s(n)); } FFTW_EXECUTE(â_to_a); for (unsigned n = 0; n < N; n++) { @@ -113,8 +113,8 @@ std::vector<Real> LogarithmicFourierTransform::inverse(const std::vector<Complex return c; } -std::string logFourierFile(std::string prefix, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) { - return prefix + "_" + std::to_string(p) + "_" + std::to_string(s) + "_" + std::to_string(λ) + "_" + std::to_string(τ₀) + "_" + std::to_string(β) + "_" + std::to_string(log2n) + "_" + std::to_string(Δτ) + "_" + std::to_string(k) + ".dat"; +std::string logFourierFile(std::string prefix, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real shift) { + return prefix + "_" + std::to_string(p) + "_" + std::to_string(s) + "_" + std::to_string(λ) + "_" + std::to_string(τ₀) + "_" + std::to_string(β) + "_" + std::to_string(log2n) + "_" + std::to_string(Δτ) + "_" + std::to_string(shift) + ".dat"; } void logFourierSave(const std::vector<Real>& C, const std::vector<Real>& R, const std::vector<Complex>& Ct, const std::vector<Complex>& Rt, unsigned p, unsigned s, Real λ, Real τ₀, Real β, unsigned log2n, Real Δτ, Real k) { @@ -184,7 +184,7 @@ Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, con } Real energy(const LogarithmicFourierTransform& fft, std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β) { - Real E = 0; + Real E = fft.t(0) * (df(λ, p, s, 1) + R[0] * df(λ, p, s, C[0])) / 2; for (unsigned n = 0; n < C.size()/2-1; n++) { Real h₂ₙ = fft.t(2*n+1) - fft.t(2*n); Real h₂ₙ₊₁ = fft.t(2*n+2) - fft.t(2*n+1); |