1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/numeric/dft/detail/dft_element_gen.hpp

44 lines
1.4 KiB
C++
Raw Normal View History

2012-04-10 03:54:38 +00:00
#ifndef SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
#define SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
#include <iterator>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/math/sin.hpp>
#include <sprout/math/cos.hpp>
namespace sprout {
namespace detail {
template<typename InputIterator>
2012-10-06 04:53:07 +00:00
inline SPROUT_CONSTEXPR 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,
2012-10-06 04:53:07 +00:00
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 sprout::cos;
using sprout::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
2012-04-10 03:54:38 +00:00
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP