JayBeams  0.1
Another project to have fun coding.
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
jb::fftw::plan< in_timeseries_type, out_timeseries_type > Class Template Reference

Wrap FFTW3 plan objects. More...

#include <plan.hpp>

Classes

struct  check_constraints
 Check the compile-time constraints for a jb::fftw::plan<> More...
 

Public Types

using in_value_type = typename jb::detail::array_traits< in_timeseries_type >::element_type
 type traits More...
 
using precision_type = typename jb::extract_value_type< in_value_type >::precision
 
using traits = ::jb::fftw::traits< precision_type >
 
using std_complex_type = typename traits::std_complex_type
 
using fftw_complex_type = typename traits::fftw_complex_type
 
using fftw_plan_type = typename traits::fftw_plan_type
 

Public Member Functions

 plan ()
 Create unusable, empty, or null plan. More...
 
 plan (plan &&rhs)
 Basic move constructor. More...
 
planoperator= (plan &&rhs)
 Move assignment. More...
 
 ~plan ()
 Destructor, cleanup the plan. More...
 
void execute (in_timeseries_type const &in, out_timeseries_type &out) const
 Execute the plan for vectors. More...
 
Prevent copy construction and assignment
 plan (plan const &)=delete
 
planoperator= (plan const &)=delete
 

Private Member Functions

void execute_impl (fftw_complex_type const *in, fftw_complex_type *out) const
 Execute the plan in the c2c case. More...
 
void execute_impl (precision_type const *in, fftw_complex_type *out) const
 Execute the plan for arrays of r2c case. More...
 
void execute_impl (fftw_complex_type const *in, precision_type *out) const
 Execute the plan for arrays of r2c case. More...
 
 plan (fftw_plan_type p)
 Constructor from a raw FFTW plan. More...
 

Static Private Member Functions

static plan create_forward_impl (std::size_t nsamples, fftw_complex_type const *in, fftw_complex_type *out, int flags)
 Create the direct plan for vectors in the c2c case. More...
 
static plan create_backward_impl (std::size_t nsamples, fftw_complex_type const *in, fftw_complex_type *out, int flags)
 Create the inverse plan for vectors in the c2c case. More...
 
static plan create_forward_impl (std::size_t nsamples, precision_type const *in, fftw_complex_type *out, int flags)
 Create the plan for vectors in the r2c case. More...
 
static plan create_backward_impl (std::size_t nsamples, fftw_complex_type const *in, precision_type *out, int flags)
 Create the plan for vectors in the c2r case. More...
 
static plan create_forward_many_impl (int howmany, std::size_t nsamples, fftw_complex_type const *in, fftw_complex_type *out, int flags)
 Create the direct plan for arrays in the c2c case. More...
 
static plan create_backward_many_impl (int howmany, std::size_t nsamples, fftw_complex_type const *in, fftw_complex_type *out, int flags)
 Create the inverse plan for arrays in the c2c case. More...
 
static plan create_forward_many_impl (int howmany, std::size_t nsamples, precision_type const *in, fftw_complex_type *out, int flags)
 Create the batched plan for arrays in the r2c case. More...
 
static plan create_backward_many_impl (int howmany, std::size_t nsamples, fftw_complex_type const *in, precision_type *out, int flags)
 Create the batched plan for arrays in the c2r case. More...
 

Private Attributes

fftw_plan_type p_
 The raw FFTW plan. More...
 

Friends

template<typename itype , typename otype >
plan< itype, otype > create_forward_plan (itype const &, otype &, int)
 
template<typename itype , typename otype >
plan< itype, otype > create_backward_plan (itype const &, otype &, int)
 
template<typename itype , typename otype >
plan< itype, otype > create_forward_plan_1d (itype const &, otype &, int)
 
template<typename itype , typename otype >
plan< itype, otype > create_backward_plan_1d (itype const &, otype &, int)
 

Detailed Description

template<typename in_timeseries_type, typename out_timeseries_type>
class jb::fftw::plan< in_timeseries_type, out_timeseries_type >

Wrap FFTW3 plan objects.

The FFTW3 optimizes execution by pre-computing coefficients and execution plans for a DFT based on the original types, size and alingment of the data. In C++, we prefer the type system to remember details like this instead of getting an error message when we use the wrong types (or a crash).

In addition, the FFTW3 library uses different names for the types that have single (fftwf_*), double (fftw_*) or quad-precision (fftwl_*). In C++ we prefer to hide such details in generics.

Finally, these plans must be destroyed to release resources. FFTW3, being a C library, requires wrappers to automate the destruction of these objects.

Template Parameters
in_timeseries_typethe type of the input timeseries
out_timeseries_typethe type of the output timeseries

Definition at line 55 of file plan.hpp.

Member Typedef Documentation

◆ fftw_complex_type

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::fftw_complex_type = typename traits::fftw_complex_type

Definition at line 67 of file plan.hpp.

◆ fftw_plan_type

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::fftw_plan_type = typename traits::fftw_plan_type

Definition at line 68 of file plan.hpp.

◆ in_value_type

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::in_value_type = typename jb::detail::array_traits<in_timeseries_type>::element_type

type traits

Definition at line 62 of file plan.hpp.

◆ precision_type

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::precision_type = typename jb::extract_value_type<in_value_type>::precision

Definition at line 64 of file plan.hpp.

◆ std_complex_type

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::std_complex_type = typename traits::std_complex_type

Definition at line 66 of file plan.hpp.

◆ traits

template<typename in_timeseries_type, typename out_timeseries_type>
using jb::fftw::plan< in_timeseries_type, out_timeseries_type >::traits = ::jb::fftw::traits<precision_type>

Definition at line 65 of file plan.hpp.

Constructor & Destructor Documentation

◆ plan() [1/4]

template<typename in_timeseries_type, typename out_timeseries_type>
jb::fftw::plan< in_timeseries_type, out_timeseries_type >::plan ( )
inline

Create unusable, empty, or null plan.

Definition at line 72 of file plan.hpp.

◆ plan() [2/4]

template<typename in_timeseries_type, typename out_timeseries_type>
jb::fftw::plan< in_timeseries_type, out_timeseries_type >::plan ( plan< in_timeseries_type, out_timeseries_type > &&  rhs)
inline

Basic move constructor.

Definition at line 77 of file plan.hpp.

◆ ~plan()

template<typename in_timeseries_type, typename out_timeseries_type>
jb::fftw::plan< in_timeseries_type, out_timeseries_type >::~plan ( )
inline

Destructor, cleanup the plan.

Definition at line 90 of file plan.hpp.

◆ plan() [3/4]

template<typename in_timeseries_type, typename out_timeseries_type>
jb::fftw::plan< in_timeseries_type, out_timeseries_type >::plan ( plan< in_timeseries_type, out_timeseries_type > const &  )
delete

◆ plan() [4/4]

template<typename in_timeseries_type, typename out_timeseries_type>
jb::fftw::plan< in_timeseries_type, out_timeseries_type >::plan ( fftw_plan_type  p)
inlineexplicitprivate

Constructor from a raw FFTW plan.

Parameters
pthe raw FFTW plan

Definition at line 207 of file plan.hpp.

Member Function Documentation

◆ create_backward_impl() [1/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_impl ( std::size_t  nsamples,
fftw_complex_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the inverse plan for vectors in the c2c case.

Definition at line 151 of file plan.hpp.

Referenced by jb::fftw::create_backward_plan().

◆ create_backward_impl() [2/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_impl ( std::size_t  nsamples,
fftw_complex_type const *  in,
precision_type out,
int  flags 
)
inlinestaticprivate

Create the plan for vectors in the c2r case.

Definition at line 165 of file plan.hpp.

◆ create_backward_many_impl() [1/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_many_impl ( int  howmany,
std::size_t  nsamples,
fftw_complex_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the inverse plan for arrays in the c2c case.

Definition at line 180 of file plan.hpp.

Referenced by jb::fftw::create_backward_plan().

◆ create_backward_many_impl() [2/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_many_impl ( int  howmany,
std::size_t  nsamples,
fftw_complex_type const *  in,
precision_type out,
int  flags 
)
inlinestaticprivate

Create the batched plan for arrays in the c2r case.

Definition at line 195 of file plan.hpp.

◆ create_forward_impl() [1/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_impl ( std::size_t  nsamples,
fftw_complex_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the direct plan for vectors in the c2c case.

Definition at line 144 of file plan.hpp.

Referenced by jb::fftw::create_forward_plan().

◆ create_forward_impl() [2/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_impl ( std::size_t  nsamples,
precision_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the plan for vectors in the r2c case.

Definition at line 158 of file plan.hpp.

◆ create_forward_many_impl() [1/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_many_impl ( int  howmany,
std::size_t  nsamples,
fftw_complex_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the direct plan for arrays in the c2c case.

Definition at line 172 of file plan.hpp.

Referenced by jb::fftw::create_forward_plan().

◆ create_forward_many_impl() [2/2]

template<typename in_timeseries_type, typename out_timeseries_type>
static plan jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_many_impl ( int  howmany,
std::size_t  nsamples,
precision_type const *  in,
fftw_complex_type out,
int  flags 
)
inlinestaticprivate

Create the batched plan for arrays in the r2c case.

Definition at line 188 of file plan.hpp.

◆ execute()

template<typename in_timeseries_type, typename out_timeseries_type>
void jb::fftw::plan< in_timeseries_type, out_timeseries_type >::execute ( in_timeseries_type const &  in,
out_timeseries_type &  out 
) const
inline

◆ execute_impl() [1/3]

template<typename in_timeseries_type, typename out_timeseries_type>
void jb::fftw::plan< in_timeseries_type, out_timeseries_type >::execute_impl ( fftw_complex_type const *  in,
fftw_complex_type out 
) const
inlineprivate

Execute the plan in the c2c case.

Definition at line 129 of file plan.hpp.

◆ execute_impl() [2/3]

template<typename in_timeseries_type, typename out_timeseries_type>
void jb::fftw::plan< in_timeseries_type, out_timeseries_type >::execute_impl ( precision_type const *  in,
fftw_complex_type out 
) const
inlineprivate

Execute the plan for arrays of r2c case.

Definition at line 134 of file plan.hpp.

◆ execute_impl() [3/3]

template<typename in_timeseries_type, typename out_timeseries_type>
void jb::fftw::plan< in_timeseries_type, out_timeseries_type >::execute_impl ( fftw_complex_type const *  in,
precision_type out 
) const
inlineprivate

Execute the plan for arrays of r2c case.

Definition at line 139 of file plan.hpp.

◆ operator=() [1/2]

template<typename in_timeseries_type, typename out_timeseries_type>
plan& jb::fftw::plan< in_timeseries_type, out_timeseries_type >::operator= ( plan< in_timeseries_type, out_timeseries_type > &&  rhs)
inline

Move assignment.

Definition at line 83 of file plan.hpp.

◆ operator=() [2/2]

template<typename in_timeseries_type, typename out_timeseries_type>
plan& jb::fftw::plan< in_timeseries_type, out_timeseries_type >::operator= ( plan< in_timeseries_type, out_timeseries_type > const &  )
delete

Friends And Related Function Documentation

◆ create_backward_plan

template<typename in_timeseries_type, typename out_timeseries_type>
template<typename itype , typename otype >
plan<itype, otype> create_backward_plan ( itype const &  ,
otype &  ,
int   
)
friend

◆ create_backward_plan_1d

template<typename in_timeseries_type, typename out_timeseries_type>
template<typename itype , typename otype >
plan<itype, otype> create_backward_plan_1d ( itype const &  ,
otype &  ,
int   
)
friend

◆ create_forward_plan

template<typename in_timeseries_type, typename out_timeseries_type>
template<typename itype , typename otype >
plan<itype, otype> create_forward_plan ( itype const &  ,
otype &  ,
int   
)
friend

◆ create_forward_plan_1d

template<typename in_timeseries_type, typename out_timeseries_type>
template<typename itype , typename otype >
plan<itype, otype> create_forward_plan_1d ( itype const &  ,
otype &  ,
int   
)
friend

Member Data Documentation

◆ p_

template<typename in_timeseries_type, typename out_timeseries_type>
fftw_plan_type jb::fftw::plan< in_timeseries_type, out_timeseries_type >::p_
private

The raw FFTW plan.

Definition at line 213 of file plan.hpp.

Referenced by jb::fftw::plan< timeseries_type, frequency_timeseries_type >::operator=().


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