Browse Source

correct the fft scaling for real input and complex output vector

pre-master-46
dwarning 9 years ago
parent
commit
b8a9ca9df4
  1. 4
      src/frontend/com_fft.c
  2. 4
      src/maths/cmaths/cmath4.c

4
src/frontend/com_fft.c

@ -172,7 +172,7 @@ com_fft(wordlist *wl)
fftw_execute(plan_forward); fftw_execute(plan_forward);
scale = (double) length;
scale = (double) fpts - 1.0;
for (j = 0; j < fpts; j++) { for (j = 0; j < fpts; j++) {
fdvec[i][j].cx_real = out[j][0]/scale; fdvec[i][j].cx_real = out[j][0]/scale;
fdvec[i][j].cx_imag = out[j][1]/scale; fdvec[i][j].cx_imag = out[j][1]/scale;
@ -200,7 +200,7 @@ com_fft(wordlist *wl)
rffts(in, M, 1); rffts(in, M, 1);
fftFree(); fftFree();
scale = (double) N;
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]). */ /* 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; fdvec[i][0].cx_real = in[0]/scale;
fdvec[i][0].cx_imag = 0.0; fdvec[i][0].cx_imag = 0.0;

4
src/maths/cmaths/cmath4.c

@ -716,7 +716,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
fftw_execute(plan_forward); fftw_execute(plan_forward);
scale = (double) length;
scale = (double) fpts - 1.0;
for (i = 0; i < fpts; i++) { for (i = 0; i < fpts; i++) {
outdata[i].cx_real = out[i][0]/scale; outdata[i].cx_real = out[i][0]/scale;
outdata[i].cx_imag = out[i][1]/scale; outdata[i].cx_imag = out[i][1]/scale;
@ -740,7 +740,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
rffts(datax, M, 1); rffts(datax, M, 1);
fftFree(); fftFree();
scale = (double) N;
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]). */ /* 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; outdata[0].cx_real = datax[0]/scale;
outdata[0].cx_imag = 0.0; outdata[0].cx_imag = 0.0;

Loading…
Cancel
Save