mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-10-19 13:49:23 +00:00
move dft functional/ -> numeric/
This commit is contained in:
parent
e6bfb69be9
commit
4a8e938887
20 changed files with 78 additions and 77 deletions
11
sprout/numeric/dft.hpp
Normal file
11
sprout/numeric/dft.hpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/dft.hpp>
|
||||
#include <sprout/numeric/dft/idft.hpp>
|
||||
#include <sprout/numeric/dft/dft_element.hpp>
|
||||
#include <sprout/numeric/dft/idft_element.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_HPP
|
||||
|
40
sprout/numeric/dft/detail/dft_element_gen.hpp
Normal file
40
sprout/numeric/dft/detail/dft_element_gen.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator>
|
||||
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,
|
||||
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 std::cos;
|
||||
using std::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
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_DFT_ELEMENT_GEN_HPP
|
8
sprout/numeric/dft/dft.hpp
Normal file
8
sprout/numeric/dft/dft.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_DFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed/dft.hpp>
|
||||
#include <sprout/numeric/dft/fit/dft.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DFT_HPP
|
48
sprout/numeric/dft/dft_element.hpp
Normal file
48
sprout/numeric/dft/dft_element.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_ELEMENT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIXED_DFT_ELEMENT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/detail/dft_element_gen.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Size>
|
||||
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,
|
||||
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(
|
||||
first,
|
||||
last,
|
||||
-(2 * sprout::math::pi<elem_type>() * i / size)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// dft_element
|
||||
//
|
||||
template<typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::value_type dft_element(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
typename std::iterator_traits<InputIterator>::difference_type i
|
||||
)
|
||||
{
|
||||
return sprout::detail::dft_element_impl(
|
||||
first,
|
||||
last,
|
||||
i,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_ELEMENT_HPP
|
46
sprout/numeric/dft/fit/dft.hpp
Normal file
46
sprout/numeric/dft/fit/dft.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIT_DFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIT_DFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/numeric/dft/fixed/dft.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type dft_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
typename sprout::container_traits<Result>::difference_type offset
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::dft(first, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// dft
|
||||
//
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type dft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::dft_impl(first, last, result, sprout::internal_begin_offset(result));
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_DFT_HPP
|
46
sprout/numeric/dft/fit/idft.hpp
Normal file
46
sprout/numeric/dft/fit/idft.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIT_IDFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIT_IDFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/numeric/dft/fixed/idft.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type idft_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
typename sprout::container_traits<Result>::difference_type offset
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::idft(first, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// idft
|
||||
//
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type idft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::idft_impl(first, last, result, sprout::internal_begin_offset(result));
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_IDFT_HPP
|
71
sprout/numeric/dft/fixed/dft.hpp
Normal file
71
sprout/numeric/dft/fixed/dft.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/numeric/dft/dft_element.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type dft_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
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
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(
|
||||
result,
|
||||
sprout::size(result),
|
||||
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
|
||||
? sprout::detail::dft_element_impl(first, last, Indexes - offset, input_size)
|
||||
: *sprout::next(sprout::internal_begin(result), Indexes)
|
||||
)...
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type dft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::dft_impl(
|
||||
first,
|
||||
last,
|
||||
result,
|
||||
typename sprout::index_range<0, sprout::container_traits<Result>::static_size>::type(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// dft
|
||||
//
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type dft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::dft(first, last, result);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::dft;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_DFT_HPP
|
71
sprout/numeric/dft/fixed/idft.hpp
Normal file
71
sprout/numeric/dft/fixed/idft.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIXED_IDFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIXED_IDFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/numeric/dft/idft_element.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type idft_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
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
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(
|
||||
result,
|
||||
sprout::size(result),
|
||||
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
|
||||
? sprout::detail::idft_element_impl(first, last, Indexes - offset, input_size)
|
||||
: *sprout::next(sprout::internal_begin(result), Indexes)
|
||||
)...
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type idft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::idft_impl(
|
||||
first,
|
||||
last,
|
||||
result,
|
||||
typename sprout::index_range<0, sprout::container_traits<Result>::static_size>::type(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// idft
|
||||
//
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type idft(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::idft(first, last, result);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::idft;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_IDFT_HPP
|
8
sprout/numeric/dft/idft.hpp
Normal file
8
sprout/numeric/dft/idft.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_IDFT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_IDFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed/idft.hpp>
|
||||
#include <sprout/numeric/dft/fit/idft.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_IDFT_HPP
|
50
sprout/numeric/dft/idft_element.hpp
Normal file
50
sprout/numeric/dft/idft_element.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#ifndef SPROUT_NUMERIC_DFT_FIXED_IDFT_ELEMENT_HPP
|
||||
#define SPROUT_NUMERIC_DFT_FIXED_IDFT_ELEMENT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/detail/dft_element_gen.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Size>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::value_type idft_element_impl(
|
||||
InputIterator first,
|
||||
InputIterator 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(
|
||||
first,
|
||||
last,
|
||||
2 * sprout::math::pi<elem_type>() * i / size
|
||||
)
|
||||
/ static_cast<elem_type>(size)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// idft_element
|
||||
//
|
||||
template<typename InputIterator>
|
||||
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(
|
||||
first,
|
||||
last,
|
||||
i,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_IDFT_ELEMENT_HPP
|
8
sprout/numeric/fft.hpp
Normal file
8
sprout/numeric/fft.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_NUMERIC_FFT_HPP
|
||||
#define SPROUT_NUMERIC_FFT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/fft/bitrev_table.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_FFT_HPP
|
||||
|
8
sprout/numeric/fft/bitrev_table.hpp
Normal file
8
sprout/numeric/fft/bitrev_table.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_NUMERIC_FFT_BITREV_TABLE_HPP
|
||||
#define SPROUT_NUMERIC_FFT_BITREV_TABLE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/fft/fixed/bitrev_table.hpp>
|
||||
#include <sprout/numeric/fft/fit/bitrev_table.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_FFT_BITREV_TABLE_HPP
|
41
sprout/numeric/fft/fit/bitrev_table.hpp
Normal file
41
sprout/numeric/fft/fit/bitrev_table.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef SPROUT_NUMERIC_FFT_FIT_BITREV_TABLE_HPP
|
||||
#define SPROUT_NUMERIC_FFT_FIT_BITREV_TABLE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/numeric/fft/fixed/bitrev_table.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type bitrev_table_impl(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::difference_type offset
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::bitrev_table(cont)),
|
||||
offset,
|
||||
offset + sprout::size(cont)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// bitrev_table
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type bitrev_table(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::bitrev_table_impl(cont, sprout::internal_begin_offset(cont));
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_FFT_FIT_BITREV_TABLE_HPP
|
64
sprout/numeric/fft/fixed/bitrev_table.hpp
Normal file
64
sprout/numeric/fft/fixed/bitrev_table.hpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#ifndef SPROUT_NUMERIC_FFT_FIXED_BITREV_TABLE_HPP
|
||||
#define SPROUT_NUMERIC_FFT_FIXED_BITREV_TABLE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/integer/bit_reverse.hpp>
|
||||
#include <sprout/integer/bit_length.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Container, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type bitrev_table_impl(
|
||||
Container const& cont,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
std::size_t bit_length,
|
||||
typename sprout::container_traits<Container>::difference_type offset,
|
||||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
return sprout::remake<Container>(
|
||||
cont,
|
||||
sprout::size(cont),
|
||||
(Indexes >= offset && Indexes < offset + size
|
||||
? sprout::bit_reverse_in(
|
||||
static_cast<typename sprout::container_traits<Container>::value_type>(Indexes - offset),
|
||||
bit_length
|
||||
)
|
||||
: *sprout::next(sprout::internal_begin(cont), Indexes)
|
||||
)...
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// bitrev_table
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type bitrev_table(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::bitrev_table_impl(
|
||||
cont,
|
||||
typename sprout::index_range<0, sprout::container_traits<Container>::static_size>::type(),
|
||||
sprout::empty(cont)
|
||||
? 0
|
||||
: sprout::bit_length(sprout::size(cont) - 1)
|
||||
,
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::bitrev_table;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_FFT_FIXED_BITREV_TABLE_HPP
|
Loading…
Add table
Add a link
Reference in a new issue