Transforms module
#include "diplib/dft.h"
template<typename T>
dip::DFT class

An object that encapsulates the Discrete Fourier Transform (DFT).

Usage:

DFT dft( size, inverse );               // creates the object with all the data ready to start running DFTs.
std::vector< std::complex< T >> buf( opts.BufferSize() ); // creates a buffer
dft.Apply( in, out, buf.data() );                         // computes a DFT, repeat as necessary
dft.Initialize( size2, inverse );                         // changes the options for the new size / direction
buf.resize( opts.BufferSize() );                          // resizes the buffer
dft.Apply( in, out, buf.data() );                         // computes a different DFT, repeat as necessary

Note that this code uses int for sizes, rather than dip::uint. dip::maximumDFTSize is the largest length of the transform.

The template can be instantiated for T = float or T = double. Linker errors will result for other types.

The DFT is computed using an FFT algorithm that is optimized for lengths that are a multiple of 2, 3 and 5. The larger the factors above 5, the longer the algorithm will take.

Constructors, destructors, assignment and conversion operators

DFT() defaulted
A default-initialized DFT object is useless. Call Initialize to make it useful.
DFT(std::size_t size, bool inverse)
Construct a DFT object by specifying the size and direction of the transform. Note that this is not a trivial operation.

Functions

void Initialize(std::size_t size, bool inverse)
Re-configure a DFT object to the given transform size and direction. Note that this is not a trivial operation.
void Apply(std::complex<T> const* source, std::complex<T>* destination, std::complex<T>* buffer, T scale) const
Apply the transform that the DFT object is configured for.
auto IsInverse() const -> bool
Returns true if this represents an inverse transform, false for a forward transform.
auto TransformSize() const -> std::size_t
Returns the size that the transform is configured for.
auto BufferSize() const -> std::size_t
Returns the size of the buffer expected by Apply.

Function documentation

template<typename T>
void Apply(std::complex<T> const* source, std::complex<T>* destination, std::complex<T>* buffer, T scale) const

Apply the transform that the DFT object is configured for.

source and destination are pointers to contiguous buffers with dip::DFT::TransformSize elements. This is the value of the size parameter of the constructor or dip::DFT::Initialize. buffer is a pointer to a contiguous buffer used for intermediate data. It should have dip::DFT::BufferSize elements.

scale is a real scalar that the output values are multiplied by. It is typically set to 1/size for the inverse transform, and 1 for the forward transform.

source and destination can only point to the same buffer if all factors of dip::DFT::TransformSize are the same. One should avoid this in general situations.