diff options
Diffstat (limited to 'log-fourier.cpp')
-rw-r--r-- | log-fourier.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/log-fourier.cpp b/log-fourier.cpp index cb57229..1fa57c3 100644 --- a/log-fourier.cpp +++ b/log-fourier.cpp @@ -254,3 +254,25 @@ Real C0(const LogarithmicFourierTransform& fft, const std::vector<Complex>& Ĉ) return C * pow(fft.shift, 2) / M_PI; } +void smooth(std::vector<Real>& C, Real ε) { + unsigned N = C.size(); + bool trigger0 = false; + bool trigger1 = false; + for (unsigned i = 0; i < N; i++) { + if (C[i] < ε || trigger0) { + C[i] = 0; + trigger0 = true; + } + if (C[N-1-i] > 1 - ε || trigger1) { + C[N-1-i] = 1; + trigger1 = true; + } + } + + Real Cmax = 0; + for (unsigned i = 0; i < N; i++) { + if (C[N-1-i] > Cmax) Cmax = C[N-1-i]; + C[N-1-i] = Cmax; + } +} + |