30 #include "../system/eptexception.h"
31 #include "../system/log.h"
60 "FFT only implemented for real data type double.");
62 "FFT only implemented for complex data type std::complex<double>.");
86 catch (...)
LogE(
"fftw3_destroy_plan throwed an exception");
154 EptAssert(in.size()>0,
"vector size has to be nonzero");
165 mRvec1 = (
double *) malloc(
mNRC*
sizeof(
double));
166 mCvec2 = (fftw_complex*) fftw_malloc((
mNRC/2+1)*
sizeof(fftw_complex));
171 catch (...)
LogE(
"fftw_pplan_dft_r2c_1d throwed an exception");
197 EptAssert(in.size()>0,
"vector size has to be nonzero");
207 mNCR = 2*in.size()-2;
208 mCvec1 = (fftw_complex*) fftw_malloc((
mNCR/2+1)*
sizeof(fftw_complex));
209 mRvec2 = (
double *) malloc(
mNCR*
sizeof(
double));
214 catch (...)
LogE(
"fftw_pplan_dft_c2r_1d throwed an exception");
232 EptAssert (in.size()>=1,
"calling FFT with empty vector");
233 if (out.size() != in.size()/2+1) out.resize(in.size()/2+1);
237 std::memcpy(
mRvec1,in.data(),
mNRC*
sizeof(double));
239 std::memcpy(out.data(),
mCvec2,(
mNRC/2+1)*
sizeof(fftw_complex));
241 catch (...)
LogE(
"fftw_execute throwed an exception");
259 EptAssert (in.size()>=1,
"calling FFT with empty vector");
260 if (out.size() != 2*in.size()-2) out.resize(2*in.size()-2);
264 std::memcpy(
mCvec1,in.data(),(
mNCR/2+1)*
sizeof(fftw_complex));
266 std::memcpy(out.data(),
mRvec2,
mNCR*
sizeof(double));
268 catch (...)
LogE(
"fftw_execute throwed an exception");
fftw_complex * mCvec2
Local copy of outgoing complex data.
size_t mNRC
Size of the FFT real -> complex.
size_t mNCR
Size of the FFT complex -> real.
std::vector< FFTComplexType > FFTComplexVector
fftw_plan mPlanRC
Plan for FFT real -> complex.
double * mRvec1
Local copy of incoming real data.
std::complex< double > FFTComplexType
void updatePlan(const FFTRealVector &in, unsigned flags)
Construct a new plan for the FFT transformation if necessary.
~FFT_Implementation()
Destructor, deletes plans and local vector copies if existing.
fftw_plan mPlanCR
Plan for FFT complex -> real.
fftw_complex * mCvec1
Local copy of incoming complex data.
std::vector< FFTRealType > FFTRealVector
double * mRvec2
Local copy of outgoing real data.
void optimize(FFTRealVector &in)
Optimize plan for the forward transfomation.
void calculateFFT(const FFTRealVector &in, FFTComplexVector &out)
Foward FFT, mapping a real vector with size N to a complex one with size N/2+1.
FFT_Implementation()
Constructor, clears member variables and checks type consistency.
static std::mutex mPlanMutex
Static mutex protecting planmaking.