From 0ef666ea26d3e971ac5f4d58e25c5403d016fd68 Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 26 Aug 2017 17:20:19 +0200 Subject: [PATCH] com_psd: Correct the special handling of dc and nyquist component in fftw branch --- src/frontend/com_fft.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/com_fft.c b/src/frontend/com_fft.c index 0e06c594f..fdb45f29b 100644 --- a/src/frontend/com_fft.c +++ b/src/frontend/com_fft.c @@ -397,14 +397,19 @@ com_psd(wordlist *wl) scaling = (double) length; intres = (double)length * (double)length; - noipower = 0.0; - for (j = 0; j < fpts; j++) { + fdvec[i][0].cx_real = out[0][0]*out[0][0]/intres; + fdvec[i][0].cx_imag = 0; + noipower = fdvec[i][0].cx_real; + for (j = 1; j < fpts-1; j++) { fdvec[i][j].cx_real = 2.* (out[j][0]*out[j][0] + out[j][1]*out[j][1])/intres; fdvec[i][j].cx_imag = 0; noipower += fdvec[i][j].cx_real; if (!finite(noipower)) break; } + fdvec[i][fpts-1].cx_real = out[fpts-1][0]*out[fpts-1][0]/intres; + fdvec[i][fpts-1].cx_imag = 0; + noipower += fdvec[i][fpts-1].cx_real; #else /* Green's FFT */