From 043da3b65df1af0edad837428a28f35393f87e48 Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Sat, 11 Oct 2003 14:43:13 +0000 Subject: [PATCH] avoid last recursive call 'make test' output: ### testing SNR for 1024 point FFTs #### DOUBLE snr_t2f = 295.35 snr_f2t = 308.32 #### FLOAT snr_t2f = 146.71 snr_f2t = 143.02 #### SHORT snr_t2f = 54.718 snr_f2t = 24.494 #### timing 10000 x 1024 point FFTs #### DOUBLE Elapsed:0:23.05 user:18.95 sys:0.24 #### FLOAT Elapsed:0:06.45 user:5.17 sys:0.10 #### SHORT Elapsed:0:05.59 user:4.72 sys:0.06 --- kiss_fft.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/kiss_fft.c b/kiss_fft.c index 27a411c..4f2fe05 100644 --- a/kiss_fft.c +++ b/kiss_fft.c @@ -39,14 +39,11 @@ typedef struct { kiss_fft_cpx * scratch; }kiss_fft_state; -#ifdef FIXED_POINT +#define C_ADD(x,a,b) \ + do{ (x).r = (a).r+(b).r;\ + (x).i = (a).i+(b).i;}while(0) -# define C_ADD(x,a,b) \ - do{ (x).r = ( ( (a).r+(b).r ) );\ - (x).i = ( ( (a).i+(b).i ) ); }while(0) -# define C_SUB(x,a,b) \ - do{ (x).r = ( ( (a).r-(b).r ) );\ - (x).i = ( ( (a).i-(b).i ) ); }while(0) +#ifdef FIXED_POINT /* We don't have to worry about overflow from multiplying by twiddle factors since they * all have unity magnitude. Still need to shift away fractional bits after adding 1/2 for * rounding. @@ -58,12 +55,6 @@ typedef struct { #else // not FIXED_POINT -#define C_ADD(x,a,b) \ - do{ (x).r = (a).r+(b).r;\ - (x).i = (a).i+(b).i;}while(0) -#define C_SUB(x,a,b) \ - do{ (x).r = (a).r-(b).r;\ - (x).i = (a).i-(b).i;}while(0) #define C_MUL(m,a,b) \ do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) @@ -83,12 +74,6 @@ kiss_fft_cpx cexp(double phase) return x; } -static kiss_fft_cpx csub(kiss_fft_cpx a,kiss_fft_cpx b) -{ - kiss_fft_cpx c; - C_SUB(c,a,b); - return c; -} static kiss_fft_cpx cadd(kiss_fft_cpx a,kiss_fft_cpx b) { kiss_fft_cpx c; @@ -120,15 +105,20 @@ void fft_work( int m,p=0,q,q1,u,k; kiss_fft_cpx t; + /* if (n==1) { *Fout = *f; return; } + */ p=*factors++; m=*factors++;//m = n/p; for (q=0;qtwiddles = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft ); st->tmpbuf = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft ); st->scratch = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft ); - st->factors = (int*)malloc( sizeof(int)*nfft ); for (i=0;infft; - - for (i=0;itmpbuf[i] = f[i]; - + memcpy(st->tmpbuf,f,sizeof(kiss_fft_cpx)*n); fft_work( f, st->tmpbuf, 1, n,n, st->inverse, st->scratch ,st->twiddles,st->factors); }