summaryrefslogtreecommitdiff
path: root/log-fourier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'log-fourier.cpp')
-rw-r--r--log-fourier.cpp38
1 files changed, 13 insertions, 25 deletions
diff --git a/log-fourier.cpp b/log-fourier.cpp
index 11edfcb..e60439a 100644
--- a/log-fourier.cpp
+++ b/log-fourier.cpp
@@ -64,6 +64,8 @@ std::vector<Complex> LogarithmicFourierTransform::fourier(const std::vector<Real
for (unsigned n = 0; n < pad*N; n++) {
if (n < N) {
a[n] = c[n] * exp((1 - k) * τ(n));
+ } else if (n >= (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<Real> LogarithmicFourierTransform::inverse(const std::vector<Complex
for (unsigned n = 0; n < pad * N; n++) {
if (n < N) {
a[n] = (ĉ[n].real() + II * σ * ĉ[n].imag()) * std::exp((1 - k) * ω(n));
+ } else if (n >= (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;
}
@@ -184,8 +188,14 @@ 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 = 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++) {
+ 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;
+ }
+ */
+ Real E = fft.t(2*n₀) * df(λ, p, s, 1);
+ for (unsigned n = n₀; n < C.size()/2-1; n++) {
Real R₂ₙ = R[2*n];
Real R₂ₙ₊₁ = R[2*n+1];
Real R₂ₙ₊₂ = R[2*n+2];
@@ -193,29 +203,7 @@ Real energy(const LogarithmicFourierTransform& fft, std::vector<Real>& 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;
- }
+ //if (C₂ₙ₊₂ < 0 || R₂ₙ₊₂ < 0) break;
Real h₂ₙ = fft.t(2*n+1) - fft.t(2*n);
Real h₂ₙ₊₁ = fft.t(2*n+2) - fft.t(2*n+1);