Special Nyquist scaling only for even length

This commit is contained in:
dwarning 2026-03-03 09:55:57 +01:00
parent 6ae057b3ea
commit a0dc0bb608
2 changed files with 12 additions and 8 deletions

View File

@ -185,9 +185,10 @@ com_fft(wordlist *wl)
fdvec[i][j].cx_real = out[j][0]/scale;
fdvec[i][j].cx_imag = out[j][1]/scale;
}
fdvec[i][fpts-1].cx_real = out[fpts-1][0]/scale/2.0;
fdvec[i][fpts-1].cx_imag = 0.0;
if (length % 2 == 0) {
fdvec[i][fpts-1].cx_real = out[fpts-1][0]/scale/2.0;
fdvec[i][fpts-1].cx_imag = 0.0;
}
}
fftw_destroy_plan(plan_forward);
@ -425,8 +426,10 @@ com_psd(wordlist *wl)
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;
if (length % 2 == 0) {
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 */

View File

@ -781,9 +781,10 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
outdata[i].cx_real = out[i][0]/scale;
outdata[i].cx_imag = out[i][1]/scale;
}
outdata[fpts-1].cx_real = out[fpts-1][0]/scale/2.0;
outdata[fpts-1].cx_imag = 0.0;
if (length % 2 == 0) {
outdata[fpts-1].cx_real = out[fpts-1][0]/scale/2.0;
outdata[fpts-1].cx_imag = 0.0;
}
fftw_free(ind);
#else /* Green's FFT */