Special Nyquist scaling only for even length.
Let nyquist bin not empty for odd vector
This commit is contained in:
parent
278841972c
commit
b3a78b02cc
|
|
@ -185,7 +185,10 @@ com_fft(wordlist *wl)
|
|||
fdvec[i][j].cx_real = out[j][0]/scale;
|
||||
fdvec[i][j].cx_imag = out[j][1]/scale;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -220,7 +223,7 @@ com_fft(wordlist *wl)
|
|||
fdvec[i][j].cx_real = in[2*j]/scale;
|
||||
fdvec[i][j].cx_imag = in[2*j+1]/scale;
|
||||
}
|
||||
fdvec[i][fpts-1].cx_real = in[1]/scale;
|
||||
fdvec[i][fpts-1].cx_real = in[1]/scale/2.0;
|
||||
fdvec[i][fpts-1].cx_imag = 0.0;
|
||||
|
||||
tfree(in);
|
||||
|
|
@ -416,15 +419,17 @@ com_psd(wordlist *wl)
|
|||
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++) {
|
||||
for (j = 1; j < fpts; 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;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -781,7 +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;
|
||||
}
|
||||
|
||||
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 */
|
||||
|
|
@ -808,7 +811,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
outdata[i].cx_real = datax[2*i]/scale;
|
||||
outdata[i].cx_imag = datax[2*i+1]/scale;
|
||||
}
|
||||
outdata[fpts-1].cx_real = datax[1]/scale;
|
||||
outdata[fpts-1].cx_real = datax[1]/scale/2.0;
|
||||
outdata[fpts-1].cx_imag = 0.0;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue