2012-12-03 12:48:50 +00:00
|
|
|
#ifndef SPROUT_NUMERIC_DFT_DFT_ELEMENT_HPP
|
|
|
|
#define SPROUT_NUMERIC_DFT_DFT_ELEMENT_HPP
|
2012-02-25 14:59:46 +00:00
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/math/constants.hpp>
|
2013-01-03 08:01:50 +00:00
|
|
|
#include <sprout/iterator/operation.hpp>
|
2013-02-01 11:21:01 +00:00
|
|
|
#include <sprout/numeric/dft/detail/dft_element_gen.hpp>
|
2012-02-25 14:59:46 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace detail {
|
|
|
|
template<typename InputIterator, typename Size>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::value_type
|
|
|
|
dft_element_impl(
|
|
|
|
InputIterator first, InputIterator last, typename std::iterator_traits<InputIterator>::difference_type i,
|
2012-02-25 14:59:46 +00:00
|
|
|
Size size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
typedef typename std::iterator_traits<InputIterator>::value_type value_type;
|
|
|
|
typedef typename value_type::value_type elem_type;
|
|
|
|
return sprout::detail::dft_element_gen(
|
2013-07-22 13:00:09 +00:00
|
|
|
first, last,
|
2013-02-14 09:02:43 +00:00
|
|
|
-(sprout::math::two_pi<elem_type>() * i / size)
|
2012-02-25 14:59:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// dft_element
|
|
|
|
//
|
|
|
|
template<typename InputIterator>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::value_type
|
|
|
|
dft_element(InputIterator first, InputIterator last, typename std::iterator_traits<InputIterator>::difference_type i) {
|
2012-02-25 14:59:46 +00:00
|
|
|
return sprout::detail::dft_element_impl(
|
2012-10-06 04:53:07 +00:00
|
|
|
first, last, i,
|
2013-01-03 08:01:50 +00:00
|
|
|
sprout::distance(first, last)
|
2012-02-25 14:59:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
2012-12-03 12:48:50 +00:00
|
|
|
#endif // #ifndef SPROUT_NUMERIC_DFT_DFT_ELEMENT_HPP
|