Skip to content

Commit

Permalink
Only normalize first half of FFT result
Browse files Browse the repository at this point in the history
  • Loading branch information
sevagh committed May 6, 2018
1 parent 7c90024 commit 477b095
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::vector<double>
acorr_r(const std::vector<double> &signal)
{
int N = signal.size();
int N2 = 2 * N;// - 1;
int N2 = 2 * N;

auto fft_forward = ffts_init_1d(N2, false);
auto fft_backward = ffts_init_1d(N2, false);
Expand All @@ -36,7 +36,7 @@ acorr_r(const std::vector<double> &signal)
ffts_execute(fft_forward, signalb_ext.data(), outb.data());

std::complex<float> scale = {1.0f / (float)N2, 0.0};
for (int i = 0; i < N2; ++i)
for (int i = 0; i < N; ++i)
out[i] = outa[i] * std::conj(outb[i]) * scale;

ffts_execute(fft_backward, out.data(), result.data());
Expand Down

0 comments on commit 477b095

Please sign in to comment.