#
template<typename T>
DFT class

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

### Contents

Usage:

DFT dft( size, inverse ); // creates the object with all the data ready to start running DFTs. dft.Apply( in, out ); // computes a DFT, repeat as necessary dft.Initialize( size2, inverse ); // changes the options for the new size / direction dft.Apply( in, out ); // computes a different DFT, repeat as necessary

The template can be instantiated for `T = float`

or `T = double`

. Linker errors will result for other types.

The DFT is computed using either PocketFFT or FFTW, depending on compile-time configuration (see the
`DIP_ENABLE_FFTW`

CMake configuration option).

When using FFTW, `dip::maximumDFTSize`

is the largest length of the transform. PocketFFT does not have this limit.

## Constructors, destructors, assignment and conversion operators

- DFT() defaulted
- A default-initialized
`DFT`

object is useless. Call`Initialize`

to make it useful. - DFT(dip::uint size, bool inverse, dip::Option::DFTOptions options = {})
- Construct a
`DFT`

object, see`dip::DFT::Initialize`

for the meaning of the parameters. Note that this is not a trivial operation. Not thread safe.

## Functions

- void Initialize(dip::uint size, bool inverse, dip::Option::DFTOptions options = {})
- Re-configure a
`DFT`

object to the given transform size and direction. - void Apply(std::complex<T>* source, std::complex<T>* destination, 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 IsInplace() const -> bool
- Returns whether the transform is configured to work in place or not. Not meaningful when using PocketFFT.
- auto IsAligned() const -> bool
- Returns whether the transform is configured to work on aligned buffers or not. Not meaningful when using PocketFFT.
- auto TransformSize() const -> dip::uint
- Returns the size that the transform is configured for.
- auto BufferSize() const -> dip::uint deprecated
- Returns the size of the buffer expected by
`Apply`

. - void Destroy() private
- Frees memory

## Function documentation

###
template<typename T>
void
Initialize(dip::uint size,
bool inverse,
dip::Option::DFTOptions options = {})

Re-configure a `DFT`

object to the given transform size and direction.

`size`

is the size of the transform. The two pointers passed to `dip::DFT::Apply`

are expected to point at
buffers with this length. If `inverse`

is `true`

, an inverse transform will be computed.

`options`

determines some properties for the algorithm that will compute the DFT.
- `dip::Option::DFTOption::InPlace`

means the input and output pointers passed to `dip::DFT::Apply`

must be the same.
- `dip::Option::DFTOption::TrashInput`

means that the algorithm is free to overwrite the input array.
Ignored when working in place.
- `dip::Option::DFTOption::Aligned`

means that the input and output buffers are aligned to 16-bit boundaries,
which can significantly improve the speed of the algorithm.

When using PocketFFT, all these options are ignored.

Note that this is not a trivial operation, planning an FFT costs time.

This operation is not thread safe.

###
template<typename T>
void
Apply(std::complex<T>* source,
std::complex<T>* destination,
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`

. These two pointers
can point to the same address for in-place operation; otherwise they must point to non-overlapping
regions of memory. When using FFTW, the `inplace`

parameter to the constructor or `dip::DFT::Initialize`

must be `true`

if the two pointers here are the same, or `false`

if they are different.

The input array is not marked `const`

. If `dip::Option::DFTOption::TrashInput`

` is given when planning,
the input array can be overwritten with intermediate data, but otherwise will be left intact.

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