mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add C++11constexpr fft
Stockham DIT fft algorithm written in C++11constexpr
This commit is contained in:
parent
f08464943f
commit
e6af368c77
9 changed files with 575 additions and 169 deletions
|
@ -8,51 +8,9 @@
|
|||
#ifndef SPROUT_NUMERIC_FFT_IFFT_HPP
|
||||
#define SPROUT_NUMERIC_FFT_IFFT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/complex.hpp>
|
||||
#include <sprout/algorithm/cxx14/transform.hpp>
|
||||
#include <sprout/numeric/fft/fft.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
struct conj_value {
|
||||
public:
|
||||
template<typename Complex>
|
||||
SPROUT_CONSTEXPR Complex operator()(Complex const& x) const {
|
||||
return conj(x);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Size>
|
||||
struct conj_div_value {
|
||||
private:
|
||||
Size n_;
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR conj_div_value(Size n)
|
||||
: n_(n)
|
||||
{}
|
||||
template<typename Complex>
|
||||
SPROUT_CONSTEXPR Complex operator()(Complex const& x) const {
|
||||
return conj(x) / typename Complex::value_type(n_);
|
||||
}
|
||||
};
|
||||
template<typename Size>
|
||||
SPROUT_CONSTEXPR sprout::detail::conj_div_value<Size>
|
||||
conj_div(Size n) {
|
||||
return sprout::detail::conj_div_value<Size>(n);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// ifft
|
||||
//
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
ifft(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
sprout::transform(first, last, first, sprout::detail::conj_value());
|
||||
sprout::fft(first, last);
|
||||
sprout::transform(first, last, first, sprout::detail::conj_div(last - first));
|
||||
}
|
||||
} // namespace sprout
|
||||
#include <sprout/numeric/fft/fixed/ifft.hpp>
|
||||
#include <sprout/numeric/fft/fit/ifft.hpp>
|
||||
#include <sprout/numeric/fft/cxx14/ifft.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_FFT_IFFT_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue