/* Copyright (C) 2025 Joel Yliluoma - Material for https://youtu.be/C4tHxouarGc - https://iki.fi/bisqwit/ */ /* MIT license follows: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include using complex = std::complex; // Baseclass for all DFT methods. // Inheriting class must implement at least one of xform() or xform_many(), and also get_name(). struct DFTbase { std::size_t N; bool inplace; public: // Inplace tells whether the method can safely use the parameter as both input and output. DFTbase(std::size_t n, bool is_inplace) : N(n), inplace(is_inplace) {} virtual ~DFTbase() {} /* The basic transformation: in[] into out[]. */ virtual void xform(const complex* in, std::size_t istep, complex* out, std::size_t ostep) { xform_many(in,istep,0, out,ostep,0, 1); } /* Many transformations in sequence. */ virtual void xform_many(const complex* in, std::size_t istep, std::size_t istep2, complex* out, std::size_t ostep, std::size_t ostep2, std::size_t num) { for(std::size_t n=0; n temp(N*num); xform_many(inout,step,step2, &temp[0],1,N, num); for(std::size_t n=0; n temp(N*num); for(std::size_t n=0; n