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
|
2012-02-25 14:59:46 +00:00
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/operation.hpp>
|
2012-05-09 01:15:19 +00:00
|
|
|
#include <sprout/math/sin.hpp>
|
|
|
|
#include <sprout/math/cos.hpp>
|
2012-02-25 14:59:46 +00:00
|
|
|
|
|
|
|
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,
|
2012-02-25 14:59:46 +00:00
|
|
|
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()
|
2012-02-25 14:59:46 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
|
2012-05-09 01:15:19 +00:00
|
|
|
using sprout::cos;
|
|
|
|
using sprout::sin;
|
2012-02-25 14:59:46 +00:00
|
|
|
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
|