Loading...
Searching...
No Matches
BALL::TFFT2D< ComplexTraits > Class Template Reference
Foundation Classes » Mathematics » Fast Fourier Transforms

`#include <BALL/MATHS/FFT2D.h>`

Inheritance diagram for BALL::TFFT2D< ComplexTraits >:

## Public Types

typedef std::complex< typename ComplexTraits::ComplexPrecision > | Complex
typedef TRegularData2D< std::complex< typename ComplexTraits::ComplexPrecision > > | ComplexVector
typedef TRegularData2D< std::complex< typenameComplexTraits::ComplexPrecision > >::IndexType | IndexType
Public Types inherited from BALL::TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > >
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > > | VectorType
| The type containing an STL vector of the appropriate type.
typedef TVector2< float > | CoordinateType
| The coordinate type.
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::iterator | Iterator
| A mutable iterator.
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::const_iterator | ConstIterator
| A nonmutable iterator.
typedef std::complex< ComplexTraits::ComplexPrecision > | value_type
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::iterator | iterator
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::const_iterator | const_iterator
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::reference | reference
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::const_reference | const_reference
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::pointer | pointer
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::difference_type | difference_type
typedef std::vector< std::complex< ComplexTraits::ComplexPrecision > >::size_type | size_type

## Public Member Functions

Constructors and Destructors
| TFFT2D ()
| Default constructor.
| TFFT2D (const TFFT2D &data)
| Copy constructor.
| TFFT2D (Size nX, Size nY, double stepPhysX=1., double stepPhysY=1., Vector2 origin=Vector2(0., 0.), bool inFourierSpace=false)
virtual | ~TFFT2D ()
| Destructor.
Assignment
const TFFT2D & | operator= (const TFFT2D &fft_2d)
| Assignment operator.
virtual void | clear ()
virtual void | destroy ()
Public Member Functions inherited from BALL::TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > >
| TRegularData2D ()
virtual | ~TRegularData2D ()
TRegularData2D & | operator= (const TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > > &data)
bool | operator== (const TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > > &data) const
BALL_INLINE bool | operator!= (const TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > > &data) const
| Inequality operator.
BALL_INLINE bool | empty () const
| Empty predicate.
bool | isInside (const CoordinateType &x) const
| Test if a given point is inside the grid.
BALL_INLINE ConstIterator | begin () const
BALL_INLINE ConstIterator | end () const
BALL_INLINE size_type | size () const
BALL_INLINE size_type | max_size () const
BALL_INLINE void | swap (TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > > &data)
const std::complex< ComplexTraits::ComplexPrecision > & | getData (const IndexType &index) const
const std::complex< ComplexTraits::ComplexPrecision > & | operator[] (const IndexType &index) const
std::complex< ComplexTraits::ComplexPrecision > | operator() (const CoordinateType &x) const
std::complex< ComplexTraits::ComplexPrecision > | getInterpolatedValue (const CoordinateType &x) const
const std::complex< ComplexTraits::ComplexPrecision > & | getClosestValue (const CoordinateType &x) const
IndexType | getLowerIndex (const CoordinateType &v) const
IndexType | getClosestIndex (const CoordinateType &v) const
const IndexType & | getSize () const
const CoordinateType & | getOrigin () const
const CoordinateType & | getSpacing () const
void | setOrigin (const CoordinateType &origin)
const CoordinateType & | getDimension () const
void | setDimension (const CoordinateType &dimension)
void | resize (const IndexType &new_size)
void | rescale (const IndexType &new_size)
CoordinateType | getCoordinates (const IndexType &index) const
void | getEnclosingIndices (const CoordinateType &r, Position &ll, Position &lr, Position &ul, Position &ur) const
void | getEnclosingValues (const CoordinateType &r, std::complex< ComplexTraits::ComplexPrecision > &ll, std::complex< ComplexTraits::ComplexPrecision > &lr, std::complex< ComplexTraits::ComplexPrecision > &ul, std::complex< ComplexTraits::ComplexPrecision > &ur) const
std::complex< ComplexTraits::ComplexPrecision > | calculateMean () const
std::complex< ComplexTraits::ComplexPrecision > | calculateSD () const
void | binaryWrite (const String &filename) const
void | binaryRead (const String &filename)

## Predicates

Size | lengthX_
Size | lengthY_
bool | inFourierSpace_
Size | numPhysToFourier_
Size | numFourierToPhys_
Vector2 | origin_
double | stepPhysX_
double | stepPhysY_
double | stepFourierX_
double | stepFourierY_
Vector2 | minPhys_
Vector2 | maxPhys_
Vector2 | minFourier_
Vector2 | maxFourier_
ComplexTraits::FftwPlan | planForward_
ComplexTraits::FftwPlan | planBackward_
Size | dataLength_
Complex * | dataAdress_
bool | planCalculated_
bool | operator== (const TFFT2D &fft_2d) const
void | doFFT ()
void | doiFFT ()
bool | translate (const Vector2 &trans_origin)
bool | setPhysStepWidth (double new_width_x, double new_width_y)
double | getPhysStepWidthX () const
double | getPhysStepWidthY () const
double | getFourierStepWidthX () const
double | getFourierStepWidthY () const
double | getPhysSpaceMinX () const
double | getPhysSpaceMinY () const
double | getPhysSpaceMaxX () const
double | getPhysSpaceMaxY () const
double | getFourierSpaceMinX () const
double | getFourierSpaceMinY () const
double | getFourierSpaceMaxX () const
double | getFourierSpaceMaxY () const
Size | getMaxXIndex () const
Size | getMaxYIndex () const
Size | getNumberOfInverseTransforms () const
Vector2 | getGridCoordinates (Position position) const
Complex | getData (const Vector2 &pos) const
Complex | getInterpolatedValue (const Vector2 &pos) const
void | setData (const Vector2 &pos, Complex val)
Complex & | operator[] (const Vector2 &pos)
const Complex & | operator[] (const Vector2 &pos) const
const Complex & | operator[] (const IndexType &index) const
Complex & | operator[] (const IndexType &index)
Complex & | operator[] (const Position &pos)
const Complex & | operator[] (const Position &pos) const
void | setNumberOfFFTTransforms (Size num)
void | setNumberOfiFFTTransforms (Size num)
Complex | phase (const Vector2 &pos) const
bool | isInFourierSpace () const

## Additional Inherited Members

VectorType | data_
| The grid data.
CoordinateType | origin_
| Origin of the grid (offset).
CoordinateType | dimension_
| Dimension of the grid.
CoordinateType | spacing_
| Grid spacing.
IndexType | size_
| The dimensions in grid points.

## Detailed Description

template<typename ComplexTraits>
class BALL::TFFT2D< ComplexTraits >

A class to perform Fast Fourier Transforms and inverse Fast Fourier Transforms on regularly spaced two dimensional data.

  This class makes use of the freely available library FFTW, which can be found at http://www.fftw.org coordinate system can be handled automatically. The normaliztion is chosen symmetrically.

  S/TFFT2D.h

Definition at line 41 of file FFT2D.h.

## Member Typedef Documentation

## Complex

template<typename ComplexTraits>

typedef std::complex<typename ComplexTraits::ComplexPrecision> BALL::TFFT2D< ComplexTraits >::Complex

Definition at line 46 of file FFT2D.h.

## ComplexVector

template<typename ComplexTraits>

typedef TRegularData2D<std::complex<typename ComplexTraits::ComplexPrecision> > BALL::TFFT2D< ComplexTraits >::ComplexVector

Definition at line 47 of file FFT2D.h.

## IndexType

template<typename ComplexTraits>

typedef TRegularData2D<std::complex<typenameComplexTraits::ComplexPrecision>>::IndexType BALL::TFFT2D< ComplexTraits >::IndexType

Definition at line 48 of file FFT2D.h.

## Constructor & Destructor Documentation

## TFFT2D() [1/3]

template<typename ComplexTraits>

BALL::TFFT2D< ComplexTraits >::TFFT2D | ( |  | ) |

Default constructor.

Definition at line 334 of file FFT2D.h.

## TFFT2D() [2/3]

template<typename ComplexTraits>

BALL::TFFT2D< ComplexTraits >::TFFT2D | ( | const TFFT2D< ComplexTraits > & | data | ) |

Copy constructor.

## TFFT2D() [3/3]

template<typename ComplexTraits>

BALL::TFFT2D< ComplexTraits >::TFFT2D | ( | Size | nX,
|  | Size | nY,
|  | double | stepPhysX = 1.,
|  | double | stepPhysY = 1.,
|  | Vector2 | origin = Vector2(0., 0.),
|  | bool | inFourierSpace = false )

Detailed constructor.

Parameters

  nX | The number of grid points in X direction
  nY | The number of grid points in Y direction
  stepPhysX | The step width in X direction in physical space
  stepPhysY | The step width in Y direction in physical space
  origin | The origin of the coordinate system
  inFourierSpace | Flag to decide whether the data is assumed to be in physical or fourier space

## ~TFFT2D()

template<typename ComplexTraits>

virtual BALL::TFFT2D< ComplexTraits >::~TFFT2D | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## clear()

template<typename ComplexTraits>

virtual void BALL::TFFT2D< ComplexTraits >::clear | ( |  | ) |

virtual

Clear the contents.

Reimplemented from BALL::TRegularData2D< std::complex< ComplexTraits::ComplexPrecision > >.

## destroy()

template<typename ComplexTraits>

virtual void BALL::TFFT2D< ComplexTraits >::destroy | ( |  | ) |

virtual

Clear the contents and reset all attributes.

## doFFT()

template<typename ComplexTraits>

void BALL::TFFT2D< ComplexTraits >::doFFT | ( |  | ) |

Perform a single fast fourier transform on the data.

## doiFFT()

template<typename ComplexTraits>

void BALL::TFFT2D< ComplexTraits >::doiFFT | ( |  | ) |

Perform a single inverse fourier transform on the data.

## getData()

template<typename ComplexTraits>

TFFT2D< ComplexTraits >::Complex BALL::TFFT2D< ComplexTraits >::getData | ( | const Vector2 & | pos | ) | const

Returns the data at the grid position closest to pos , and automatically includes the correct phase factor and (symmetric) normalization.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 579 of file FFT2D.h.

## getFourierSpaceMaxX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierSpaceMaxX | ( |  | ) | const

Returns the maximal position of the grid in fourier space in X direction.

Definition at line 492 of file FFT2D.h.

## getFourierSpaceMaxY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierSpaceMaxY | ( |  | ) | const

Returns the maximal position of the grid in fourier space in Y direction.

Definition at line 498 of file FFT2D.h.

## getFourierSpaceMinX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierSpaceMinX | ( |  | ) | const

Returns the minimal position of the grid in fourier space in X direction.

Definition at line 480 of file FFT2D.h.

## getFourierSpaceMinY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierSpaceMinY | ( |  | ) | const

Returns the minimal position of the grid in fourier space in Y direction.

Definition at line 486 of file FFT2D.h.

## getFourierStepWidthX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierStepWidthX | ( |  | ) | const

Returns the step width in fourier space in X direction.

Definition at line 444 of file FFT2D.h.

## getFourierStepWidthY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getFourierStepWidthY | ( |  | ) | const

Returns the step width in fourier space in Y direction.

Definition at line 450 of file FFT2D.h.

## getGridCoordinates()

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::getGridCoordinates | ( | Position | position | ) | const

Returns the grid coordinate corresponding to the position.

Definition at line 523 of file FFT2D.h.

## getInterpolatedValue()

template<typename ComplexTraits>

TFFT2D< ComplexTraits >::Complex BALL::TFFT2D< ComplexTraits >::getInterpolatedValue | ( | const Vector2 & | pos | ) | const

Returns the data at point pos. If pos is not a point on the grid, the data is linearly interpolated. This method automatically includes the correct phase factor and (symmetric) normalization.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 601 of file FFT2D.h.

## getMaxXIndex()

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::getMaxXIndex | ( |  | ) | const

Return the largest grid position for the x direction. This method returns the maximum position allowed in the grid. As the point in the origin has the indices (0, 0), this method returns the number of points in X direction minus one.

Definition at line 504 of file FFT2D.h.

## getMaxYIndex()

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::getMaxYIndex | ( |  | ) | const

Return the largest grid position for the y direction. This method returns the maximum position allowed in the grid. As the point in the origin has the indices (0, 0), this method returns the number of points in Y direction minus one.

Definition at line 510 of file FFT2D.h.

## getNumberOfInverseTransforms()

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::getNumberOfInverseTransforms | ( |  | ) | const

Return the number of inverse transforms that have been carried out using this class. This is an important factor for the normalization of the data.

Definition at line 516 of file FFT2D.h.

## getPhysSpaceMaxX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysSpaceMaxX | ( |  | ) | const

Returns the maximal position of the grid in physical space in X direction.

Definition at line 468 of file FFT2D.h.

## getPhysSpaceMaxY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysSpaceMaxY | ( |  | ) | const

Returns the maximal position of the grid in physical space in Y direction.

Definition at line 474 of file FFT2D.h.

## getPhysSpaceMinX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysSpaceMinX | ( |  | ) | const

Returns the minimal position of the grid in physical space in X direction.

Definition at line 456 of file FFT2D.h.

## getPhysSpaceMinY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysSpaceMinY | ( |  | ) | const

Returns the minimal position of the grid in physical space in Y direction.

Definition at line 462 of file FFT2D.h.

## getPhysStepWidthX()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysStepWidthX | ( |  | ) | const

Returns the step width in physical space in X direction.

Definition at line 432 of file FFT2D.h.

## getPhysStepWidthY()

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::getPhysStepWidthY | ( |  | ) | const

Returns the step width in physical space in Y direction.

Definition at line 438 of file FFT2D.h.

## isInFourierSpace()

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::isInFourierSpace | ( |  | ) | const

Returns true if the data is considered to be in Fourier space, false otherwise.

Definition at line 762 of file FFT2D.h.

## operator=()

template<typename ComplexTraits>

const TFFT2D & BALL::TFFT2D< ComplexTraits >::operator= | ( | const TFFT2D< ComplexTraits > & | fft_2d | ) |

Assignment operator.

## operator==()

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::operator== | ( | const TFFT2D< ComplexTraits > & | fft_2d | ) | const

Equality operator.

Definition at line 343 of file FFT2D.h.

## operator[]() [1/6]

template<typename ComplexTraits>

Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const IndexType & | index | ) |

inline

Mutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 250 of file FFT2D.h.

## operator[]() [2/6]

template<typename ComplexTraits>

const Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const IndexType & | index | ) | const

inline

Nonmutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 244 of file FFT2D.h.

## operator[]() [3/6]

template<typename ComplexTraits>

Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const Position & | pos | ) |

inline

Access the (raw) data at Position pos.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 256 of file FFT2D.h.

## operator[]() [4/6]

template<typename ComplexTraits>

const Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const Position & | pos | ) | const

inline

Access the (raw) data at Position pos. Const method.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 265 of file FFT2D.h.

## operator[]() [5/6]

template<typename ComplexTraits>

TFFT2D< ComplexTraits >::Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const Vector2 & | pos | ) |

Access the data at the grid position closest to pos . This function returns the "raw" data at that position.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 665 of file FFT2D.h.

## operator[]() [6/6]

template<typename ComplexTraits>

const TFFT2D< ComplexTraits >::Complex & BALL::TFFT2D< ComplexTraits >::operator[] | ( | const Vector2 & | pos | ) | const

Access the data at the grid position closest to pos . This function returns the "raw" data at that position.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 707 of file FFT2D.h.

## phase()

template<typename ComplexTraits>

TFFT2D< ComplexTraits >::Complex BALL::TFFT2D< ComplexTraits >::phase | ( | const Vector2 & | pos | ) | const

This computes the phase factor in fourier space that results if the origin of the coordinate system in physical space is not in the "lower left corner".

Definition at line 749 of file FFT2D.h.

## setData()

template<typename ComplexTraits>

void BALL::TFFT2D< ComplexTraits >::setData | ( | const Vector2 & | pos,
|  | Complex | val )

Sets the data point at the grid position closest to pos to the value val , and – if called in fourier space – automatically includes the correct phase factor and (symmetric) normalization.

Exceptions

  Exception::OutOfGrid | if pos is outside the grid boundaries

Definition at line 642 of file FFT2D.h.

## setNumberOfFFTTransforms()

template<typename ComplexTraits>

void BALL::TFFT2D< ComplexTraits >::setNumberOfFFTTransforms | ( | Size | num | ) |

inline

Definition at line 271 of file FFT2D.h.

## setNumberOfiFFTTransforms()

template<typename ComplexTraits>

void BALL::TFFT2D< ComplexTraits >::setNumberOfiFFTTransforms | ( | Size | num | ) |

inline

Definition at line 277 of file FFT2D.h.

## setPhysStepWidth()

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::setPhysStepWidth | ( | double | new_width_x,
|  | double | new_width_y )

Set the step width in physical space to {new_width_x, new_width_y}. The step width in fourier space is automatically adjusted accordingly. {new_width_x and new_width_y} must be positive, otherwise the function does nothing and retuns false .

Definition at line 409 of file FFT2D.h.

## translate()

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::translate | ( | const Vector2 & | trans_origin | ) |

Translate the origin in physical space about {trans_origin}, i.e. the new origin will be located at the former position {trans_origin}. If the result is out of bounds, the function does nothing and returns false .

Definition at line 385 of file FFT2D.h.

## Member Data Documentation

## dataAdress_

template<typename ComplexTraits>

Complex* BALL::TFFT2D< ComplexTraits >::dataAdress_

protected

Definition at line 311 of file FFT2D.h.

## dataLength_

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::dataLength_

protected

Definition at line 310 of file FFT2D.h.

## inFourierSpace_

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::inFourierSpace_

protected

Definition at line 295 of file FFT2D.h.

## lengthX_

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::lengthX_

protected

Definition at line 294 of file FFT2D.h.

## lengthY_

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::lengthY_

protected

Definition at line 294 of file FFT2D.h.

## maxFourier_

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::maxFourier_

protected

Definition at line 302 of file FFT2D.h.

## maxPhys_

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::maxPhys_

protected

Definition at line 301 of file FFT2D.h.

## minFourier_

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::minFourier_

protected

Definition at line 302 of file FFT2D.h.

## minPhys_

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::minPhys_

protected

Definition at line 301 of file FFT2D.h.

## numFourierToPhys_

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::numFourierToPhys_

protected

Definition at line 297 of file FFT2D.h.

## numPhysToFourier_

template<typename ComplexTraits>

Size BALL::TFFT2D< ComplexTraits >::numPhysToFourier_

protected

Definition at line 296 of file FFT2D.h.

## origin_

template<typename ComplexTraits>

Vector2 BALL::TFFT2D< ComplexTraits >::origin_

protected

Definition at line 298 of file FFT2D.h.

## planBackward_

template<typename ComplexTraits>

ComplexTraits::FftwPlan BALL::TFFT2D< ComplexTraits >::planBackward_

protected

Definition at line 306 of file FFT2D.h.

## planCalculated_

template<typename ComplexTraits>

bool BALL::TFFT2D< ComplexTraits >::planCalculated_

protected

Definition at line 312 of file FFT2D.h.

## planForward_

template<typename ComplexTraits>

ComplexTraits::FftwPlan BALL::TFFT2D< ComplexTraits >::planForward_

protected

Definition at line 305 of file FFT2D.h.

## stepFourierX_

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::stepFourierX_

protected

Definition at line 300 of file FFT2D.h.

## stepFourierY_

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::stepFourierY_

protected

Definition at line 300 of file FFT2D.h.

## stepPhysX_

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::stepPhysX_

protected

Definition at line 299 of file FFT2D.h.

## stepPhysY_

template<typename ComplexTraits>

double BALL::TFFT2D< ComplexTraits >::stepPhysY_

protected

Definition at line 299 of file FFT2D.h.