CARMA C++
carma::util::FftwRealToRealPlan Class Reference

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 ()
 

Detailed Description

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.

Member Enumeration Documentation

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.

See Also
importWisdom
exportWisdom
forgetWisdom

Definition at line 68 of file FftwRealToRealPlan.h.

Constructor & Destructor Documentation

carma::util::FftwRealToRealPlan::FftwRealToRealPlan ( FftwRealVector::size_type  size,
FftwRealVector &  data,
enum Kind  transformKind,
enum Rigor  minimumRigor = MEASURE 
)
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 (

See Also
importWisdom). If a more rigorous plan already exists in wisdom it will be used instead of the specified rigor.
Parameters
sizeNumber of input points to transform.
dataReference to preallocated data vector.
transformKindType of transform.
minimumRigorSpecifies how rigorously to optimize plan.
Exceptions
ErrorExceptionif 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.

Member Function Documentation

void carma::util::FftwRealToRealPlan::execute ( )

Execute transform for this plan.

Exceptions
ErrorExceptionif vector reallocation is detected or size has been trimmed.
static void carma::util::FftwRealToRealPlan::exportWisdom ( const ::std::string &  filename)
static

Export wisdom to the given file.

Parameters
filenameName of file to export wisdom to. on file error.
See Also
importWisdom
forgetWisdom
static void carma::util::FftwRealToRealPlan::forgetWisdom ( )
static

Forget all wisdom.

Useful for creating fresh new wisdom (contradiction in terms?).

See Also
importWisdom
seeWisdom
enum Kind carma::util::FftwRealToRealPlan::getKind ( ) const

Retrieve kind.

FftwRealVector::size_type carma::util::FftwRealToRealPlan::getSize ( ) const

Retrieve size.

static void carma::util::FftwRealToRealPlan::importWisdom ( const ::std::string &  filename)
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.

Parameters
filenameName of file to import wisdom from.
Exceptions
FileNotFoundException
ErrorException
See Also
exportWisdom
forgetWisdom

The documentation for this class was generated from the following file: