kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit aee9a300d5a72738d8a32222e65b9ab4c64df0af
parent 0ba976aa5383d3d14fbee8937d167afbdf317054
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Wed, 17 Jan 2024 06:39:38 +0000

Constructors for dft_plan

Diffstat:
Minclude/kfr/base/shape.hpp | 1+
Minclude/kfr/dft/fft.hpp | 30++++++++++++++++++++++++++----
Minclude/kfr/dft/impl/ft.hpp | 1-
3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/include/kfr/base/shape.hpp b/include/kfr/base/shape.hpp @@ -99,6 +99,7 @@ KFR_INTRINSIC bool increment_indices(shape<dims>& indices, const shape<dims>& st template <index_t dims> struct shape : static_array_base<index_t, csizeseq_t<dims>> { + static_assert(dims <= 256, "Too many dimensions"); using base = static_array_base<index_t, csizeseq_t<dims>>; using base::base; diff --git a/include/kfr/dft/fft.hpp b/include/kfr/dft/fft.hpp @@ -27,13 +27,10 @@ #include "../base/basic_expressions.hpp" #include "../base/memory.hpp" -#include "../base/small_buffer.hpp" #include "../base/univector.hpp" #include "../math/sin_cos.hpp" #include "../simd/complex.hpp" #include "../simd/constants.hpp" -#include "../simd/read_write.hpp" -#include "../simd/vec.hpp" #include <bitset> CMT_PRAGMA_GNU(GCC diagnostic push) @@ -130,13 +127,25 @@ using dft_stage_ptr = std::unique_ptr<dft_stage<T>>; CMT_MULTI_PROTO(template <typename T> void dft_initialize(dft_plan<T>& plan);) CMT_MULTI_PROTO(template <typename T> void dft_real_initialize(dft_plan_real<T>& plan);) -/// @brief Class for performing DFT/FFT +/// @brief 1D DFT/FFT template <typename T> struct dft_plan { size_t size; size_t temp_size; + dft_plan() + : size(0), temp_size(0), data_size(0), arblen(false), disposition_inplace{}, disposition_outofplace{} + { + } + + dft_plan(const dft_plan&) = delete; + dft_plan(dft_plan&&) = default; + dft_plan& operator=(const dft_plan&) = delete; + dft_plan& operator=(dft_plan&&) = default; + + bool is_initialized() const { return size != 0; } + explicit dft_plan(cpu_t cpu, size_t size, dft_order order = dft_order::normal) : size(size), temp_size(0), data_size(0), arblen(false) { @@ -386,12 +395,25 @@ protected: } }; +/// @brief Real-to-complex and Complex-to-real 1D DFT template <typename T> struct dft_plan_real : dft_plan<T> { size_t size; dft_pack_format fmt; + dft_plan_real() + : size(0), fmt(dft_pack_format::CCs) + { + } + + dft_plan_real(const dft_plan_real&) = delete; + dft_plan_real(dft_plan_real&&) = default; + dft_plan_real& operator=(const dft_plan_real&) = delete; + dft_plan_real& operator=(dft_plan_real&&) = default; + + bool is_initialized() const { return size != 0; } + explicit dft_plan_real(cpu_t cpu, size_t size, dft_pack_format fmt = dft_pack_format::CCs) : dft_plan<T>(typename dft_plan<T>::noinit{}, size / 2), size(size), fmt(fmt) { diff --git a/include/kfr/dft/impl/ft.hpp b/include/kfr/dft/impl/ft.hpp @@ -25,7 +25,6 @@ */ #pragma once -#include "../../base/small_buffer.hpp" #include "../../base/univector.hpp" #include "../../math/sin_cos.hpp" #include "../../simd/complex.hpp"