GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFftWavetable Class Reference

Lookup table class for Fast Fourier Transformation. More...

#include <GFftWavetable.hpp>

Inheritance diagram for GFftWavetable:
GBase

Public Member Functions

 GFftWavetable (void)
 Void constructor. More...
 
 GFftWavetable (const int &size)
 Wave table constructor. More...
 
 GFftWavetable (const GFftWavetable &wavetable)
 Copy constructor. More...
 
virtual ~GFftWavetable (void)
 Destructor. More...
 
GFftWavetableoperator= (const GFftWavetable &wavetable)
 Assignment operator. More...
 
std::complex< double > & operator[] (const int &index)
 Return reference to trigonometric coefficient. More...
 
const std::complex< double > & operator[] (const int &index) const
 Return reference to trigonometric coefficient (const version) More...
 
void clear (void)
 Clear lookup table for Fast Fourier Transform. More...
 
GFftWavetableclone (void) const
 Clone lookup table for Fast Fourier Transform. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of trigonometric coefficients. More...
 
const int & index (const int &factor) const
 Return start index for a given factor. More...
 
int factors (void) const
 Return number of factorisation factors. More...
 
int factor (const int &index) const
 Return factorisation factor. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print lookup table for Fast Fourier Transform information. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GFftWavetable &wavetable)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void set_members (const int &n)
 Set wavetable. More...
 
void set_factors (const int &n)
 Compute FFT factorisation. More...
 

Protected Attributes

std::vector< int > m_factors
 Wavetable factors. More...
 
std::vector< int > m_twiddle
 Start index of factors. More...
 
std::vector< std::complex
< double > > 
m_trig
 Trigonometric coefficients. More...
 

Detailed Description

Lookup table class for Fast Fourier Transformation.

Definition at line 44 of file GFftWavetable.hpp.

Constructor & Destructor Documentation

GFftWavetable::GFftWavetable ( void  )

Void constructor.

Definition at line 52 of file GFftWavetable.cpp.

References init_members().

Referenced by clone().

GFftWavetable::GFftWavetable ( const int &  size)
explicit

Wave table constructor.

Parameters
[in]sizeArray size.

Constructs the lookup table for Fast Fourier Transformation for a given array size.

Definition at line 70 of file GFftWavetable.cpp.

References init_members(), and set_members().

GFftWavetable::GFftWavetable ( const GFftWavetable wavetable)

Copy constructor.

Parameters
[in]wavetableLookup table for Fast Fourier Transform.

Definition at line 88 of file GFftWavetable.cpp.

References copy_members(), and init_members().

GFftWavetable::~GFftWavetable ( void  )
virtual

Destructor.

Definition at line 104 of file GFftWavetable.cpp.

References free_members().

Member Function Documentation

std::string GFftWavetable::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GFftWavetable").

Implements GBase.

Definition at line 89 of file GFftWavetable.hpp.

void GFftWavetable::clear ( void  )
virtual

Clear lookup table for Fast Fourier Transform.

Implements GBase.

Definition at line 156 of file GFftWavetable.cpp.

References free_members(), and init_members().

GFftWavetable * GFftWavetable::clone ( void  ) const
virtual

Clone lookup table for Fast Fourier Transform.

Returns
Pointer to deep copy of lookup table for Fast Fourier Transform.

Implements GBase.

Definition at line 174 of file GFftWavetable.cpp.

References GFftWavetable().

void GFftWavetable::copy_members ( const GFftWavetable wavetable)
protected

Copy class members.

Parameters
[in]wavetableLookup table for Fast Fourier Transform.

Definition at line 272 of file GFftWavetable.cpp.

References m_factors, m_trig, and m_twiddle.

Referenced by GFftWavetable(), and operator=().

int GFftWavetable::factor ( const int &  index) const

Return factorisation factor.

Parameters
[in]indexFactorisation index [0,...,factors()-1].
Returns
Factorisation factor.
Exceptions
GException::out_of_rangeIndex is outside valid range.

Returns factorisation factor.

Definition at line 192 of file GFftWavetable.cpp.

References factors(), G_FACTOR, and m_factors.

Referenced by print(), set_factors(), and GFft::transform().

int GFftWavetable::factors ( void  ) const
inline

Return number of factorisation factors.

Returns
Number of factorisation factors.

Definition at line 158 of file GFftWavetable.hpp.

References m_factors.

Referenced by factor(), print(), and GFft::transform().

void GFftWavetable::free_members ( void  )
protected

Delete class members.

Definition at line 287 of file GFftWavetable.cpp.

Referenced by clear(), operator=(), and ~GFftWavetable().

const int & GFftWavetable::index ( const int &  factor) const
inline

Return start index for a given factor.

Parameters
[in]factorFactor index [0,...,factors()-1].

Returns the index of the first trigonometric coefficient for a given factor.

Definition at line 134 of file GFftWavetable.hpp.

References m_twiddle.

Referenced by GFft::transform().

void GFftWavetable::init_members ( void  )
protected

Initialise class members.

Definition at line 255 of file GFftWavetable.cpp.

References m_factors, m_trig, and m_twiddle.

Referenced by clear(), GFftWavetable(), operator=(), and set_members().

GFftWavetable & GFftWavetable::operator= ( const GFftWavetable wavetable)

Assignment operator.

Parameters
[in]wavetableLookup table for Fast Fourier Transform.
Returns
Lookup table for Fast Fourier Transform.

Definition at line 126 of file GFftWavetable.cpp.

References copy_members(), free_members(), and init_members().

std::complex< double > & GFftWavetable::operator[] ( const int &  index)
inline

Return reference to trigonometric coefficient.

Parameters
[in]indexTrigonometric coefficient index [0,...,size()-1].

Returns a reference to the trigonometric coefficient with the specified index.

Definition at line 104 of file GFftWavetable.hpp.

References m_trig.

const std::complex< double > & GFftWavetable::operator[] ( const int &  index) const
inline

Return reference to trigonometric coefficient (const version)

Parameters
[in]indexTrigonometric coefficient index [0,...,size()-1].

Returns a const reference to the trigonometric coefficient with the specified index.

Definition at line 119 of file GFftWavetable.hpp.

References m_trig.

std::string GFftWavetable::print ( const GChatter chatter = NORMAL) const
virtual

Print lookup table for Fast Fourier Transform information.

Parameters
[in]chatterChattiness.
Returns
String containing lookup table for Fast Fourier Transform information.

Implements GBase.

Definition at line 212 of file GFftWavetable.cpp.

References factor(), factors(), gammalib::parformat(), SILENT, size(), and gammalib::str().

void GFftWavetable::set_factors ( const int &  n)
protected

Compute FFT factorisation.

Parameters
[in]nLength of array to be transformed.
Exceptions
GException::invalid_argumentNon positive array length specified
GException::invalid_valueProduct of factorisation factors are not equal to array length

Computes the factorisation

\[ n = \prod_i p_i \]

of an array of length n.

The method is a C++ implementation of the fft_complex_factorize() and the fft_factorize() functions of the GSL library (version 2.2.1), defined in the file fft/factorize.c.

Definition at line 401 of file GFftWavetable.cpp.

References factor(), G_SET_FACTORS, m_factors, and gammalib::str().

Referenced by set_members().

void GFftWavetable::set_members ( const int &  n)
protected

Set wavetable.

Parameters
[in]nLength.

Computes the coefficients

\[ \frac{-i 2 \pi j k}{n} \]

of the discrete Fourier transformation

\[ x_j = \sum_{k=0}^{n-1} z_k \exp \left( \frac{-i 2 \pi j k}{n} \right) \]

The method is a C++ implementation of the gsl_fft_complex_wavetable_alloc() function of the GSL library (version 2.2.1), defined in the file fft/c_init.c.

Definition at line 315 of file GFftWavetable.cpp.

References cos(), G_SET_MEMBERS, init_members(), m_factors, m_trig, m_twiddle, set_factors(), sin(), gammalib::str(), and gammalib::twopi.

Referenced by GFftWavetable().

int GFftWavetable::size ( void  ) const
inline

Return number of trigonometric coefficients.

Returns
Number of trigonometric coefficients.

Definition at line 146 of file GFftWavetable.hpp.

References m_trig.

Referenced by print().

Member Data Documentation

std::vector<int> GFftWavetable::m_factors
protected

Wavetable factors.

Definition at line 77 of file GFftWavetable.hpp.

Referenced by copy_members(), factor(), factors(), init_members(), set_factors(), and set_members().

std::vector<std::complex<double> > GFftWavetable::m_trig
protected

Trigonometric coefficients.

Definition at line 79 of file GFftWavetable.hpp.

Referenced by copy_members(), init_members(), operator[](), set_members(), and size().

std::vector<int> GFftWavetable::m_twiddle
protected

Start index of factors.

Definition at line 78 of file GFftWavetable.hpp.

Referenced by copy_members(), index(), init_members(), and set_members().


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