LTL  2.0.x
Files | Classes
FFTW3 interface for MArrays

Files

file  fftw.h
 

Classes

class  ltl::FourierTransform< T, N >
 

Detailed Description

Interface to call libfftw3 FFT routines on MArrays up to rank 3.

Interface to fftw3 FFT library. Currently, each call to one of the FFT methods causes a new plan to be generated. This is highly inefficient, but safe. It guarantees that pointers to the data strorage of MArray do not escape by being stored in a plan that might survive the MArray object.

All transforms leave the output array un-normalized. To normalize (divide by number of elements) call normalize().

#include <ltl/fftw.h>
// example of 1-dimensional FFT using fftw3 library:
MArray<double, 1> in(size);
MArray<std::complex<double>, 1> out(size);
FourierTransform<double,1> FFT;
in = 10.0 +
20.0 * sin(indexPosDbl(in,1) / double(size) * 2.0 * M_PI * 3.0) +
30.0 * cos(indexPosDbl(in,1) / double(size) * 2.0 * M_PI * 4.0);
FFT.FFT_Real2Complex(in,out);
FFT.normalize(out);
out = merge(real(out * conj(out)) > 1e-9, out, 0);
std::cout << out << std::endl;