2012-04-10 03:54:38 +00:00
|
|
|
#ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|
|
|
|
#define SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|
2012-02-25 14:59:46 +00:00
|
|
|
|
2013-02-01 11:21:01 +00:00
|
|
|
#include <iterator>
|
|
|
|
#include <type_traits>
|
2012-02-25 14:59:46 +00:00
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/index_tuple.hpp>
|
2012-03-31 07:24:13 +00:00
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
2012-02-25 14:59:46 +00:00
|
|
|
#include <sprout/iterator/operation.hpp>
|
2013-02-01 11:21:01 +00:00
|
|
|
#include <sprout/iterator/dft_iterator.hpp>
|
2012-02-25 14:59:46 +00:00
|
|
|
#include <sprout/algorithm/fixed/result_of.hpp>
|
2013-02-07 14:12:57 +00:00
|
|
|
#include <sprout/pit/pit.hpp>
|
2013-02-01 11:21:01 +00:00
|
|
|
#include <sprout/math/comparison.hpp>
|
2012-04-10 03:54:38 +00:00
|
|
|
#include <sprout/numeric/dft/dft_element.hpp>
|
2013-02-01 11:21:01 +00:00
|
|
|
#include <sprout/detail/container_complate.hpp>
|
2012-02-25 14:59:46 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace fixed {
|
|
|
|
namespace detail {
|
2013-02-01 11:21:01 +00:00
|
|
|
template<typename RandomAccessIterator, typename Result, sprout::index_t... Indexes>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
2013-02-01 11:21:01 +00:00
|
|
|
dft_impl_ra(
|
|
|
|
RandomAccessIterator first, RandomAccessIterator last, Result const& result,
|
2012-02-25 14:59:46 +00:00
|
|
|
sprout::index_tuple<Indexes...>,
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::container_traits<Result>::difference_type offset,
|
|
|
|
typename sprout::container_traits<Result>::size_type size,
|
|
|
|
typename sprout::container_traits<Result>::size_type input_size
|
2012-02-25 14:59:46 +00:00
|
|
|
)
|
|
|
|
{
|
2012-03-31 07:24:13 +00:00
|
|
|
return sprout::remake<Result>(
|
2013-02-01 11:21:01 +00:00
|
|
|
result, size,
|
|
|
|
(Indexes >= offset && sprout::math::less(Indexes, offset + size) && sprout::math::less(Indexes, offset + input_size)
|
2012-02-25 14:59:46 +00:00
|
|
|
? sprout::detail::dft_element_impl(first, last, Indexes - offset, input_size)
|
2012-03-31 07:24:13 +00:00
|
|
|
: *sprout::next(sprout::internal_begin(result), Indexes)
|
2012-02-25 14:59:46 +00:00
|
|
|
)...
|
|
|
|
);
|
|
|
|
}
|
2013-02-01 11:21:01 +00:00
|
|
|
template<typename RandomAccessIterator, typename Result>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
2013-02-01 11:21:01 +00:00
|
|
|
dft(
|
|
|
|
RandomAccessIterator first, RandomAccessIterator last, Result const& result,
|
|
|
|
std::random_access_iterator_tag*
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::fixed::detail::dft_impl_ra(
|
|
|
|
first, last, result,
|
2012-05-14 02:33:36 +00:00
|
|
|
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
2012-03-31 07:24:13 +00:00
|
|
|
sprout::internal_begin_offset(result),
|
2012-02-25 14:59:46 +00:00
|
|
|
sprout::size(result),
|
2013-01-03 08:01:50 +00:00
|
|
|
sprout::distance(first, last)
|
2012-02-25 14:59:46 +00:00
|
|
|
);
|
|
|
|
}
|
2013-02-01 11:21:01 +00:00
|
|
|
|
|
|
|
template<typename ForwardIterator, typename Result, typename... Args>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
>::type
|
|
|
|
dft_impl(
|
|
|
|
ForwardIterator first, ForwardIterator last, Result const& result,
|
|
|
|
typename sprout::container_traits<Result>::size_type size,
|
|
|
|
ForwardIterator first_, typename sprout::container_traits<Result>::difference_type i,
|
|
|
|
Args const&... args
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::remake<Result>(result, sprout::size(result), args...);
|
|
|
|
}
|
|
|
|
template<typename ForwardIterator, typename Result, typename... Args>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
>::type
|
|
|
|
dft_impl(
|
|
|
|
ForwardIterator first, ForwardIterator last, Result const& result,
|
|
|
|
typename sprout::container_traits<Result>::size_type size,
|
|
|
|
ForwardIterator first_, typename sprout::container_traits<Result>::difference_type i,
|
|
|
|
Args const&... args
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return first != last && sizeof...(Args) < size
|
|
|
|
? sprout::fixed::detail::dft_impl(
|
|
|
|
sprout::next(first), last, result, size, first_, i + 1,
|
|
|
|
args..., sprout::detail::dft_element_impl(first_, last, i, size)
|
|
|
|
)
|
|
|
|
: sprout::detail::container_complate(result, args...)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
template<typename ForwardIterator, typename Result>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
dft(
|
|
|
|
ForwardIterator first, ForwardIterator last, Result const& result,
|
|
|
|
void*
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::fixed::detail::dft_impl(first, last, result, sprout::size(result), first, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ForwardIterator, typename Result>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
sprout::is_fixed_container<Result>::value,
|
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
>::type
|
|
|
|
dft(ForwardIterator first, ForwardIterator last, Result const& result) {
|
|
|
|
typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category;
|
|
|
|
return sprout::fixed::detail::dft(first, last, result, category());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ForwardIterator, typename Result>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
!sprout::is_fixed_container<Result>::value,
|
|
|
|
typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
>::type
|
|
|
|
dft(ForwardIterator first, ForwardIterator last, Result const& result) {
|
|
|
|
return sprout::remake<Result>(
|
|
|
|
result, sprout::size(result),
|
|
|
|
sprout::make_dft_iterator(first, last),
|
|
|
|
sprout::make_dft_iterator(first, last, sprout::distance(first, last))
|
|
|
|
);
|
|
|
|
}
|
2012-02-25 14:59:46 +00:00
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// dft
|
|
|
|
//
|
2013-02-01 11:21:01 +00:00
|
|
|
template<typename ForwardIterator, typename Result>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
2013-02-01 11:21:01 +00:00
|
|
|
dft(ForwardIterator first, ForwardIterator last, Result const& result) {
|
2012-02-25 14:59:46 +00:00
|
|
|
return sprout::fixed::detail::dft(first, last, result);
|
|
|
|
}
|
2013-02-01 11:21:01 +00:00
|
|
|
|
|
|
|
template<typename Result, typename ForwardIterator>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
|
|
|
dft(ForwardIterator first, ForwardIterator last) {
|
|
|
|
return sprout::fixed::dft(first, last, sprout::pit<Result>());
|
|
|
|
}
|
2012-02-25 14:59:46 +00:00
|
|
|
} // namespace fixed
|
|
|
|
|
|
|
|
using sprout::fixed::dft;
|
|
|
|
} // namespace sprout
|
|
|
|
|
2012-04-10 03:54:38 +00:00
|
|
|
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|