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/idft_element.hpp

50 lines
1.8 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2016-02-25 09:48:28 +00:00
Copyright (c) 2011-2016 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
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)
=============================================================================*/
2012-12-03 12:48:50 +00:00
#ifndef SPROUT_NUMERIC_DFT_IDFT_ELEMENT_HPP
#define SPROUT_NUMERIC_DFT_IDFT_ELEMENT_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/math/constants.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/numeric/dft/detail/dft_element_gen.hpp>
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
idft_element_impl(
2016-04-01 14:37:48 +00:00
InputIterator const& first, InputIterator const& last, typename std::iterator_traits<InputIterator>::difference_type i,
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
)
/ static_cast<elem_type>(size)
;
}
} // namespace detail
//
// idft_element
//
template<typename InputIterator>
2012-10-06 04:53:07 +00:00
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::value_type
idft_element( InputIterator first, InputIterator last, typename std::iterator_traits<InputIterator>::difference_type i) {
return sprout::detail::idft_element_impl(
2012-10-06 04:53:07 +00:00
first, last, i,
sprout::distance(first, last)
);
}
} // namespace sprout
2012-12-03 12:48:50 +00:00
#endif // #ifndef SPROUT_NUMERIC_DFT_IDFT_ELEMENT_HPP