From 3a4db1fed7d3dbfa3a519fc331869eaa245e2a53 Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Mon, 18 May 2009 03:23:38 +0000 Subject: [PATCH] *** empty log message *** --- kissfft.hh | 85 +++++++++++++++++++------------------------------ test/testcpp.cc | 2 +- 2 files changed, 34 insertions(+), 53 deletions(-) diff --git a/kissfft.hh b/kissfft.hh index 2508750..a586cb1 100644 --- a/kissfft.hh +++ b/kissfft.hh @@ -22,8 +22,9 @@ struct traits std::vector & stageRadix, std::vector & stageRemainder ) { - dst.resize(nfft); - fill_twiddles( &dst[0],nfft,inverse); + _twiddles.resize(nfft); + fill_twiddles( &_twiddles[0],nfft,inverse); + dst = _twiddles; //factorize //start factoring out 4's, then 2's, then 3,5,7,9,... @@ -44,7 +45,10 @@ struct traits stageRemainder.push_back(n); }while(n>1); } - //const std::complex twiddle(int i) { return _twiddle[i]; } + std::vector _twiddles; + + + const cpx_type twiddle(int i) { return _twiddles[i]; } }; } @@ -67,11 +71,11 @@ class kissfft void transform(const cpx_type * src , cpx_type * dst) { - kf_work(0, dst, src, 1); + kf_work(0, dst, src, 1,1); } private: - void kf_work( int stage,cpx_type * Fout, const cpx_type * f, const size_t fstride) + void kf_work( int stage,cpx_type * Fout, const cpx_type * f, size_t fstride,size_t in_stride) { int p = _stageRadix[stage]; int m = _stageRemainder[stage]; @@ -81,7 +85,7 @@ class kissfft if (m==1) { do{ *Fout = *f; - f += fstride; + f += fstride*in_stride; }while(++Fout != Fout_end ); }else{ do{ @@ -89,8 +93,8 @@ class kissfft // DFT of size m*p performed by doing // p instances of smaller DFTs of size m, // each one takes a decimated version of the input - kf_work(stage+1, Fout , f, fstride*p); - f += fstride; + kf_work(stage+1, Fout , f, fstride*p,in_stride); + f += fstride*in_stride; }while( (Fout += m) != Fout_end ); } @@ -118,56 +122,33 @@ class kissfft void kf_bfly2( cpx_type * Fout, const size_t fstride, int m) { - cpx_type * Fout2; - cpx_type * tw1 = &_twiddles[0]; - cpx_type t; - Fout2 = Fout + m; - do{ - C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); - - C_MUL (t, *Fout2 , *tw1); - tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; - }while (--m); + for (int k=0;k(32); dotest(32); dotest(32); dotest(1024); dotest(1024); dotest(1024); - dotest(1800); dotest(1800); dotest(1800); + dotest(840); dotest(840); dotest(840); } return 0; }