From 32e0d5f12f72cb35ffcca719029513917c58f3f9 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 6 Mar 2026 16:31:29 +0100 Subject: [PATCH] Revert "make fft scaling independent from rounding behaviour for odd data" This reverts commit a31ac54200e3872f28500f9762c49f1369898029. --- src/frontend/com_fft.c | 4 ++-- src/maths/cmaths/cmath4.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontend/com_fft.c b/src/frontend/com_fft.c index 8b74414fc..d3b68056a 100644 --- a/src/frontend/com_fft.c +++ b/src/frontend/com_fft.c @@ -63,7 +63,6 @@ com_fft(wordlist *wl) #ifdef HAVE_LIBFFTW3 fpts = length/2 + 1; - scale = ((double)length)/2.0; #else /* size of fft input vector is power of two and larger or equal than spice vector */ N = 1; @@ -73,7 +72,6 @@ com_fft(wordlist *wl) M++; } fpts = N/2 + 1; - scale = ((double)N)/2; #endif win = TMALLOC(double, length); @@ -180,6 +178,7 @@ com_fft(wordlist *wl) fftw_execute(plan_forward); + scale = (double) fpts - 1.0; fdvec[i][0].cx_real = out[0][0]/scale/2.0; fdvec[i][0].cx_imag = 0.0; for (j = 1; j < fpts; j++) { @@ -216,6 +215,7 @@ com_fft(wordlist *wl) rffts(in, M, 1); fftFree(); + scale = (double) fpts - 1.0; /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ fdvec[i][0].cx_real = in[0]/scale/2.0; fdvec[i][0].cx_imag = 0.0; diff --git a/src/maths/cmaths/cmath4.c b/src/maths/cmaths/cmath4.c index 04b0b5142..af661e968 100644 --- a/src/maths/cmaths/cmath4.c +++ b/src/maths/cmaths/cmath4.c @@ -774,7 +774,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp fftw_execute(plan_forward); - scale = ((double)length)/2.0; + scale = (double) fpts - 1.0; outdata[0].cx_real = out[0][0]/scale/2.0; outdata[0].cx_imag = 0.0; for (i = 1; i < fpts; i++) { @@ -803,7 +803,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp rffts(datax, M, 1); fftFree(); - scale = ((double)N)/2; + scale = (double) fpts - 1.0; /* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */ outdata[0].cx_real = datax[0]/scale/2.0; outdata[0].cx_imag = 0.0;