mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add transform_reduce algorithm
This commit is contained in:
parent
2052058357
commit
6e962b0ccc
4 changed files with 288 additions and 0 deletions
|
@ -12,5 +12,6 @@
|
|||
#include <sprout/range/numeric/accumulate.hpp>
|
||||
#include <sprout/range/numeric/reduce.hpp>
|
||||
#include <sprout/range/numeric/inner_product.hpp>
|
||||
#include <sprout/range/numeric/transform_reduce.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_NON_MODIFYIING_HPP
|
||||
|
|
43
sprout/range/numeric/transform_reduce.hpp
Normal file
43
sprout/range/numeric/transform_reduce.hpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*=============================================================================
|
||||
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_REDUCE_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_TRANSFORM_REDUCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/numeric/transform_reduce.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace range {
|
||||
|
||||
// 29.8.5 Transform reduce
|
||||
template<typename InputRange1, typename InputRange2, typename T, typename BinaryOperation1, typename BinaryOperation2>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
transform_reduce(
|
||||
InputRange1 const& range1, InputRange2 const& range2,
|
||||
T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2
|
||||
)
|
||||
{
|
||||
return sprout::transform_reduce(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init, binary_op1, binary_op2);
|
||||
}
|
||||
|
||||
template<typename InputRange1, typename InputRange2, typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
transform_reduce(InputRange1 const& range1, InputRange2 const& range2, T init) {
|
||||
return sprout::transform_reduce(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init);
|
||||
}
|
||||
|
||||
template<typename InputRange, typename T, typename BinaryOperation, typename UnaryOperation>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
transform_reduce(InputRange const& range, T init, BinaryOperation binary_op, UnaryOperation unary_op) {
|
||||
return sprout::transform_reduce(sprout::begin(range), sprout::end(range), init, binary_op, unary_op);
|
||||
}
|
||||
} // namespace range
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_TRANSFORM_REDUCE_HPP
|
Loading…
Add table
Add a link
Reference in a new issue