Discrete Fourier Transform¶
High-performance FFT, convolution, and spectral analysis routines.
A¶
variabledft_plan<T>::all_stages Internal data.variabledft_plan<T>::arblen True if Bluestein's FFT algorithm is selected.functionautocorrelate(const univector<T, Tag1> &) Computes the auto-correlation of a real or complex signal.
B¶
typedefdft_plan<T>::bitsetvariableconvolve_filter<T>::block_sizevariabledft_stage<T>::blocks Number of independent blocks processed by the stage.enum constantdft_type::both Both direct and inverse transforms.
C¶
functiondft_plan<T>::calc_disposition() Internal functionvariabledft_stage<T>::can_inplace Whether the stage can operate in-place.enum constantdft_pack_format::CCs Conjugate-symmetric format: {DC, 0}, X[1], X[2], ..., X[N/2-1], {Nyquist, 0} The number of complex samples istypedefcdirect_t Tag type selecting the direct (forward) DFT direction.typedefcinvert_t Tag type selecting the inverse DFT direction.functiondft_cache_impl<int>::clear()functiondft_plan_real<T>::complex_size() Returns the number of complex samples produced/consumed.functiondft_plan_md_real<T, Dims>::complex_size() Returns the shape of the complex (packed) spectrum.functiondft_plan_md_real<T, Dims>::complex_size_for(shape<Dims>) Returns the complex spectrum shape for a given real shape.functiondft_plan_real<T>::complex_size_for(size_t, dft_pack_format) Returns the number of complex samples for a given real size and format.functiondft_resampler<T>::compute_block_size(size_t, T, T) Computes the minimal power-of-two block size required for the given filter parameters (Kaiser formula).classconvolve_filter<T> Streaming convolution filter using the overlap-add (block convolution) method.constructorconvolve_filter<T>::convolve_filter<T>(const univector_ref<const T> &, size_t) Constructs a filter and initializes its kernel fromdata.constructorconvolve_filter<T>::convolve_filter<T>(size_t, size_t) Constructs a filter with a kernel of the given length (initially zero).functionconvolve(const univector<T1, Tag1> &, const univector<T2, Tag2> &) Computes the linear convolution of two real or complex signals.functiondft_stage<T>::copy_input(bool, complex<T> *, const complex<T> *, size_t) Copies the input into the stage's working buffer.functioncorrelate(const univector<T1, Tag1> &, const univector<T2, Tag2> &) Computes the linear correlation of two real or complex signals.variableconvolve_filter<T>::cscratchvariabledft_resampler_params::cutoff Normalised cutoff frequency (0..1], where 1.0 = Nyquist of the output rate.
D¶
variabledft_stage<T>::data Pointer to the stage's internal data buffer.variabledft_plan<T>::data Internal data.variabledft_stage<T>::data_size Size in bytes of the stage's internal data (e.g. twiddles).variabledft_plan<T>::data_size Internal data size.variableconvolve_filter<T>::data_sizeclassdct_plan<T> Plan for computing the Discrete Cosine Transform (DCT type 2, unscaled).constructordct_plan<T>::dct_plan<T>(size_t) Constructs a DCT plan for the given size.variabledefault_dft_algorithmenumdft_algorithm Concrete DFT/FFT algorithm selection.typedefdft_cacheclassdft_cache_impl<int>enumdft_decomp Decomposition direction for a butterfly pass.enumdft_family Family of DFT algorithms (groups related algorithms).macroDFT_MAX_STAGESenumdft_order Specifies the desired order for DFT output (and IDFT input).enumdft_pack_format Specifies the packing format for real DFT output data. See https://www.kfr.dev/docs/latest/dft_format/ for detailsclassdft_plan_md_real<T, Dims> Multidimensional real-to-complex / complex-to-real DFT plan.constructordft_plan_md_real<T, Dims>::dft_plan_md_real<T, Dims>(const dft_plan_md_real<T, Dims> &)constructordft_plan_md_real<T, Dims>::dft_plan_md_real<T, Dims>(dft_plan_md_real<T, Dims> &&)constructordft_plan_md_real<T, Dims>::dft_plan_md_real<T, Dims>(shape<Dims>, bool) Constructs a multidimensional real DFT plan.classdft_plan_md<T, Dims> Multidimensional complex DFT plan.constructordft_plan_md<T, Dims>::dft_plan_md<T, Dims>(const dft_plan_md<T, Dims> &)constructordft_plan_md<T, Dims>::dft_plan_md<T, Dims>(dft_plan_md<T, Dims> &&)constructordft_plan_md<T, Dims>::dft_plan_md<T, Dims>(shape<Dims>) Constructs a multidimensional DFT plan for the given shape.typedefdft_plan_ptrtypedefdft_plan_real_ptrclassdft_plan_real<T> Real-to-complex and complex-to-real 1D DFT plan.constructordft_plan_real<T>::dft_plan_real<T>() Constructs an empty (uninitialized) real DFT plan.constructordft_plan_real<T>::dft_plan_real<T>(const dft_plan_real<T> &)constructordft_plan_real<T>::dft_plan_real<T>(dft_plan_real<T> &&)constructordft_plan_real<T>::dft_plan_real<T>(size_t, dft_pack_format, bool) Constructs a real DFT plan.classdft_plan<T> Class for performing 1D DFT/FFT.constructordft_plan<T>::dft_plan<T>() Constructs an empty DFT plan.destructordft_plan<T>::~dft_plan<T>() Destructor.constructordft_plan<T>::dft_plan<T>(const dft_plan<T> &) Copy constructor (deleted).constructordft_plan<T>::dft_plan<T>(dft_plan<T> &&) Move constructor.constructordft_plan<T>::dft_plan<T>(noinit, size_t, dft_order, bool)constructordft_plan<T>::dft_plan<T>(size_t, dft_order, bool) Constructs a DFT plan with the specified size and order.structdft_resampler_params Parameters for constructing adft_resampler.constructordft_resampler_params::dft_resampler_params(int, fbase, fbase, fbase) Constructs resampler parameters.classdft_resampler<T> FFT-based sample-rate converter and FIR filter using overlap-save.constructordft_resampler<T>::dft_resampler<T>(const dft_resampler_params &) Constructs the resampler from the given parameters.typedefdft_stage_ptrclassdft_stage<T> Base structure representing a single DFT stage.destructordft_stage<T>::~dft_stage<T>() Destructor.enumdft_type Direction(s) of DFT computation requested for a plan.functiondft(const univector<complex<T>, Tag> &) Performs the direct (forward) complex DFT using a cached plan.enum constantdft_decomp::dif Decimation-in-frequencyenum constantdft_type::direct Only the direct (forward) transform.variabledft_plan<T>::disposition_inplace Internal data.variabledft_plan<T>::disposition_outofplace Internal data.enum constantdft_decomp::dit Decimation-in-timefunctiondft_stage<T>::do_execute(cdirect_t, complex<T> *, const complex<T> *, u8 *) Performs the direct stage execution (implemented by derived stages).functiondft_stage<T>::do_execute(cinvert_t, complex<T> *, const complex<T> *, u8 *) Performs the inverse stage execution (implemented by derived stages).functiondft_stage<T>::do_initialize(size_t) Initializes the stage's internal data for the given DFT size.functiondft_stage<T>::dump() Prints the stage parameters to stdout for debugging.functiondft_plan<T>::dump() Dumps details of the DFT plan to stdout for inspection.functiondft_plan_md<T, Dims>::dump() Dumps details of the underlying per-axis plans to stdout.functiondft_plan_md_real<T, Dims>::dump() Dumps details of the underlying per-axis plans to stdout.
E¶
functiondft_plan<T>::execute_dft(cbool_t<inverse>, complex<T> *, const complex<T> *, u8 *)functiondft_stage<T>::execute(bool, complex<T> *, const complex<T> *, u8 *) Executes the stage in the requested direction.functiondft_stage<T>::execute(cdirect_t, complex<T> *, const complex<T> *, u8 *) Executes the direct (forward) stage.functiondft_stage<T>::execute(cinvert_t, complex<T> *, const complex<T> *, u8 *) Executes the inverse stage.functiondft_plan<T>::execute(complex<T> *, const complex<T> *, u8 *, bool) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(complex<T> *, const complex<T> *, u8 *, bool)functiondft_plan_md<T, Dims>::execute(complex<T> *, const complex<T> *, u8 *, bool) Executes the multidimensional DFT on raw pointers.functiondft_plan<T>::execute(complex<T> *, const complex<T> *, u8 *, cbool_t<inverse>) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(complex<T> *, const complex<T> *, u8 *, cbool_t<inverse>)functiondft_plan_md<T, Dims>::execute(complex<T> *, const complex<T> *, u8 *, cbool_t<inverse>) Executes the multidimensional DFT with a compile-time direction.functiondft_plan_md_real<T, Dims>::execute(complex<T> *, const T *, u8 *, bool) Forward transform selected by a runtime flag (raw pointers).functiondft_plan_real<T>::execute(complex<T> *, const T *, u8 *, cdirect_t) Executes the forward real-to-complex DFT.functiondft_plan_md_real<T, Dims>::execute(complex<T> *, const T *, u8 *, cdirect_t) Forward transform: real input to packed complex output (raw pointers).functiondft_plan_md<T, Dims>::execute(const tensor<complex<T>, Dims> &, const tensor<complex<T>, Dims> &, u8 *, bool) Executes the multidimensional DFT on tensors.functiondft_plan_md_real<T, Dims>::execute(const tensor<complex<T>, Dims> &, const tensor<T, Dims> &, u8 *, cdirect_t) Forward transform on tensors.functiondft_plan_md_real<T, Dims>::execute(const tensor<T, Dims> &, const tensor<complex<T>, Dims> &, u8 *, cinvert_t) Inverse transform on tensors.functiondft_plan_md_real<T, Dims>::execute(T *, const complex<T> *, u8 *, bool) Inverse transform selected by a runtime flag (raw pointers).functiondft_plan_real<T>::execute(T *, const complex<T> *, u8 *, cinvert_t) Executes the inverse complex-to-real DFT.functiondft_plan_md_real<T, Dims>::execute(T *, const complex<T> *, u8 *, cinvert_t) Inverse transform: packed complex input to real output (raw pointers).functiondct_plan<T>::execute(T *, const T *, u8 *, bool) Executes the DCT.functiondft_plan<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, bool) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, bool)functiondft_plan<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, cbool_t<inverse>) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, cbool_t<inverse>)functiondft_plan<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, bool) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, bool)functiondft_plan<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, cbool_t<inverse>) Execute the complex DFT oninand write the result toout.functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, cbool_t<inverse>)functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<T, Tag2> &, u8 *, cdirect_t) Forward real-to-complex DFT using univector buffers with a raw scratch pointer.functiondft_plan_real<T>::execute(univector<complex<T>, Tag1> &, const univector<T, Tag2> &, univector<u8, Tag3> &, cdirect_t) Forward real-to-complex DFT using univector buffers with a scratch univector.functiondft_plan_real<T>::execute(univector<T, Tag1> &, const univector<complex<T>, Tag2> &, u8 *, cinvert_t) Inverse complex-to-real DFT using univector buffers with a raw scratch pointer.functiondft_plan_real<T>::execute(univector<T, Tag1> &, const univector<complex<T>, Tag2> &, univector<u8, Tag3> &, cinvert_t) Inverse complex-to-real DFT using univector buffers with a scratch univector.functiondct_plan<T>::execute(univector<T, Tag1> &, const univector<T, Tag2> &, univector<u8, Tag3> &, bool) Executes the DCT using univector buffers.
F¶
functiondft_resampler_params::factor() Returns the absolute resampling factor (2^|shift|).functiondft_resampler<T>::factor() Returns the resampling factor (a power of two, >= 1).variableconvolve_filter<T>::fftfunctionfft_multiply_accumulate(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, const univector<complex<T>, Tag3> &, const univector<complex<T>, Tag4> &, dft_pack_format) Multiply-accumulate of two spectra with an addend into a destination.functionfft_multiply_accumulate(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, const univector<complex<T>, Tag3> &, dft_pack_format) Multiply-accumulate of two spectra into a destination.functionfft_multiply(univector<complex<T>, Tag1> &, const univector<complex<T>, Tag2> &, const univector<complex<T>, Tag3> &, dft_pack_format) Element-wise multiplication of two spectra (convolution in time domain).functiondft_resampler<T>::filter_length() Returns the designed filter length (in filter-rate samples).variabledft_plan_real<T>::fmt Packing format of the complex spectrum.enum constantdft_family::fourstep Four-step FFT family.enum constantdft_algorithm::fourstep Four-step FFT algorithm.
G¶
functiondft_cache_impl<int>::get(ctype_t<f32>, size_t)functiondft_cache_impl<int>::get(ctype_t<f64>, size_t)functiondft_cache_impl<int>::getreal(ctype_t<f32>, size_t)functiondft_cache_impl<int>::getreal(ctype_t<f64>, size_t)
I¶
functionidft(const univector<complex<T>, Tag> &) Performs the inverse complex DFT using a cached plan.functiondft_stage<T>::initialize(size_t)functionconvolve_filter<T>::input_block_size() Returns the processing block size.variabledft_resampler_params::input_block_size Computed FFT block size (power of two) satisfying the overlap-save constraint.functiondft_resampler<T>::input_block_size() Returns the input FFT block size \(N\) .functiondft_resampler<T>::input_hop() Returns the number of new input samples consumed per frame.variableconvolve_filter<T>::input_positionfunctiondft_cache_impl<int>::instance()enum constantdft_order::internal Possibly bit/digit-reversed, implementation-defined, may be faster to computeenum constantdft_type::inverse Only the inverse transform.variableconvolve_filter<T>::ir_segmentsfunctionirealdft(const univector<complex<T>, Tag> &) Performs the inverse complex-to-real DFT using a cached plan.functiondft_resampler_params::is_downsampling() Returnstrueif this is a downsampling configuration.functiondft_resampler<T>::is_downsampling() Returnstrueif this resampler downsamples byfactor().functiondft_plan<T>::is_initialized() Checks whether the plan is non-empty.functiondft_plan_real<T>::is_initialized() Checks whether the plan is non-empty.functiondft_plan_md<T, Dims>::is_initialized() Checks whether the plan is non-empty.functiondft_plan_md_real<T, Dims>::is_initialized() Checks whether the plan is non-empty.
K¶
functiondft_resampler<T>::kaiser_beta_from_attenuation(T) Computes the Kaiser window beta from a desired stopband attenuation.macroKFR_DFT_ALGO_SWITCHmacroKFR_DFT_SUPPORTS_ODD_REAL
L¶
variablengfft_plan<T>::l2fftsize Log2 of the FFT size (e.g. 16 means a 65536-point FFT).functionlibrary_version_dft() Returns the full version string of the KFR DFT module.
N¶
variabledft_stage<T>::name Human-readable name of the stage (forvariabledft_stage<T>::need_reorder Whether the stage output requires bit-reversal reordering.functionngfft_execute(const ngfft_plan<T> &, bool, complex<T> *, const complex<T> *, dft_algorithm) Executes the FFT with separate input and output buffers, runtime direction and algorithm.functionngfft_execute(const ngfft_plan<T> &, bool, complex<T> *, dft_algorithm) Executes the FFT in-place with runtime direction and algorithm.functionngfft_execute(const ngfft_plan<T> &, cbool_t<inverse>, complex<T> *, const complex<T> *, dft_algorithm) Executes the FFT with separate input and output buffers, a compile-time direction and runtime algorithm.functionngfft_execute(const ngfft_plan<T> &, cbool_t<inverse>, complex<T> *, dft_algorithm) Executes the FFT in-place with a compile-time direction and runtime algorithm.functionngfft_initialize(ngfft_plan<T> &, dft_algorithm) Initializes the plan's twiddles for a runtime algorithm value.classngfft_plan_real<T>constructorngfft_plan_real<T>::ngfft_plan_real<T>()constructorngfft_plan_real<T>::ngfft_plan_real<T>(uint8_t)classngfft_plan<T> Plan structure for the ng FFT algorithms (new in KFR 7.1).functionngfft_real_execute(const ngfft_plan<T> &, complex<T> *, const T *, dft_algorithm) Executes the forward real-to-complex FFT with a runtime algorithm.functionngfft_real_execute(const ngfft_plan<T> &, T *, const complex<T> *, dft_algorithm) Executes the inverse complex-to-real FFT with a runtime algorithm.functionngfft_twiddle_count(ngfft_plan<T> &, dft_algorithm) Returns the twiddle-factor count for a runtime algorithm value.structdft_plan<T>::noinitenum constantdft_order::normal Normal order
O¶
functiondft_plan_md_real<T, Dims>::operator=(const dft_plan_md_real<T, Dims> &)functiondft_plan_md<T, Dims>::operator=(const dft_plan_md<T, Dims> &)functiondft_plan_real<T>::operator=(const dft_plan_real<T> &)functiondft_plan<T>::operator=(const dft_plan<T> &) Copy assignment operator (deleted).functiondft_stage<T>::operatorfunctiondft_stage<T>::operatorfunctiondft_plan_md_real<T, Dims>::operator=(dft_plan_md_real<T, Dims> &&)functiondft_plan_md<T, Dims>::operator=(dft_plan_md<T, Dims> &&)functiondft_plan_real<T>::operator=(dft_plan_real<T> &&)functiondft_plan<T>::operator=(dft_plan<T> &&) Move assignment operator.functiondft_stage<T>::operatorfunctiondft_stage<T>::operatorvariabledft_stage<T>::out_offset Offset (in complex elements) between successive recursive outputs.functiondft_resampler<T>::output_block_size() Returns the output FFT block size \(M\) .functiondft_resampler<T>::output_hop() Returns the number of valid output samples produced per frame.variableconvolve_filter<T>::overlap
P¶
enum constantdft_pack_format::Perm Packed format: {DC, Nyquist}, X[1], X[2], ..., X[N/2-1] For even N, the number of complex samples istypedefconvolve_filter<T>::plan_tvariableconvolve_filter<T>::positionfunctiondft_plan<T>::precompute_disposition(int, bitset, bool) Internal functionvariableconvolve_filter<T>::premulfunctionconvolve_filter<T>::process_buffer(T *, const T *, size_t)functionconvolve_filter<T>::process_expression(T *, const expression_handle<T> &, size_t)functiondft_resampler<T>::process_frame(const T *) Processes one frame in-place and returns a pointer to the valid output.functiondft_resampler<T>::process_frame(T *, const T *) Processes one frame via overlap-save and writes normalised output.functiondft_resampler<T>::process(std::span<T>, std::span<const T>) Processes an arbitrary-length input stream and writes the resampled output.variabledft_plan<T>::progressive_optimized True if the plan is for progressive execution of the DFT.
R¶
variabledft_stage<T>::radix Radix of the stage (number of butterfly arms).variableconvolve_filter<T>::real_fftvariabledft_plan_md_real<T, Dims>::real_out_is_enough If true, the inverse transform may write directly into the real output buffer without an extra complex working region.functiondft_plan_md_real<T, Dims>::real_out_size() Returns the number of real elements needed to hold the inverse output.functiondft_plan_md_real<T, Dims>::real_out_size_for(shape<Dims>) Returns the real output element count for a given real shape.functionrealdft(const univector<T, Tag> &) Performs the direct (forward) real-to-complex DFT using a cached plan.variabledft_stage<T>::recursion Whether the stage uses recursive execution.functionreference_dft_md(complex<T> *, const complex<T> *, shape<dynamic_shape>, bool, size_t, size_t) Performs Multidimensional Complex DFT using reference implementation (slow, used for testing)functionreference_dft_md(complex<T> *, const T *, shape<dynamic_shape>, bool, size_t, size_t) Performs Multidimensional Direct Real DFT using reference implementation (slow, used for testing)functionreference_dft_md(T *, const complex<T> *, shape<dynamic_shape>, bool, size_t, size_t) Performs Multidimensional Inverse Real DFT using reference implementation (slow, used for testing)functionreference_dft(complex<T> *, const complex<T> *, size_t, bool, size_t, size_t) Performs Complex DFT using reference implementation (slow, used for testing)functionreference_dft(complex<T> *, const T *, size_t, size_t, size_t) Performs Direct Real DFT using reference implementation (slow, used for testing)functionreference_dft(T *, const complex<T> *, size_t, size_t, size_t) Performs Inverse Real DFT using reference implementation (slow, used for testing)variabledft_stage<T>::repeats Number of recursive repetitions used during execution.functionconvolve_filter<T>::reset() Resets the filter state (clears input history and overlap buffers).functiondft_resampler<T>::reset() Resets the resampler to its freshly-constructed state, clearing all buffered input without changing filter parameters.
S¶
variableconvolve_filter<T>::saved_inputvariableconvolve_filter<T>::scratch1variableconvolve_filter<T>::scratch2variableconvolve_filter<T>::segmentsfunctionconvolve_filter<T>::set_data(const univector_ref<const T> &) Sets (replaces) the filter kernel.variabledft_resampler_params::shift Resampling factor as a power of 2 (e.g. 1 for 2x, -1 for 0.5x, 0 for filter-only).variabledft_plan<T>::size The size of the DFT as passed to the constructor.variabledft_plan_real<T>::size Number of real samples in the transform.variabledft_plan_md<T, Dims>::size Per-dimension sizes of the transform.variabledft_plan_md_real<T, Dims>::size Per-dimension sizes of the real transform.typedefconvolve_filter<T>::STfunctiondft_resampler_params::stage_factor() Returns the per-stage conversion ratio (>1 for upsampling, <1 for downsampling).variabledft_stage<T>::stage_size Number of complex elements processed by this stage.variabledft_plan<T>::stages Internal data.variabledft_resampler_params::stopband_atten_db Desired stopband attenuation in dB (e.g. 144). Controls Kaiser beta.
T¶
variableconvolve_filter<T>::tempvariabledft_stage<T>::temp_size Size in bytes of scratch buffer required by this stage.variabledft_plan<T>::temp_size The temporary (scratch) buffer size for the DFT plan.variabledft_plan_md<T, Dims>::temp_size Scratch buffer size in bytes required byvariabledft_plan_md_real<T, Dims>::temp_size Scratch buffer size in bytes required byvariabledft_resampler_params::transition_width Transition bandwidth normalised to the lower-rate Nyquist (0..1].variablengfft_plan<T>::twiddles User-allocated pointer to twiddle factors. The required element count is obtained from ngfft_twiddle_count(); the buffer must be cache-line aligned. Initialise via ngfft_initialize() before first use.
U¶
variabledft_stage<T>::user Stage-specific user value (e.g. log2 of the stage size).
This file was generated by cxxdox, a C++ documentation generator based on MkDocs Material and libclang.