mirror of
https://github.com/mborgerding/kissfft.git
synced 2025-06-03 00:58:12 -04:00
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
This commit is contained in:
parent
7ec9402d5b
commit
043da3b65d
36
kiss_fft.c
36
kiss_fft.c
@ -39,14 +39,11 @@ typedef struct {
|
|||||||
kiss_fft_cpx * scratch;
|
kiss_fft_cpx * scratch;
|
||||||
}kiss_fft_state;
|
}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) \
|
#ifdef FIXED_POINT
|
||||||
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)
|
|
||||||
/* We don't have to worry about overflow from multiplying by twiddle factors since they
|
/* 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
|
* all have unity magnitude. Still need to shift away fractional bits after adding 1/2 for
|
||||||
* rounding.
|
* rounding.
|
||||||
@ -58,12 +55,6 @@ typedef struct {
|
|||||||
|
|
||||||
#else // not FIXED_POINT
|
#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) \
|
#define C_MUL(m,a,b) \
|
||||||
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
|
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
|
||||||
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
|
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
|
||||||
@ -83,12 +74,6 @@ kiss_fft_cpx cexp(double phase)
|
|||||||
return x;
|
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)
|
static kiss_fft_cpx cadd(kiss_fft_cpx a,kiss_fft_cpx b)
|
||||||
{
|
{
|
||||||
kiss_fft_cpx c;
|
kiss_fft_cpx c;
|
||||||
@ -120,15 +105,20 @@ void fft_work(
|
|||||||
int m,p=0,q,q1,u,k;
|
int m,p=0,q,q1,u,k;
|
||||||
kiss_fft_cpx t;
|
kiss_fft_cpx t;
|
||||||
|
|
||||||
|
/*
|
||||||
if (n==1) {
|
if (n==1) {
|
||||||
*Fout = *f;
|
*Fout = *f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
p=*factors++;
|
p=*factors++;
|
||||||
m=*factors++;//m = n/p;
|
m=*factors++;//m = n/p;
|
||||||
|
|
||||||
for (q=0;q<p;++q) {
|
for (q=0;q<p;++q) {
|
||||||
fft_work( Fout + m*q, f+q*fstride, fstride*p, m,Norig,inverse, scratch ,twiddles,factors);
|
if (m==1)
|
||||||
|
*(Fout + m*q) = *(f+q*fstride);
|
||||||
|
else
|
||||||
|
fft_work( Fout + m*q, f+q*fstride, fstride*p, m,Norig,inverse, scratch ,twiddles,factors);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( u=0; u<m; ++u ) {
|
for ( u=0; u<m; ++u ) {
|
||||||
@ -177,7 +167,6 @@ void * kiss_fft_alloc(int nfft,int inverse_fft)
|
|||||||
st->twiddles = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
st->twiddles = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
||||||
st->tmpbuf = (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->scratch = (kiss_fft_cpx*)malloc( sizeof(kiss_fft_cpx)*nfft );
|
||||||
|
|
||||||
st->factors = (int*)malloc( sizeof(int)*nfft );
|
st->factors = (int*)malloc( sizeof(int)*nfft );
|
||||||
|
|
||||||
for (i=0;i<nfft;++i) {
|
for (i=0;i<nfft;++i) {
|
||||||
@ -212,9 +201,6 @@ void kiss_fft(const void * cfg,kiss_fft_cpx *f)
|
|||||||
const kiss_fft_state * st = cfg;
|
const kiss_fft_state * st = cfg;
|
||||||
|
|
||||||
n = st->nfft;
|
n = st->nfft;
|
||||||
|
memcpy(st->tmpbuf,f,sizeof(kiss_fft_cpx)*n);
|
||||||
for (i=0;i<n;++i)
|
|
||||||
st->tmpbuf[i] = f[i];
|
|
||||||
|
|
||||||
fft_work( f, st->tmpbuf, 1, n,n, st->inverse, st->scratch ,st->twiddles,st->factors);
|
fft_work( f, st->tmpbuf, 1, n,n, st->inverse, st->scratch ,st->twiddles,st->factors);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user