/*============================================================================= Copyright (c) 2011-2015 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_NUMERIC_FFT_IFFT_HPP #define SPROUT_NUMERIC_FFT_IFFT_HPP #include #include #include #include #include namespace sprout { namespace detail { struct conj_value { public: template SPROUT_CONSTEXPR Complex operator()(Complex const& x) const { return conj(x); } }; template struct conj_div_value { private: Size n_; public: explicit SPROUT_CONSTEXPR conj_div_value(Size n) : n_(n) {} template SPROUT_CONSTEXPR Complex operator()(Complex const& x) const { return conj(x) / typename Complex::value_type(n_); } }; template SPROUT_CONSTEXPR sprout::detail::conj_div_value conj_div(Size n) { return sprout::detail::conj_div_value(n); } } // namespace detail // // ifft // template 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 #endif // #ifndef SPROUT_NUMERIC_FFT_IFFT_HPP