61 [&](
auto& resultElement)
63 const auto k = static_cast<double>(&resultElement - result.data());
64 const auto minusTwoPiKOverN = -constants::twoPi * k / static_cast<double>(n);
65 resultElement = std::complex<double>{ 0., 0. };
66 for (
auto m = 0u; m < std::min(n, x.size()); ++m)
68 const auto angle = minusTwoPiKOverN *
static_cast<double>(m);
69 resultElement += (x[m] * std::polar(1.,
angle));
89 template<
typename dtype>
106 const auto dataColSlice = data.
cSlice();
107 const auto resultColSlice = result.cSlice();
109 for (
uint32 row = 0; row < data.numRows(); ++row)
111 const auto rowData = data(row, dataColSlice);
113 result.put(row, resultColSlice, rowResult);
141 template<
typename dtype>
150 return fft(inArray, inArray.
size(), inAxis);
154 return fft(inArray, inArray.
numCols(), inAxis);
158 return fft(inArray, inArray.
numRows(), inAxis);
180 template<
typename dtype>
195 const auto&
shape = inArray.shape();
197 const auto dataColSlice = data.
cSlice();
198 const auto resultColSlice = result.cSlice();
200 for (
uint32 row = 0; row < data.numRows(); ++row)
202 const auto rowData = data(row, dataColSlice);
204 result.put(row, resultColSlice, rowResult);
211 return fft(inArray.transpose(), inN,
Axis::COL).transpose();
232 template<
typename dtype>
241 return fft(inArray, inArray.size(), inAxis);
245 return fft(inArray, inArray.numCols(), inAxis);
249 return fft(inArray, inArray.numRows(), inAxis);
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
size_type size() const noexcept
Definition NdArrayCore.hpp:4604
self_type transpose() const
Definition NdArrayCore.hpp:4963
size_type numCols() const noexcept
Definition NdArrayCore.hpp:3545
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4591
size_type numRows() const noexcept
Definition NdArrayCore.hpp:3557
Slice cSlice(index_type inStartIdx=0, size_type inStepSize=1) const
Definition NdArrayCore.hpp:1008
Definition FFT/FFT.hpp:42
NdArray< std::complex< double > > fft_internal(const NdArray< std::complex< double > > &x, uint32 n)
Definition FFT/FFT.hpp:50
Definition FFT/FFT.hpp:40
NdArray< std::complex< double > > fft(const NdArray< dtype > &inArray, uint32 inN, Axis inAxis=Axis::NONE)
Definition FFT/FFT.hpp:90
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition StlAlgorithms.hpp:226
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
auto angle(const std::complex< dtype > &inValue)
Definition angle.hpp:48
auto complex(dtype inReal)
Definition complex.hpp:47
Shape shape(const NdArray< dtype > &inArray) noexcept
Definition Functions/shape.hpp:42
std::uint32_t uint32
Definition Types.hpp:40