1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

sprout/functional/dft.hpp 追加

sprout/complex.hpp 修正
This commit is contained in:
bolero-MURAKAMI 2012-02-25 23:59:46 +09:00
parent aa96f9ce73
commit 10c73ea3e3
17 changed files with 453 additions and 24 deletions

View file

@ -0,0 +1,40 @@
#ifndef SPROUT_FUNCTIONAL_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
#define SPROUT_FUNCTIONAL_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
#include <cmath>
#include <iterator>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout {
namespace detail {
template<typename InputIterator>
SPROUT_CONSTEXPR inline typename std::iterator_traits<InputIterator>::value_type dft_element_gen(
InputIterator first,
InputIterator last,
typename std::iterator_traits<InputIterator>::value_type::value_type arg,
typename std::iterator_traits<InputIterator>::difference_type k = 0,
typename std::iterator_traits<InputIterator>::value_type value = typename std::iterator_traits<InputIterator>::value_type(),
typename std::iterator_traits<InputIterator>::value_type::value_type theta = typename std::iterator_traits<InputIterator>::value_type::value_type()
)
{
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
using std::cos;
using std::sin;
return first != last
? value + sprout::detail::dft_element_gen(
sprout::next(first),
last,
arg,
k + 1,
*first * value_type(cos(theta), sin(theta)),
arg * (k + 1)
)
: value
;
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_DFT_DETAIL_DFT_ELEMENT_GEN_HPP