Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

TFFT3D< ComplexTraits > Class Template Reference
[Fast Fourier Transforms]

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

#include <FFT3D.h>

Inheritance diagram for TFFT3D< ComplexTraits >:

TRegularData3D< std::complex< ComplexTraits::ComplexPrecision > > List of all members.

Public Types

typedef std::complex< typename
ComplexTraits::ComplexPrecision > 
Complex
typedef TRegularData3D< std::complex<
typename ComplexTraits::ComplexPrecision > > 
ComplexVector

Public Member Functions

Constructors and Destructors
 throw ()
 Default constructor.
 throw ()
 Copy constructor.
 TFFT3D (Size ldnX, Size ldnY, Size ldnZ, double stepPhysX=1., double stepPhysY=1., double stepPhysZ=1., Vector3 origin=Vector3(0., 0., 0), bool inFourierSpace=false) throw ()
 Detailed constructor.
virtual ~TFFT3D () throw ()
 Destructor.
Assignment
const TFFT3Doperator= (const TFFT3D &fft_3d) throw ()
 Assignment operator.
virtual void clear () throw ()
 Clear the contents.
virtual void destroy () throw ()
 Clear the contents and reset all attributes.
Predicates
bool operator== (const TFFT3D &fft3d) const throw ()
 Equality operator.
void doFFT () throw ()
 Perform a single fast Fourier transform on the data.
void doiFFT () throw ()
 Perform a single inverse Fourier transform on the data.
bool translate (const Vector3 &trans_origin) throw ()
 Translate the origin in physical space about {trans_origin}, i.e.
bool setPhysStepWidth (double new_width_x, double new_width_y, double new_width_z) throw ()
 Set the step width in physical space to {new_width_x, new_width_y, new_width_z}.
double getPhysStepWidthX () const throw ()
 Returns the step width in physical space in X direction.
double getPhysStepWidthY () const throw ()
 Returns the step width in physical space in Y direction.
double getPhysStepWidthZ () const throw ()
 Returns the step width in physical space in Z direction.
double getFourierStepWidthX () const throw ()
 Returns the step width in Fourier space in X direction.
double getFourierStepWidthY () const throw ()
 Returns the step width in Fourier space in Y direction.
double getFourierStepWidthZ () const throw ()
 Returns the step width in Fourier space in Z direction.
double getPhysSpaceMinX () const throw ()
 Returns the minimal position of the grid in physical space in X direction.
double getPhysSpaceMinY () const throw ()
 Returns the minimal position of the grid in physical space in Y direction.
double getPhysSpaceMinZ () const throw ()
 Returns the minimal position of the grid in physical space in Z direction.
double getPhysSpaceMaxX () const throw ()
 Returns the maximal position of the grid in physical space in X direction.
double getPhysSpaceMaxY () const throw ()
 Returns the maximal position of the grid in physical space in Y direction.
double getPhysSpaceMaxZ () const throw ()
 Returns the maximal position of the grid in physical space in Z direction.
double getFourierSpaceMinX () const throw ()
 Returns the minimal position of the grid in Fourier space in X direction.
double getFourierSpaceMinY () const throw ()
 Returns the minimal position of the grid in Fourier space in Y direction.
double getFourierSpaceMinZ () const throw ()
 Returns the minimal position of the grid in Fourier space in Z direction.
double getFourierSpaceMaxX () const throw ()
 Returns the maximal position of the grid in Fourier space in X direction.
double getFourierSpaceMaxY () const throw ()
 Returns the maximal position of the grid in Fourier space in Y direction.
double getFourierSpaceMaxZ () const throw ()
 Returns the maximal position of the grid in Fourier space in Z direction.
Size getMaxXIndex () const throw ()
 Return the largest grid position for the x direction.
Size getMaxYIndex () const throw ()
 Return the largest grid position for the y direction.
Size getMaxZIndex () const throw ()
 Return the largest grid position for the z direction.
Size getNumberOfInverseTransforms () const throw ()
 Return the number of inverse transforms that have been carried out using this class.
Vector3 getGridCoordinates (Position position) const throw ()
 Returns the grid coordinate corresponding to the position.
Complex getData (const Vector3 &pos) const throw (Exception::OutOfGrid)
 Returns the data at the grid position closest to pos , and automatically includes the correct phase factor and (symmetric) normalization.
Complex getInterpolatedValue (const Vector3 &pos) const throw (Exception::OutOfGrid)
 Returns the data at point pos.
void setData (const Vector3 &pos, Complex val) throw (Exception::OutOfGrid)
 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.
Complex & operator[] (const Vector3 &pos) throw (Exception::OutOfGrid)
 Access the data at the grid position closest to pos .
const Complex & operator[] (const Vector3 &pos) const throw (Exception::OutOfGrid)
 Access the data at the grid position closest to pos .
Complex & operator[] (const Position &pos) throw (Exception::OutOfGrid)
 Access the (raw) data at Position pos.
const Complex & operator[] (const Position &pos) const throw (Exception::OutOfGrid)
 Access the (raw) data at Position pos.
void setNumberOfFFTTransforms (Size num)
void setNumberOfiFFTTransforms (Size num)
Complex phase (const Vector3 &pos) const throw ()
 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".
Predicates
bool isInFourierSpace () const throw ()
 Returns true if the data is considered to be in Fourier space, false otherwise.

Protected Attributes

Size lengthX_
Size lengthY_
Size lengthZ_
bool inFourierSpace_
Size numPhysToFourier_
Size numFourierToPhys_
Vector3 origin_
 Origin of the grid (offset).
double stepPhysX_
double stepPhysY_
double stepPhysZ_
double stepFourierX_
double stepFourierY_
double stepFourierZ_
Vector3 minPhys_
Vector3 maxPhys_
Vector3 minFourier_
Vector3 maxFourier_
ComplexTraits::FftwPlan planForward_
ComplexTraits::FftwPlan planBackward_
Size dataLength_
Complex * dataAdress_
bool planCalculated_

Detailed Description

template<typename ComplexTraits>
class TFFT3D< ComplexTraits >

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

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


Constructor & Destructor Documentation

template<typename ComplexTraits>
TFFT3D< ComplexTraits >::TFFT3D Size  ldnX,
Size  ldnY,
Size  ldnZ,
double  stepPhysX = 1.,
double  stepPhysY = 1.,
double  stepPhysZ = 1.,
Vector3  origin = Vector3(0., 0., 0),
bool  inFourierSpace = false
throw ()
 

Detailed constructor.

Parameters:
ldnX The binary logarithm of the number of grid points in X direction (we use the logarithm to ensure that the number of points is a power of two, which is important for the FFT)
ldnY The binary logarithm of the number of grid points in Y direction
ldnZ The binary logarithm of the number of grid points in Z direction
stepPhysX The step width in X direction in physical space
stepPhysY The step width in Y direction in physical space
stepPhysZ The step width in Z 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


Member Function Documentation

template<typename ComplexTraits>
virtual void TFFT3D< ComplexTraits >::clear  )  throw () [virtual]
 

Clear the contents.

Reimplemented from TRegularData3D< std::complex< ComplexTraits::ComplexPrecision > >.

template<typename ComplexTraits>
virtual void TFFT3D< ComplexTraits >::destroy  )  throw () [virtual]
 

Clear the contents and reset all attributes.

template<typename ComplexTraits>
void TFFT3D< ComplexTraits >::doFFT  )  throw ()
 

Perform a single fast Fourier transform on the data.

template<typename ComplexTraits>
void TFFT3D< ComplexTraits >::doiFFT  )  throw ()
 

Perform a single inverse Fourier transform on the data.

template<typename ComplexTraits>
TFFT3D< ComplexTraits >::Complex TFFT3D< ComplexTraits >::getData const Vector3 pos  )  const throw (Exception::OutOfGrid)
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMaxX  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMaxY  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMaxZ  )  const throw ()
 

Returns the maximal position of the grid in Fourier space in Z direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMinX  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMinY  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierSpaceMinZ  )  const throw ()
 

Returns the minimal position of the grid in Fourier space in Z direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierStepWidthX  )  const throw ()
 

Returns the step width in Fourier space in X direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierStepWidthY  )  const throw ()
 

Returns the step width in Fourier space in Y direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getFourierStepWidthZ  )  const throw ()
 

Returns the step width in Fourier space in Z direction.

template<typename ComplexTraits>
Vector3 TFFT3D< ComplexTraits >::getGridCoordinates Position  position  )  const throw ()
 

Returns the grid coordinate corresponding to the position.

template<typename ComplexTraits>
TFFT3D< ComplexTraits >::Complex TFFT3D< ComplexTraits >::getInterpolatedValue const Vector3 pos  )  const throw (Exception::OutOfGrid)
 

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.

template<typename ComplexTraits>
Size TFFT3D< ComplexTraits >::getMaxXIndex  )  const throw ()
 

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, 0), this method returns the number of points in X direction minus one.

template<typename ComplexTraits>
Size TFFT3D< ComplexTraits >::getMaxYIndex  )  const throw ()
 

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, 0), this method returns the number of points in Y direction minus one.

template<typename ComplexTraits>
Size TFFT3D< ComplexTraits >::getMaxZIndex  )  const throw ()
 

Return the largest grid position for the z direction.

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

template<typename ComplexTraits>
Size TFFT3D< ComplexTraits >::getNumberOfInverseTransforms  )  const throw ()
 

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.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMaxX  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMaxY  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMaxZ  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMinX  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMinY  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysSpaceMinZ  )  const throw ()
 

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

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysStepWidthX  )  const throw ()
 

Returns the step width in physical space in X direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysStepWidthY  )  const throw ()
 

Returns the step width in physical space in Y direction.

template<typename ComplexTraits>
double TFFT3D< ComplexTraits >::getPhysStepWidthZ  )  const throw ()
 

Returns the step width in physical space in Z direction.

template<typename ComplexTraits>
bool TFFT3D< ComplexTraits >::isInFourierSpace  )  const throw ()
 

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

template<typename ComplexTraits>
bool TFFT3D< ComplexTraits >::operator== const TFFT3D< ComplexTraits > &  fft3d  )  const throw ()
 

Equality operator.

template<typename ComplexTraits>
const Complex& TFFT3D< ComplexTraits >::operator[] const Position pos  )  const throw (Exception::OutOfGrid)
 

Access the (raw) data at Position pos.

Const method.

template<typename ComplexTraits>
Complex& TFFT3D< ComplexTraits >::operator[] const Position pos  )  throw (Exception::OutOfGrid)
 

Access the (raw) data at Position pos.

template<typename ComplexTraits>
const TFFT3D< ComplexTraits >::Complex & TFFT3D< ComplexTraits >::operator[] const Vector3 pos  )  const throw (Exception::OutOfGrid)
 

Access the data at the grid position closest to pos .

This function returns the "raw" data at that position.

template<typename ComplexTraits>
TFFT3D< ComplexTraits >::Complex & TFFT3D< ComplexTraits >::operator[] const Vector3 pos  )  throw (Exception::OutOfGrid)
 

Access the data at the grid position closest to pos .

This function returns the "raw" data at that position.

template<typename ComplexTraits>
TFFT3D< ComplexTraits >::Complex TFFT3D< ComplexTraits >::phase const Vector3 pos  )  const throw ()
 

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".

template<typename ComplexTraits>
void TFFT3D< ComplexTraits >::setData const Vector3 pos,
Complex  val
throw (Exception::OutOfGrid)
 

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.

template<typename ComplexTraits>
bool TFFT3D< ComplexTraits >::setPhysStepWidth double  new_width_x,
double  new_width_y,
double  new_width_z
throw ()
 

Set the step width in physical space to {new_width_x, new_width_y, new_width_z}.

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

template<typename ComplexTraits>
bool TFFT3D< ComplexTraits >::translate const Vector3 trans_origin  )  throw ()
 

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 .