JayBeams  0.1
Another project to have fun coding.
Namespaces | Classes | Typedefs | Functions | Variables
jb::fftw Namespace Reference

Wrappers for the FFTW3 library. More...

Namespaces

 detail
 

Classes

class  allocator
 Define an allocator based on fftw_malloc()/fftw_free() More...
 
class  plan
 Wrap FFTW3 plan objects. More...
 
class  tde_result
 A time-delay estimator (TDE) is an algorithm to compare two families of timeseries and return the estimated delay of the first family vs. More...
 
class  tde_result< boost::multi_array< T, 1, A >, value_t >
 Handles TDE result for a multi array type timeseries with dimensionality 1. More...
 
class  tde_result< boost::multi_array< T, K, A >, value_t >
 Handles TDE result for a multi array type timeseries. More...
 
class  time_delay_estimator
 A simple time delay estimator based on cross-correlation. More...
 
class  time_delay_estimator_many
 A time delay estimator based on cross-correlation. More...
 
struct  traits
 Wrap fftw_* types and operations to treat floating point values generically. More...
 
struct  traits< double >
 Wrap the FFTW types and functions for double precision float point numbers. More...
 
struct  traits< float >
 Wrap the FFTW types and functions for single precision float point numbers. More...
 
struct  traits< long double >
 Wrap the FFTW types and functions for quad precision float point numbers. More...
 
struct  traits< std::complex< T > >
 Define traits for std::complex<T> in terms of the traits for T. More...
 

Typedefs

template<typename value_type , std::size_t num_dims>
using aligned_multi_array = boost::multi_array< value_type, num_dims, jb::fftw::allocator< value_type > >
 Alias boost::multi_array with properly allocated storage for FFTW3. More...
 
template<typename T >
using aligned_vector = std::vector< T, jb::fftw::allocator< T > >
 Alias std::vector with properly allocated storage for FFTW3. More...
 

Functions

template<typename F >
traits< F >::fftw_complex_type * fftw_cast_array (std::complex< F > *ptr)
 
template<typename F >
traits< F >::fftw_complex_type const * fftw_cast_array (std::complex< F > const *ptr)
 
template<typename F >
F * fftw_cast_array (F *ptr)
 
template<typename F >
F const * fftw_cast_array (F const *ptr)
 
template<typename vector >
auto fftw_cast (vector &in) -> decltype(fftw_cast_array(&in[0]))
 
template<typename vector >
auto fftw_cast (vector const &in) -> decltype(fftw_cast_array(&in[0]))
 
template<typename T , std::size_t K, typename A >
auto fftw_cast (boost::multi_array< T, K, A > const &a) -> decltype(fftw_cast_array(a.data()))
 
template<typename T , std::size_t K, typename A >
auto fftw_cast (boost::multi_array< T, K, A > &a) -> decltype(fftw_cast_array(a.data()))
 
template<typename in_array_type , typename out_array_type >
plan< in_array_type, out_array_type > create_forward_plan (in_array_type const &in, out_array_type &out, int flags=default_plan_flags)
 Create a plan to compute many DFTs given the input and output arrays. More...
 
template<typename in_array_type , typename out_array_type >
plan< in_array_type, out_array_type > create_backward_plan (in_array_type const &in, out_array_type &out, int flags=default_plan_flags)
 Create a plan to compute many inverse DFT given the input and output arrays. More...
 

Variables

int constexpr default_plan_flags
 

Detailed Description

Wrappers for the FFTW3 library.


Class Documentation

◆ jb::fftw::traits

struct jb::fftw::traits

template<typename precision_t>
struct jb::fftw::traits< precision_t >

Wrap fftw_* types and operations to treat floating point values generically.

Type traits to handle single-precision (float / fftwf_*), double-precision (double / fftw_*) and quad-precision (long double / fftwl_*) generically in C++ code.

Template Parameters
precision_tthe type of floating point value, must be either float, double or long double.

Definition at line 22 of file traits.hpp.

Typedef Documentation

◆ aligned_multi_array

template<typename value_type , std::size_t num_dims>
using jb::fftw::aligned_multi_array = typedef boost::multi_array<value_type, num_dims, jb::fftw::allocator<value_type> >

Alias boost::multi_array with properly allocated storage for FFTW3.

FFTW3 recommends using storage aligned for SIMD operations. jb::fftw defines an STL allocator to take advantage of the FFTW3 memory allocation functions that guarantee this alignment. This type alias makes it easy to create boost::multi_arrays using the allocator.

Template Parameters
value_typethe type stored by the multi_array
num_dimsthe number of dimensions in the multi array

Definition at line 24 of file aligned_multi_array.hpp.

◆ aligned_vector

template<typename T >
using jb::fftw::aligned_vector = typedef std::vector<T, jb::fftw::allocator<T> >

Alias std::vector with properly allocated storage for FFTW3.

FFTW3 recommends using storage aligned for SIMD operations. jb::fftw defines an STL allocator to take advantage of the FFTW3 memory allocation functions that guarantee this alignment. This type alias makes it easy to create std::vectors using the allocator.

Template Parameters
Tthe type stored by the vector

Definition at line 22 of file aligned_vector.hpp.

Function Documentation

◆ create_backward_plan()

template<typename in_array_type , typename out_array_type >
plan<in_array_type, out_array_type> jb::fftw::create_backward_plan ( in_array_type const &  in,
out_array_type &  out,
int  flags = default_plan_flags 
)

Create a plan to compute many inverse DFT given the input and output arrays.

Parameters
inthe input timeseries
outthe output timeseries
flagsthe FFTW flags for the plan
Exceptions
std::invalid_argumentif the input and output vectors are not compatible
Returns
a jb::fftw::plan<> of the right type.
Template Parameters
in_array_typethe type of the input timeseries
out_array_typethe type of the output timeseries

Definition at line 261 of file plan.hpp.

References jb::fftw::detail::check_plan_inputs(), jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_impl(), jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_backward_many_impl(), jb::detail::element_count(), fftw_cast(), and jb::detail::nsamples().

Referenced by jb::fftw::plan< timeseries_type, frequency_timeseries_type >::create_backward_impl(), and jb::fftw::plan< timeseries_type, frequency_timeseries_type >::execute().

◆ create_forward_plan()

template<typename in_array_type , typename out_array_type >
plan<in_array_type, out_array_type> jb::fftw::create_forward_plan ( in_array_type const &  in,
out_array_type &  out,
int  flags = default_plan_flags 
)

Create a plan to compute many DFTs given the input and output arrays.

Parameters
inthe input array of timeseries
outthe output array of timeseries
flagsthe FFTW flags for the plan
Exceptions
std::invalid_argumentif the input and output vectors are not compatible
Returns
a jb::fftw::plan<> of the right type.
Template Parameters
in_array_typethe type of the input array of timeseries
out_array_typethe type of the output array of timeseries

Definition at line 231 of file plan.hpp.

References jb::fftw::detail::check_plan_inputs(), jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_impl(), jb::fftw::plan< in_timeseries_type, out_timeseries_type >::create_forward_many_impl(), jb::detail::element_count(), fftw_cast(), and jb::detail::nsamples().

Referenced by jb::fftw::plan< timeseries_type, frequency_timeseries_type >::create_forward_impl(), and jb::fftw::plan< timeseries_type, frequency_timeseries_type >::execute().

◆ fftw_cast() [1/4]

template<typename vector >
auto jb::fftw::fftw_cast ( vector &  in) -> decltype(fftw_cast_array(&in[0]))

◆ fftw_cast() [2/4]

template<typename vector >
auto jb::fftw::fftw_cast ( vector const &  in) -> decltype(fftw_cast_array(&in[0]))

Definition at line 38 of file cast.hpp.

References fftw_cast_array().

◆ fftw_cast() [3/4]

template<typename T , std::size_t K, typename A >
auto jb::fftw::fftw_cast ( boost::multi_array< T, K, A > const &  a) -> decltype(fftw_cast_array(a.data()))

Definition at line 43 of file cast.hpp.

References fftw_cast_array().

◆ fftw_cast() [4/4]

template<typename T , std::size_t K, typename A >
auto jb::fftw::fftw_cast ( boost::multi_array< T, K, A > &  a) -> decltype(fftw_cast_array(a.data()))

Definition at line 49 of file cast.hpp.

References fftw_cast_array().

◆ fftw_cast_array() [1/4]

template<typename F >
traits<F>::fftw_complex_type* jb::fftw::fftw_cast_array ( std::complex< F > *  ptr)

Definition at line 12 of file cast.hpp.

Referenced by fftw_cast().

◆ fftw_cast_array() [2/4]

template<typename F >
traits<F>::fftw_complex_type const* jb::fftw::fftw_cast_array ( std::complex< F > const *  ptr)

Definition at line 18 of file cast.hpp.

◆ fftw_cast_array() [3/4]

template<typename F >
F* jb::fftw::fftw_cast_array ( F *  ptr)

Definition at line 23 of file cast.hpp.

◆ fftw_cast_array() [4/4]

template<typename F >
F const* jb::fftw::fftw_cast_array ( F const *  ptr)

Definition at line 28 of file cast.hpp.

Variable Documentation

◆ default_plan_flags

int constexpr jb::fftw::default_plan_flags
Initial value:
=
(FFTW_ESTIMATE | FFTW_PRESERVE_INPUT | FFTW_UNALIGNED)

Definition at line 13 of file plan.hpp.