From 7b87846abcede7c9d16b87e29f9fb0516493706b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 9 May 2025 09:10:05 -0300 Subject: Energy tweak --- log-fourier.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'log-fourier.cpp') diff --git a/log-fourier.cpp b/log-fourier.cpp index e8404d7..11edfcb 100644 --- a/log-fourier.cpp +++ b/log-fourier.cpp @@ -186,12 +186,43 @@ Real estimateZ(LogarithmicFourierTransform& fft, const std::vector& C, con Real energy(const LogarithmicFourierTransform& fft, std::vector& C, const std::vector& R, unsigned p, unsigned s, Real λ, Real β) { 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++) { - if (C[2*n+2] < 0 || R[2*n+2] < 0) break; + Real R₂ₙ = R[2*n]; + Real R₂ₙ₊₁ = R[2*n+1]; + Real R₂ₙ₊₂ = R[2*n+2]; + Real C₂ₙ = C[2*n]; + Real C₂ₙ₊₁ = C[2*n+1]; + Real C₂ₙ₊₂ = C[2*n+2]; + + if (R₂ₙ > 1 || R₂ₙ₊₁ > 1 || R₂ₙ₊₂ > 1) { + R₂ₙ = 1; + R₂ₙ₊₁ = 1; + R₂ₙ₊₂ = 1; + } + + if (C₂ₙ > 1 || C₂ₙ₊₁ > 1 || C₂ₙ₊₂ > 1) { + C₂ₙ = 1; + C₂ₙ₊₁ = 1; + C₂ₙ₊₂ = 1; + } + + if (R₂ₙ < 0 || R₂ₙ₊₁ < 0 || R₂ₙ₊₂ < 0) { + R₂ₙ = 0; + R₂ₙ₊₁ = 0; + R₂ₙ₊₂ = 0; + } + + if (C₂ₙ < 0 || C₂ₙ₊₁ < 0 || C₂ₙ₊₂ < 0) { + C₂ₙ = 0; + C₂ₙ₊₁ = 0; + C₂ₙ₊₂ = 0; + } + 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₂ₙ = R[2*n] * df(λ, p, s, C[2*n]); - Real f₂ₙ₊₁ = R[2*n+1] * df(λ, p, s, C[2*n+1]); - Real f₂ₙ₊₂ = R[2*n+2] * df(λ, p, s, C[2*n+2]); + Real f₂ₙ = R₂ₙ * df(λ, p, s, C₂ₙ); + Real f₂ₙ₊₁ = R₂ₙ₊₁ * df(λ, p, s, C₂ₙ₊₁); + Real f₂ₙ₊₂ = R₂ₙ₊₂ * df(λ, p, s, C₂ₙ₊₂); + E += (h₂ₙ + h₂ₙ₊₁) / 6 * ( (2 - h₂ₙ₊₁ / h₂ₙ) * f₂ₙ + std::pow(h₂ₙ + h₂ₙ₊₁, 2) / (h₂ₙ * h₂ₙ₊₁) * f₂ₙ₊₁ -- cgit v1.2.3-70-g09d2 From 516a9832d1f237396211a4806925d81e64ba7b14 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 9 May 2025 11:59:52 -0300 Subject: Undid energy tweaks, and restored mirror padding --- log-fourier.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'log-fourier.cpp') diff --git a/log-fourier.cpp b/log-fourier.cpp index 11edfcb..5d0da17 100644 --- a/log-fourier.cpp +++ b/log-fourier.cpp @@ -64,6 +64,8 @@ std::vector LogarithmicFourierTransform::fourier(const std::vector= (pad - 1) * N) { + a[n] = c[pad*N-n-1] * exp((1 - k) * τ(pad*N-n-1)); } else { a[n] = 0; } @@ -92,6 +94,8 @@ std::vector LogarithmicFourierTransform::inverse(const std::vector= (pad - 1) * N) { + a[n] = (ĉ[pad*N-n-1].real() + II * σ * ĉ[pad*N-n-1].imag()) * std::exp((1 - k) * ω(pad*N-n-1)); } else { a[n] = 0; } @@ -193,30 +197,6 @@ Real energy(const LogarithmicFourierTransform& fft, std::vector& C, const Real C₂ₙ₊₁ = C[2*n+1]; Real C₂ₙ₊₂ = C[2*n+2]; - if (R₂ₙ > 1 || R₂ₙ₊₁ > 1 || R₂ₙ₊₂ > 1) { - R₂ₙ = 1; - R₂ₙ₊₁ = 1; - R₂ₙ₊₂ = 1; - } - - if (C₂ₙ > 1 || C₂ₙ₊₁ > 1 || C₂ₙ₊₂ > 1) { - C₂ₙ = 1; - C₂ₙ₊₁ = 1; - C₂ₙ₊₂ = 1; - } - - if (R₂ₙ < 0 || R₂ₙ₊₁ < 0 || R₂ₙ₊₂ < 0) { - R₂ₙ = 0; - R₂ₙ₊₁ = 0; - R₂ₙ₊₂ = 0; - } - - if (C₂ₙ < 0 || C₂ₙ₊₁ < 0 || C₂ₙ₊₂ < 0) { - C₂ₙ = 0; - C₂ₙ₊₁ = 0; - C₂ₙ₊₂ = 0; - } - 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₂ₙ = R₂ₙ * df(λ, p, s, C₂ₙ); -- cgit v1.2.3-70-g09d2