cmath4.c, com_fft.c, cleanup
This commit is contained in:
parent
f989219f6f
commit
cd8aa1ee04
|
|
@ -41,8 +41,6 @@ com_fft(wordlist *wl)
|
||||||
|
|
||||||
#ifdef GREEN
|
#ifdef GREEN
|
||||||
int M;
|
int M;
|
||||||
#else
|
|
||||||
int sign;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double *reald = NULL, *imagd = NULL;
|
double *reald = NULL, *imagd = NULL;
|
||||||
|
|
@ -64,7 +62,7 @@ com_fft(wordlist *wl)
|
||||||
span = time[tlen-1] - time[0];
|
span = time[tlen-1] - time[0];
|
||||||
|
|
||||||
#ifdef GREEN
|
#ifdef GREEN
|
||||||
// size of input vector is power of two and larger than spice vector
|
/* size of fft input vector is power of two and larger or equal than spice vector */
|
||||||
N = 1;
|
N = 1;
|
||||||
M = 0;
|
M = 0;
|
||||||
while (N < tlen) {
|
while (N < tlen) {
|
||||||
|
|
@ -182,7 +180,8 @@ com_fft(wordlist *wl)
|
||||||
fftInit(M);
|
fftInit(M);
|
||||||
rffts(reald, M, 1);
|
rffts(reald, M, 1);
|
||||||
fftFree();
|
fftFree();
|
||||||
scale = N;
|
|
||||||
|
scale = (double) N;
|
||||||
/* 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]). */
|
||||||
for (j = 0; j < fpts; j++) {
|
for (j = 0; j < fpts; j++) {
|
||||||
fdvec[i][j].cx_real = reald[2*j]/scale;
|
fdvec[i][j].cx_real = reald[2*j]/scale;
|
||||||
|
|
@ -190,8 +189,7 @@ com_fft(wordlist *wl)
|
||||||
}
|
}
|
||||||
fdvec[i][0].cx_imag = 0;
|
fdvec[i][0].cx_imag = 0;
|
||||||
#else
|
#else
|
||||||
sign = 1;
|
fftext(reald, imagd, N, tlen, 1 /* forward */);
|
||||||
fftext(reald, imagd, N, tlen, sign);
|
|
||||||
scale = 0.66;
|
scale = 0.66;
|
||||||
|
|
||||||
for (j = 0; j < fpts; j++) {
|
for (j = 0; j < fpts; j++) {
|
||||||
|
|
@ -258,7 +256,7 @@ com_psd(wordlist *wl)
|
||||||
|
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
|
|
||||||
// size of input vector is power of two and larger than spice vector
|
/* size of fft input vector is power of two and larger or equal than spice vector */
|
||||||
N = 1;
|
N = 1;
|
||||||
M = 0;
|
M = 0;
|
||||||
while (N < tlen) {
|
while (N < tlen) {
|
||||||
|
|
@ -267,7 +265,7 @@ com_psd(wordlist *wl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// output vector has length of N/2
|
// output vector has length of N/2
|
||||||
fpts = N>>1;
|
fpts = N/2;
|
||||||
|
|
||||||
win = TMALLOC(double, tlen);
|
win = TMALLOC(double, tlen);
|
||||||
maxt = time[tlen-1];
|
maxt = time[tlen-1];
|
||||||
|
|
@ -375,7 +373,8 @@ com_psd(wordlist *wl)
|
||||||
fftInit(M);
|
fftInit(M);
|
||||||
rffts(reald, M, 1);
|
rffts(reald, M, 1);
|
||||||
fftFree();
|
fftFree();
|
||||||
scaling = N;
|
|
||||||
|
scaling = (double) N;
|
||||||
|
|
||||||
/* 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]). */
|
||||||
intres = (double)N * (double)N;
|
intres = (double)N * (double)N;
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* size of fft input vector is power of two and larger than spice vector */
|
/* size of fft input vector is power of two and larger or equal than spice vector */
|
||||||
N = 1;
|
N = 1;
|
||||||
M = 0;
|
M = 0;
|
||||||
while (N < 2*length) {
|
while (N < 2*length) {
|
||||||
|
|
@ -714,7 +714,7 @@ cx_ifft(void *data, short int type, int length, int *newlength, short int *newty
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* output vector has same length as input vector */
|
/* output vector has same length as input vector */
|
||||||
tpts = length;
|
tpts = length;
|
||||||
|
|
||||||
xscale = TMALLOC(double, tpts);
|
xscale = TMALLOC(double, tpts);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue