Skip to content

class dft_plan<T> dft

template <typename T>
struct dft_plan { … }

Class for performing 1D DFT/FFT.

The same plan is used for both direct DFT and inverse DFT. The type is default-constructible and movable but non-copyable. It is advisable to create an instance of the dft_plan with a specific size beforehand and reuse this instance in all subsequent DFT operations.

Template parameters
T Template parameter specifying the floating-point type. Must be either float or double; other types are not supported.

variable size

size_t size

The size of the DFT as passed to the contructor.

Defined at dft/fft.hpp:187

variable temp_size

size_t temp_size

The temporary (scratch) buffer size for the DFT plan.

Note

Preallocating a byte buffer of this size and passing its pointer to the execute function may improve performance.

Defined at dft/fft.hpp:192

constructor dft_plan<T>()

dft_plan()

Constructs an empty DFT plan.

This default constructor ensures the type is default-constructible.

Defined at dft/fft.hpp:199

constructor dft_plan<T>(const dft_plan<T> &)

dft_plan(const dft_plan&) = delete

Copy constructor (deleted).

Copying of dft_plan instances is not allowed.

Defined at dft/fft.hpp:209

function operator=(const dft_plan<T> &)

dft_plan& operator=(const dft_plan&) = delete

Copy assignment operator (deleted).

Copy assignment of dft_plan instances is not allowed.

Defined at dft/fft.hpp:216

constructor dft_plan<T>(dft_plan<T> &&)

dft_plan(dft_plan&&) = default

Move constructor.

Defined at dft/fft.hpp:221

function operator=(dft_plan<T> &&)

dft_plan& operator=(dft_plan&&) = default

Move assignment operator.

Defined at dft/fft.hpp:226

function is_initialized()

bool is_initialized() const

Checks whether the plan is non-empty.

Returns
true if the plan was constructed with a specific DFT size, false otherwise.

Defined at dft/fft.hpp:233

constructor dft_plan<T>(size_t, dft_order, bool)

explicit dft_plan(size_t size, dft_order order = dft_order::normal, bool progressive_optimized = false)

Constructs a DFT plan with the specified size and order.

Parameters
size The size of the DFT.
order The order of the DFT samples. See dft_order.
progressive_optimized If true, the plan will be optimized for progressive execution.

Defined at dft/fft.hpp:242

function dump()

void dump() const

Dumps details of the DFT plan to stdout for inspection.

May be used to determine the selected architecture at runtime and the chosen DFT algorithms.

Defined at dft/fft.hpp:253

function execute(complex<T> *, const complex<T> *, u8 *, bool)

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:265

destructor ~dft_plan<T>()

~dft_plan()

Destructor.

Deallocates internal data.

Defined at dft/fft.hpp:279

function execute(complex<T> *, const complex<T> *, u8 *, cbool_t<inverse>)

template <bool inverse>
KFR_MEM_INTRINSIC void execute(complex<T>* out, const complex<T>* in, u8* temp,
                               cbool_t<inverse> inv) const

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
Template parameters
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:292

function execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, bool)

template <univector_tag Tag1, univector_tag Tag2, univector_tag Tag3>
KFR_MEM_INTRINSIC void execute(univector<complex<T>, Tag1>& out, const univector<complex<T>, Tag2>& in,
                               univector<u8, Tag3>& temp, bool inverse = false) const

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:309

function execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, cbool_t<inverse>)

template <bool inverse, univector_tag Tag1, univector_tag Tag2, univector_tag Tag3>
KFR_MEM_INTRINSIC void execute(univector<complex<T>, Tag1>& out, const univector<complex<T>, Tag2>& in,
                               univector<u8, Tag3>& temp, cbool_t<inverse> inv) const

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
Template parameters
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:329

function execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, bool)

template <univector_tag Tag1, univector_tag Tag2>
KFR_MEM_INTRINSIC void execute(univector<complex<T>, Tag1>& out, const univector<complex<T>, Tag2>& in,
                               u8* temp, bool inverse = false) const

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:346

function execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, cbool_t<inverse>)

template <bool inverse, univector_tag Tag1, univector_tag Tag2>
KFR_MEM_INTRINSIC void execute(univector<complex<T>, Tag1>& out, const univector<complex<T>, Tag2>& in,
                               u8* temp, cbool_t<inverse> inv) const

Execute the complex DFT on in and write the result to out.

Parameters
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. If NULL, scratch buffer of size plan->temp_size will be allocated on stack or heap.
Template parameters
inverse If true, apply the inverse DFT.

Note

No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to the constructor.

Defined at dft/fft.hpp:366

variable data

autofree<u8> data

Internal data.

Defined at dft/fft.hpp:372

variable data_size

size_t data_size

Internal data size.

Defined at dft/fft.hpp:373

variable all_stages

std::vector<dft_stage_ptr<T>> all_stages

Internal data.

Defined at dft/fft.hpp:375

variable stages

std::array<std::vector<dft_stage<T>*>, 2> stages

Internal data.

Defined at dft/fft.hpp:376

variable arblen

bool arblen

True if Bluestein's FFT algorithm is selected.

Defined at dft/fft.hpp:377

variable progressive_optimized

bool progressive_optimized

True if the plan is for progressive execution of the DFT.

Defined at dft/fft.hpp:378

typedef bitset

using bitset = std::bitset<DFT_MAX_STAGES>

Defined at dft/fft.hpp:379

variable disposition_inplace

std::array<bitset, 2> disposition_inplace

Internal data.

Defined at dft/fft.hpp:380

variable disposition_outofplace

std::array<bitset, 2> disposition_outofplace

Internal data.

Defined at dft/fft.hpp:381

function calc_disposition()

void calc_disposition()

Internal function

Defined at dft/fft.hpp:384

function precompute_disposition(int, bitset, bool)

static bitset precompute_disposition(int num_stages, bitset can_inplace_per_stage,
                                     bool inplace_requested)

Internal function

Defined at dft/fft.hpp:387

struct progressive

struct progressive { … }

Internal data structure for progressive execution of the DFT. Do not access the members directly as they may change in future versions.

variable inverse

bool inverse

Defined at dft/fft.hpp:395

variable out

complex<T>* out

Defined at dft/fft.hpp:396

variable in

const complex<T>* in

Defined at dft/fft.hpp:397

variable temp

u8* temp

Defined at dft/fft.hpp:398

variable disposition

bitset disposition

Defined at dft/fft.hpp:399

variable scratch

complex<T>* scratch

Defined at dft/fft.hpp:400

variable step

size_t step = 0

Defined at dft/fft.hpp:401

Defined at dft/fft.hpp:393

function progressive_total_steps()

size_t progressive_total_steps() const

Returns the number of steps for progressive execution of the DFT.

Returns
The number of steps for progressive execution.

Defined at dft/fft.hpp:406

function progressive_start(bool, complex<T> *, const complex<T> *, u8 *)

Initiates the progressive execution of the DFT.

Parameters
inverse If true, applies the inverse DFT.
out Pointer to the output data.
in Pointer to the input data.
temp Temporary (scratch) buffer. A scratch buffer of size plan->temp_size must be provided.
Returns
A progressive structure that can be used with progressive_step.

Note

Ensure that the entire input data is available in the in buffer before calling this function. The out buffer will contain the result data after the final step of the progressive execution.

Defined at dft/fft.hpp:419

function progressive_step(progressive &)

Steps the progressive execution of the DFT.

Parameters
progressive A progressive structure returned by progressive_start.
Returns
true if there are more steps to execute, false if the DFT is complete.

Defined at dft/fft.hpp:435

struct noinit

struct noinit { … }

Defined at dft/fft.hpp:442

constructor dft_plan<T>(noinit, size_t, dft_order, bool)

explicit dft_plan(noinit, size_t size, dft_order order = dft_order::normal,
                  bool progressive_optimized = false)

Defined at dft/fft.hpp:445

function execute_dft(cbool_t<inverse>, complex<T> *, const complex<T> *, u8 *)

template <bool inverse>
KFR_INTRINSIC void execute_dft(cbool_t<inverse>, complex<T>* out, const complex<T>* in, u8* temp) const

Defined at dft/fft.hpp:452

Defined at dft/fft.hpp:184