diff options
Diffstat (limited to 'log-fourier.cpp')
-rw-r--r-- | log-fourier.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/log-fourier.cpp b/log-fourier.cpp index d5ac17d..345e490 100644 --- a/log-fourier.cpp +++ b/log-fourier.cpp @@ -190,7 +190,7 @@ Real estimateZ(LogarithmicFourierTransform& fft, const std::vector<Real>& C, con return ((2 * Γ₀ * std::conj(Rt[0]) + std::pow(β, 2) * (RddfCt[0] * Ct[0] + dfCt[0] * std::conj(Rt[0]))) / Ct[0]).real(); } -Real energy(const LogarithmicFourierTransform& fft, std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β) { +Real energy(const LogarithmicFourierTransform& fft, const std::vector<Real>& C, const std::vector<Real>& R, unsigned p, unsigned s, Real λ, Real β) { unsigned n₀ = 0; for (unsigned n = 0; n < C.size(); n++) { if (C[n] > 1 || R[n] > 1) n₀ = n % 2 == 0 ? n / 2 : (n + 1) / 2; @@ -221,3 +221,25 @@ Real energy(const LogarithmicFourierTransform& fft, std::vector<Real>& C, const return β * E; } +Real C0(const LogarithmicFourierTransform& fft, const std::vector<Complex>& Ĉ) { + Real C = 0; + for (unsigned n = 0; n < Ĉ.size()/2-1; n++) { + Real Ĉ₂ₙ = Ĉ[2*n].real(); + Real Ĉ₂ₙ₊₁ = Ĉ[2*n+1].real(); + Real Ĉ₂ₙ₊₂ = Ĉ[2*n+2].real(); + + Real h₂ₙ = fft.t(2*n+1) - fft.t(2*n); + Real h₂ₙ₊₁ = fft.t(2*n+2) - fft.t(2*n+1); + Real f₂ₙ = Ĉ₂ₙ; + Real f₂ₙ₊₁ = Ĉ₂ₙ₊₁; + Real f₂ₙ₊₂ = Ĉ₂ₙ₊₂; + + C += (h₂ₙ + h₂ₙ₊₁) / 6 * ( + (2 - h₂ₙ₊₁ / h₂ₙ) * f₂ₙ + + std::pow(h₂ₙ + h₂ₙ₊₁, 2) / (h₂ₙ * h₂ₙ₊₁) * f₂ₙ₊₁ + + (2 - h₂ₙ / h₂ₙ₊₁) * f₂ₙ₊₂ + ); + } + return C / M_PI; +} + |