/*============================================================================= Copyright (c) 2011-2017 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_COEFFICIENT_ARRAY_HPP #define SPROUT_NUMERIC_FFT_COEFFICIENT_ARRAY_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace detail { template inline SPROUT_CONSTEXPR sprout::array, sizeof...(Indexes)*2> make_fft_coefficients_impl( sprout::array, sizeof...(Indexes)> const& arr, sprout::complex mul, sprout::index_tuple ) { return sprout::array, sizeof...(Indexes)*2>{ { arr[Indexes]..., (arr[Indexes] * mul)... } }; } template inline SPROUT_CONSTEXPR typename std::enable_if< N == 0, typename sprout::array, 1> >::type make_fft_coefficients_loop( bool ) { return typename sprout::array, 1>{ { { static_cast( 1 ) } } }; } template inline SPROUT_CONSTEXPR typename std::enable_if< N != 0, typename sprout::array, 1 << N> >::type make_fft_coefficients_loop(bool inverse) { return make_fft_coefficients_impl( make_fft_coefficients_loop(inverse), { sprout::cos((inverse?-1:1)*sprout::math::two_pi() / (1 << Size >> (N - 1))), sprout::sin((inverse?-1:1)*sprout::math::two_pi() / (1 << Size >> (N - 1))) }, sprout::make_index_tuple<1 << (N - 1)>() ); } template inline SPROUT_CONSTEXPR sprout::array, 1 << Size> make_fft_coefficients(bool inverse) { return make_fft_coefficients_loop(inverse); } } // namespace detail template inline SPROUT_CONSTEXPR sprout::array, Size> make_fft_coefficients() { return sprout::detail::make_fft_coefficients(false); } template inline SPROUT_CONSTEXPR sprout::array, Size> make_ifft_coefficients() { return sprout::detail::make_fft_coefficients(true); } } // namespce sprout #endif // SPROUT_NUMERIC_FFT_COEFFICIENT_ARRAY_HPP