CARMA C++
|
C++ wrapper of real-to-real half-complex fftw_plans. More...
#include <carma/util/FftwRealToRealPlan.h>
Public Types | |
enum | Kind { REAL_TO_HALFCOMPLEX, HALFCOMPLEX_TO_REAL } |
Fftw supports many different kinds of real-to-real transforms, these are the ones supported by this wrapper. More... | |
enum | Rigor { ESTIMATE, MEASURE, PATIENT, EXHAUSTIVE } |
Fftw has several options for creating plans which substantially impact creation time but can also have a significant impact on fftw execution performance. More... | |
typedef ::std::map< enum Rigor,::std::string > | RigorEnumMap |
Public Member Functions | |
void | execute () |
Execute transform for this plan. More... | |
FftwRealToRealPlan (FftwRealVector::size_type size, FftwRealVector &data, enum Kind transformKind, enum Rigor minimumRigor=MEASURE) | |
Create an FftwRealToRealPlan. More... | |
FftwRealToRealPlan (const FftwRealToRealPlan &from) | |
Copy constructor. More... | |
enum Kind | getKind () const |
Retrieve kind. More... | |
FftwRealVector::size_type | getSize () const |
Retrieve size. More... | |
~FftwRealToRealPlan () | |
Destructor. More... | |
Static Public Member Functions | |
static void | exportWisdom (const ::std::string &filename) |
Export wisdom to the given file. More... | |
static void | forgetWisdom () |
Forget all wisdom. More... | |
static void | importWisdom (const ::std::string &filename) |
Import Fftw wisdom from the given file. More... | |
static RigorEnumMap | rigors () |
C++ wrapper of real-to-real half-complex fftw_plans.
The FFTW package uses an 'fftw_plan' to calculate an fft. The fftw paradigm is to create a plan for each type of fft you will be doing (e.g. a 32 point, 1-dimensional forward real to complex fft), store it away somewhere and then call the execute( plan ) routine when you want to perform the actual fft. Plans can be reused as often as needed.
Unlike fftw this class normalizes on reverse transforms.
The FftwRealToRealPlanManager class is useful for managing a large collection of plan size and types married to a single vector.
Definition at line 42 of file FftwRealToRealPlan.h.
Fftw supports many different kinds of real-to-real transforms, these are the ones supported by this wrapper.
Others can be easily added in the future. See the fftw manual for a description of the halfcomplex format.
Definition at line 51 of file FftwRealToRealPlan.h.
Fftw has several options for creating plans which substantially impact creation time but can also have a significant impact on fftw execution performance.
Care should be taken to use a planning rigor appropriate for the performance needed at plan creation time. Once calculated, plan 'wisdom' can be saved and reused to avoid the one-time cost of creation. Note that by default, we always attempt to use wisdom first.
Definition at line 68 of file FftwRealToRealPlan.h.
|
explicit |
Create an FftwRealToRealPlan.
Once created an Fftw plan is forever married to the input data vector (as it is with the core fftw interface), and hence the vector must not reallocate underlying storage. Vector reallocation is checked for internally and an exception will be thrown if reallocation is detected. Note that reallocation is not the same as resizing - you can resize the vector and reuse it with other instances of FftwRealToRealPlan, just make sure to reserve enough space with vector.reserve() prior to instantiating all plans.
The specified rigor dramatically impacts plan creation time (the most rigorous can take many seconds). This can be minimized by taking advantage of saved wisdom (
size | Number of input points to transform. |
data | Reference to preallocated data vector. |
transformKind | Type of transform. |
minimumRigor | Specifies how rigorously to optimize plan. |
ErrorException | if input data vector is empty. |
carma::util::FftwRealToRealPlan::FftwRealToRealPlan | ( | const FftwRealToRealPlan & | from | ) |
Copy constructor.
This creates a new fftw plan and can be a large performance hit if wisdom was forgotten (e.g. forgetWisdom called).
carma::util::FftwRealToRealPlan::~FftwRealToRealPlan | ( | ) |
Destructor.
void carma::util::FftwRealToRealPlan::execute | ( | ) |
Execute transform for this plan.
ErrorException | if vector reallocation is detected or size has been trimmed. |
|
static |
Export wisdom to the given file.
filename | Name of file to export wisdom to. on file error. |
|
static |
Forget all wisdom.
Useful for creating fresh new wisdom (contradiction in terms?).
enum Kind carma::util::FftwRealToRealPlan::getKind | ( | ) | const |
Retrieve kind.
FftwRealVector::size_type carma::util::FftwRealToRealPlan::getSize | ( | ) | const |
Retrieve size.
|
static |
Import Fftw wisdom from the given file.
Fftw wisdom is persistent optimization information for plans. Each time a plan is created, wisdom is accumulated and stored in global memory. This information can then be exported or imported to facilitate quick plan creation in the future. Using the most rigorous plan creation modes can take many seconds so this is a useful optimization if first time plan creation latency is a problem.
filename | Name of file to import wisdom from. |
FileNotFoundException | |
ErrorException |