From 1aa086ca71a4d0df138e6ebe5af0c6b0d03d8066 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 3 Jun 2017 10:31:53 +0200 Subject: [PATCH] com_fft.c, enable fft for clipped vectors --- src/frontend/com_fft.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/frontend/com_fft.c b/src/frontend/com_fft.c index 4ef273efe..d4c5733fa 100644 --- a/src/frontend/com_fft.c +++ b/src/frontend/com_fft.c @@ -165,8 +165,12 @@ com_fft(wordlist *wl) in = fftw_malloc(sizeof(double) * (unsigned int) length); out = fftw_malloc(sizeof(fftw_complex) * (unsigned int) fpts); - for (j = 0; j < length; j++) - in[j] = tdvec[i][j]*win[j]; + for (j = 0; j < length; j++) { + in[j] = tdvec[i][j] * win[j]; + /* check for clipped values (NaNs) */ + if (isnan(in[j])) + in[j] = 0.0; + } plan_forward = fftw_plan_dft_r2c_1d(length, in, out, FFTW_ESTIMATE); @@ -191,6 +195,9 @@ com_fft(wordlist *wl) in = TMALLOC(double, N); for (j = 0; j < length; j++) { in[j] = tdvec[i][j]*win[j]; + /* check for clipped values (NaNs) */ + if (isnan(in[j])) + in[j] = 0.0; } for (j = length; j < N; j++) { in[j] = 0.0;