From 786c4f3b1e3a861e1ee91b5e2076b544bc0dd93b Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 11 Oct 2017 11:58:29 +0900 Subject: [PATCH] add C++17 transform_exclusive_scan, transform_inclusive_scan --- sprout/numeric/cxx14.hpp | 2 + .../cxx14/transform_exclusive_scan.hpp | 42 ++++ .../cxx14/transform_inclusive_scan.hpp | 60 ++++++ sprout/numeric/fit.hpp | 2 + .../numeric/fit/transform_exclusive_scan.hpp | 51 +++++ .../numeric/fit/transform_inclusive_scan.hpp | 77 ++++++++ sprout/numeric/fixed.hpp | 2 + sprout/numeric/fixed/exclusive_scan.hpp | 1 - sprout/numeric/fixed/inclusive_scan.hpp | 1 + .../fixed/transform_exclusive_scan.hpp | 126 ++++++++++++ .../fixed/transform_inclusive_scan.hpp | 183 ++++++++++++++++++ sprout/numeric/transform_exclusive_scan.hpp | 16 ++ sprout/numeric/transform_inclusive_scan.hpp | 16 ++ sprout/range/numeric/cxx14.hpp | 2 + .../cxx14/transform_exclusive_scan.hpp | 34 ++++ .../cxx14/transform_inclusive_scan.hpp | 42 ++++ sprout/range/numeric/exclusive_scan.hpp | 1 + sprout/range/numeric/fit.hpp | 2 + .../numeric/fit/transform_exclusive_scan.hpp | 38 ++++ .../numeric/fit/transform_inclusive_scan.hpp | 53 +++++ sprout/range/numeric/fixed.hpp | 2 + .../fixed/transform_exclusive_scan.hpp | 45 +++++ .../fixed/transform_inclusive_scan.hpp | 63 ++++++ sprout/range/numeric/inclusive_scan.hpp | 1 + .../numeric/transform_exclusive_scan.hpp | 16 ++ .../numeric/transform_inclusive_scan.hpp | 16 ++ 26 files changed, 893 insertions(+), 1 deletion(-) create mode 100644 sprout/numeric/cxx14/transform_exclusive_scan.hpp create mode 100644 sprout/numeric/cxx14/transform_inclusive_scan.hpp create mode 100644 sprout/numeric/fit/transform_exclusive_scan.hpp create mode 100644 sprout/numeric/fit/transform_inclusive_scan.hpp create mode 100644 sprout/numeric/fixed/transform_exclusive_scan.hpp create mode 100644 sprout/numeric/fixed/transform_inclusive_scan.hpp create mode 100644 sprout/numeric/transform_exclusive_scan.hpp create mode 100644 sprout/numeric/transform_inclusive_scan.hpp create mode 100644 sprout/range/numeric/cxx14/transform_exclusive_scan.hpp create mode 100644 sprout/range/numeric/cxx14/transform_inclusive_scan.hpp create mode 100644 sprout/range/numeric/fit/transform_exclusive_scan.hpp create mode 100644 sprout/range/numeric/fit/transform_inclusive_scan.hpp create mode 100644 sprout/range/numeric/fixed/transform_exclusive_scan.hpp create mode 100644 sprout/range/numeric/fixed/transform_inclusive_scan.hpp create mode 100644 sprout/range/numeric/transform_exclusive_scan.hpp create mode 100644 sprout/range/numeric/transform_inclusive_scan.hpp diff --git a/sprout/numeric/cxx14.hpp b/sprout/numeric/cxx14.hpp index aabc6108..6b2208c6 100644 --- a/sprout/numeric/cxx14.hpp +++ b/sprout/numeric/cxx14.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include diff --git a/sprout/numeric/cxx14/transform_exclusive_scan.hpp b/sprout/numeric/cxx14/transform_exclusive_scan.hpp new file mode 100644 index 00000000..f80c8f2f --- /dev/null +++ b/sprout/numeric/cxx14/transform_exclusive_scan.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 29.8.9 Transform exclusive scan + // + template< + typename InputIterator, typename OutputIterator, typename T, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform_exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + typedef typename std::iterator_traits::value_type value_type; + value_type sum = sprout::move(init); + *result = sum; + if (first == last) { + return ++result; + } + value_type temp = unary_op(*first); + while (++first != last) { + sum = binary_op(sum, temp); + *++result = sum; + temp = unary_op(*first); + } + return ++result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/cxx14/transform_inclusive_scan.hpp b/sprout/numeric/cxx14/transform_inclusive_scan.hpp new file mode 100644 index 00000000..2af7592b --- /dev/null +++ b/sprout/numeric/cxx14/transform_inclusive_scan.hpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 29.8.10 Transform inclusive scan + // + template< + typename InputIterator, typename OutputIterator, typename BinaryOperation, typename UnaryOperation, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform_inclusive_scan(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + typedef typename std::iterator_traits::value_type value_type; + value_type sum = sprout::move(init); + *result = sum; + if (first == last) { + return ++result; + } + sum = binary_op(sum, unary_op(*first)); + *++result = sum; + while (++first != last) { + sum = binary_op(sum, unary_op(*first)); + *++result = sum; + } + return ++result; + } + template< + typename InputIterator, typename OutputIterator, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform_inclusive_scan(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op, UnaryOperation unary_op) { + typedef typename std::iterator_traits::value_type value_type; + if (first == last) { + return result; + } + value_type sum = unary_op(*first); + *result = sum; + while (++first != last) { + sum = binary_op(sum, unary_op(*first)); + *++result = sum; + } + return ++result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/fit.hpp b/sprout/numeric/fit.hpp index 25ab21be..459a9974 100644 --- a/sprout/numeric/fit.hpp +++ b/sprout/numeric/fit.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include diff --git a/sprout/numeric/fit/transform_exclusive_scan.hpp b/sprout/numeric/fit/transform_exclusive_scan.hpp new file mode 100644 index 00000000..22b1cf28 --- /dev/null +++ b/sprout/numeric/fit/transform_exclusive_scan.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_exclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::difference_type offset + ) + { + typedef typename std::iterator_traits::difference_type diff_type; + return sprout::sub_copy( + sprout::get_internal(sprout::fixed::transform_exclusive_scan(first, last, result, init, binary_op, unary_op)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // transform_exclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_exclusive_scan(InputIterator first, InputIterator last, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::fit::detail::transform_exclusive_scan_impl(first, last, result, init, binary_op, unary_op, sprout::internal_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/fit/transform_inclusive_scan.hpp b/sprout/numeric/fit/transform_inclusive_scan.hpp new file mode 100644 index 00000000..79b6edb6 --- /dev/null +++ b/sprout/numeric/fit/transform_inclusive_scan.hpp @@ -0,0 +1,77 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fit { + namespace detail { + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::difference_type offset + ) + { + typedef typename std::iterator_traits::difference_type diff_type; + return sprout::sub_copy( + sprout::get_internal(sprout::fixed::transform_inclusive_scan(first, last, result, binary_op, unary_op)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)) + ); + } + } // namespace detail + // + // transform_inclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::fit::detail::transform_inclusive_scan_impl(first, last, result, binary_op, unary_op, sprout::internal_begin_offset(result)); + } + + namespace detail { + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init, + typename sprout::container_traits::difference_type offset + ) + { + typedef typename std::iterator_traits::difference_type diff_type; + return sprout::sub_copy( + sprout::get_internal(sprout::fixed::transform_inclusive_scan(first, last, result, binary_op, unary_op, init)), + offset, + offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last) + 1, sprout::size(result)) + ); + } + } // namespace detail + // + // transform_inclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + static_assert(sprout::is_forward_iterator::value, "Sorry, not implemented."); + return sprout::fit::detail::transform_inclusive_scan_impl(first, last, result, binary_op, unary_op, init, sprout::internal_begin_offset(result)); + } + } // namespace fit +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/fixed.hpp b/sprout/numeric/fixed.hpp index 017bd453..8e31dc41 100644 --- a/sprout/numeric/fixed.hpp +++ b/sprout/numeric/fixed.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include diff --git a/sprout/numeric/fixed/exclusive_scan.hpp b/sprout/numeric/fixed/exclusive_scan.hpp index 400df854..ad767372 100644 --- a/sprout/numeric/fixed/exclusive_scan.hpp +++ b/sprout/numeric/fixed/exclusive_scan.hpp @@ -16,7 +16,6 @@ #include #include #include -#include namespace sprout { namespace fixed { diff --git a/sprout/numeric/fixed/inclusive_scan.hpp b/sprout/numeric/fixed/inclusive_scan.hpp index b247d036..036b9a75 100644 --- a/sprout/numeric/fixed/inclusive_scan.hpp +++ b/sprout/numeric/fixed/inclusive_scan.hpp @@ -8,6 +8,7 @@ #ifndef SPROUT_NUMERIC_FIXED_INCLUSIVE_SCAN_HPP #define SPROUT_NUMERIC_FIXED_INCLUSIVE_SCAN_HPP +#include #include #include #include diff --git a/sprout/numeric/fixed/transform_exclusive_scan.hpp b/sprout/numeric/fixed/transform_exclusive_scan.hpp new file mode 100644 index 00000000..675afb7e --- /dev/null +++ b/sprout/numeric/fixed/transform_exclusive_scan.hpp @@ -0,0 +1,126 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == sizeof...(Args) + 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_exclusive_scan_impl_1( + InputIterator const&, InputIterator const&, Result const& result, BinaryOperation, UnaryOperation, + typename sprout::container_traits::size_type, + typename sprout::container_traits::value_type const& value, + typename sprout::container_traits::value_type const& temp, + Args const&... args + ) + { + return sprout::remake(result, sprout::size(result), args..., value); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size != sizeof...(Args) + 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_exclusive_scan_impl_1( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::size_type size, + typename sprout::container_traits::value_type const& value, + typename sprout::container_traits::value_type const& temp, + Args const&... args + ) + { + return first != last && sizeof...(Args) + 1 < size + ? transform_exclusive_scan_impl_1(sprout::next(first), last, result, binary_op, unary_op, size, binary_op(value, temp), unary_op(*first), args..., value) + : sprout::detail::container_complate(result, args..., value) + ; + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == 0, + typename sprout::fixed::results::algorithm::type + >::type + transform_exclusive_scan_impl( + InputIterator, InputIterator, Result const& result, T, BinaryOperation, UnaryOperation, + typename sprout::container_traits::size_type + ) + { + return sprout::detail::container_complate(result); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_exclusive_scan_impl( + InputIterator, InputIterator, Result const& result, T init, BinaryOperation, UnaryOperation, + typename sprout::container_traits::size_type + ) + { + return sprout::detail::container_complate(result, init); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + (sprout::container_traits::static_size > 1), + typename sprout::fixed::results::algorithm::type + >::type + transform_exclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::size_type size + ) + { + return first != last + ? transform_exclusive_scan_impl_1(sprout::next(first), last, result, binary_op, unary_op, size, init, unary_op(*first)) + : sprout::detail::container_complate(result, init) + ; + } + } // namespace detail + // + // transform_exclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputIterator first, InputIterator last, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::detail::transform_exclusive_scan_impl(first, last, result, init, binary_op, unary_op, sprout::size(result)); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputIterator first, InputIterator last, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_exclusive_scan(first, last, sprout::pit(), init, binary_op, unary_op); + } + } // namespace fixed + + template< + typename InputIterator, typename Result, typename T, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputIterator first, InputIterator last, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_exclusive_scan(first, last, result, init, binary_op, unary_op); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputIterator first, InputIterator last, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_exclusive_scan(first, last, init, binary_op, unary_op); + } +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/fixed/transform_inclusive_scan.hpp b/sprout/numeric/fixed/transform_inclusive_scan.hpp new file mode 100644 index 00000000..a831d44e --- /dev/null +++ b/sprout/numeric/fixed/transform_inclusive_scan.hpp @@ -0,0 +1,183 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace fixed { + namespace detail { + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == sizeof...(Args) + 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl_1( + InputIterator const&, InputIterator const&, Result const& result, BinaryOperation, UnaryOperation, + typename sprout::container_traits::size_type, + typename sprout::container_traits::value_type const& value, + Args const&... args + ) + { + return sprout::remake(result, sprout::size(result), args..., value); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size != sizeof...(Args) + 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl_1( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::size_type size, + typename sprout::container_traits::value_type const& value, + Args const&... args + ) + { + return first != last && sizeof...(Args) + 1 < size + ? transform_inclusive_scan_impl_1(sprout::next(first), last, result, binary_op, unary_op, size, binary_op(value, unary_op(*first)), args..., value) + : sprout::detail::container_complate(result, args..., value) + ; + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == 0, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl( + InputIterator, InputIterator, Result const& result, BinaryOperation, UnaryOperation, + typename sprout::container_traits::size_type + ) + { + return sprout::remake(result, sprout::size(result)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size != 0, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, + typename sprout::container_traits::size_type size + ) + { + return first != last + ? transform_inclusive_scan_impl_1(sprout::next(first), last, result, binary_op, unary_op, size, unary_op(*first)) + : sprout::detail::container_complate(result) + ; + } + } // namespace detail + // + // transform_inclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::detail::transform_inclusive_scan_impl(first, last, result, binary_op, unary_op, sprout::size(result)); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_inclusive_scan(first, last, sprout::pit(), binary_op, unary_op); + } + + namespace detail { + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == 0, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl( + InputIterator, InputIterator, Result const& result, BinaryOperation, T, + typename sprout::container_traits::size_type + ) + { + return sprout::remake(result, sprout::size(result)); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + sprout::container_traits::static_size == 1, + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl( + InputIterator, InputIterator, Result const& result, BinaryOperation, T init, + typename sprout::container_traits::size_type + ) + { + return sprout::remake(result, sprout::size(result), init); + } + template + inline SPROUT_CONSTEXPR typename std::enable_if< + (sprout::container_traits::static_size > 1), + typename sprout::fixed::results::algorithm::type + >::type + transform_inclusive_scan_impl( + InputIterator const& first, InputIterator const& last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init, + typename sprout::container_traits::size_type size + ) + { + return first != last + ? transform_inclusive_scan_impl_1(first, last, result, binary_op, unary_op, size, init) + : sprout::detail::container_complate(result, init) + ; + } + } // namespace detail + // + // transform_inclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::detail::transform_inclusive_scan_impl(first, last, result, binary_op, unary_op, init, sprout::size(result)); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::transform_inclusive_scan(first, last, sprout::pit(), binary_op, unary_op, init); + } + } // namespace fixed + + template< + typename InputIterator, typename Result, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_inclusive_scan(first, last, result, binary_op, unary_op); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_inclusive_scan(first, last, binary_op, unary_op); + } + + template< + typename InputIterator, typename Result, typename BinaryOperation, typename UnaryOperation, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::transform_inclusive_scan(first, last, result, binary_op, unary_op, init); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputIterator first, InputIterator last, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::transform_inclusive_scan(first, last, binary_op, unary_op, unary_op, init); + } +} // namespace sprout + +#endif // #ifndef SPROUT_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/transform_exclusive_scan.hpp b/sprout/numeric/transform_exclusive_scan.hpp new file mode 100644 index 00000000..9d5aa479 --- /dev/null +++ b/sprout/numeric/transform_exclusive_scan.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/numeric/transform_inclusive_scan.hpp b/sprout/numeric/transform_inclusive_scan.hpp new file mode 100644 index 00000000..e2d00571 --- /dev/null +++ b/sprout/numeric/transform_inclusive_scan.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/cxx14.hpp b/sprout/range/numeric/cxx14.hpp index 38c9df8f..271c66c3 100644 --- a/sprout/range/numeric/cxx14.hpp +++ b/sprout/range/numeric/cxx14.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include diff --git a/sprout/range/numeric/cxx14/transform_exclusive_scan.hpp b/sprout/range/numeric/cxx14/transform_exclusive_scan.hpp new file mode 100644 index 00000000..8b84a55e --- /dev/null +++ b/sprout/range/numeric/cxx14/transform_exclusive_scan.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + // + // transform_exclusive_scan + // + template< + typename InputRange, typename OutputIterator, typename T, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR OutputIterator + transform_exclusive_scan(InputRange const& rng, OutputIterator result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::transform_exclusive_scan(sprout::begin(rng), sprout::end(rng), result, init, binary_op, unary_op); + } + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/cxx14/transform_inclusive_scan.hpp b/sprout/range/numeric/cxx14/transform_inclusive_scan.hpp new file mode 100644 index 00000000..83883607 --- /dev/null +++ b/sprout/range/numeric/cxx14/transform_inclusive_scan.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + // + // transform_inclusive_scan + // + template< + typename InputRange, typename OutputIterator, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR OutputIterator + transform_inclusive_scan(InputRange const& rng, OutputIterator result, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op); + } + template< + typename InputRange, typename OutputIterator, typename BinaryOperation, typename UnaryOperation, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR OutputIterator + transform_inclusive_scan(InputRange const& rng, OutputIterator result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op, init); + } + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_CXX14_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/exclusive_scan.hpp b/sprout/range/numeric/exclusive_scan.hpp index a17f08d3..f78eeeaa 100644 --- a/sprout/range/numeric/exclusive_scan.hpp +++ b/sprout/range/numeric/exclusive_scan.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_RANGE_NUMERIC_EXCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/fit.hpp b/sprout/range/numeric/fit.hpp index 93c07c5c..0bf466d5 100644 --- a/sprout/range/numeric/fit.hpp +++ b/sprout/range/numeric/fit.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_HPP diff --git a/sprout/range/numeric/fit/transform_exclusive_scan.hpp b/sprout/range/numeric/fit/transform_exclusive_scan.hpp new file mode 100644 index 00000000..57cc968e --- /dev/null +++ b/sprout/range/numeric/fit/transform_exclusive_scan.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // transform_exclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_exclusive_scan(InputRange const& rng, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fit::transform_exclusive_scan(sprout::begin(rng), sprout::end(rng), result, init, binary_op, unary_op); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_exclusive_scan(InputRange const& rng, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fit::transform_exclusive_scan(sprout::begin(rng), sprout::end(rng), init, binary_op, unary_op); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/fit/transform_inclusive_scan.hpp b/sprout/range/numeric/fit/transform_inclusive_scan.hpp new file mode 100644 index 00000000..7f65f609 --- /dev/null +++ b/sprout/range/numeric/fit/transform_inclusive_scan.hpp @@ -0,0 +1,53 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fit { + // + // transform_inclusive_scan + // + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fit::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op); + } + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fit::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op, init); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputRange const& rng) { + return sprout::fit::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng)); + } + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fit::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), binary_op, unary_op); + } + template + inline SPROUT_CONSTEXPR typename sprout::fit::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fit::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), binary_op, unary_op, init); + } + } // namespace fit + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/fixed.hpp b/sprout/range/numeric/fixed.hpp index 914d1d2e..095ac8e2 100644 --- a/sprout/range/numeric/fixed.hpp +++ b/sprout/range/numeric/fixed.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_HPP diff --git a/sprout/range/numeric/fixed/transform_exclusive_scan.hpp b/sprout/range/numeric/fixed/transform_exclusive_scan.hpp new file mode 100644 index 00000000..0910f36e --- /dev/null +++ b/sprout/range/numeric/fixed/transform_exclusive_scan.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // transform_exclusive_scan + // + template< + typename InputRange, typename Result, typename T, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputRange const& rng, Result const& result, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_exclusive_scan(sprout::begin(rng), sprout::end(rng), result, init, binary_op, unary_op); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_exclusive_scan(InputRange const& rng, T init, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_exclusive_scan(sprout::begin(rng), sprout::end(rng), init, binary_op, unary_op); + } + } // namespace fixed + + using sprout::range::fixed::transform_exclusive_scan; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/fixed/transform_inclusive_scan.hpp b/sprout/range/numeric/fixed/transform_inclusive_scan.hpp new file mode 100644 index 00000000..1cddb274 --- /dev/null +++ b/sprout/range/numeric/fixed/transform_inclusive_scan.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace range { + namespace fixed { + // + // transform_inclusive_scan + // + template< + typename InputRange, typename Result, typename BinaryOperation, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op); + } + template< + typename InputRange, typename Result, typename BinaryOperation, typename UnaryOperation, typename T, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, Result const& result, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), result, binary_op, unary_op, init); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputRange const& rng) { + return sprout::fixed::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng)); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, BinaryOperation binary_op, UnaryOperation unary_op) { + return sprout::fixed::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), binary_op, unary_op); + } + template + inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type + transform_inclusive_scan(InputRange const& rng, BinaryOperation binary_op, UnaryOperation unary_op, T init) { + return sprout::fixed::transform_inclusive_scan(sprout::begin(rng), sprout::end(rng), binary_op, unary_op, init); + } + } // namespace fixed + + using sprout::range::fixed::transform_inclusive_scan; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_TRANSFORM_INCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/inclusive_scan.hpp b/sprout/range/numeric/inclusive_scan.hpp index 30b9f159..1ffe6210 100644 --- a/sprout/range/numeric/inclusive_scan.hpp +++ b/sprout/range/numeric/inclusive_scan.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_RANGE_NUMERIC_INCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/transform_exclusive_scan.hpp b/sprout/range/numeric/transform_exclusive_scan.hpp new file mode 100644 index 00000000..549cb7d0 --- /dev/null +++ b/sprout/range/numeric/transform_exclusive_scan.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_HPP diff --git a/sprout/range/numeric/transform_inclusive_scan.hpp b/sprout/range/numeric/transform_inclusive_scan.hpp new file mode 100644 index 00000000..d5943e16 --- /dev/null +++ b/sprout/range/numeric/transform_inclusive_scan.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2011-2017 Bolero MURAKAMI + 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) +=============================================================================*/ +#ifndef SPROUT_RANGE_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP +#define SPROUT_RANGE_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP + +#include +#include +#include +#include + +#endif // #ifndef SPROUT_RANGE_NUMERIC_TRANSFORM_INCLUSIVE_SCAN_HPP