From 6a6fc0380646c826b201dd1d9a5e962d4012bfb4 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 22 Dec 2012 22:06:21 +0900 Subject: [PATCH] add range::unstable_accumulate, range::unstable_inner_product --- sprout/range/numeric/non_modifying.hpp | 2 ++ sprout/range/numeric/unstable_accumulate.hpp | 26 ++++++++++++++++ .../range/numeric/unstable_inner_product.hpp | 30 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 sprout/range/numeric/unstable_accumulate.hpp create mode 100644 sprout/range/numeric/unstable_inner_product.hpp diff --git a/sprout/range/numeric/non_modifying.hpp b/sprout/range/numeric/non_modifying.hpp index e3f632e4..0d86c0b7 100644 --- a/sprout/range/numeric/non_modifying.hpp +++ b/sprout/range/numeric/non_modifying.hpp @@ -4,5 +4,7 @@ #include #include #include +#include +#include #endif // #ifndef SPROUT_RANGE_NUMERIC_NON_MODIFYIING_HPP diff --git a/sprout/range/numeric/unstable_accumulate.hpp b/sprout/range/numeric/unstable_accumulate.hpp new file mode 100644 index 00000000..98fd2d0e --- /dev/null +++ b/sprout/range/numeric/unstable_accumulate.hpp @@ -0,0 +1,26 @@ +#ifndef SPROUT_RANGE_NUMERIC_UNSTABLE_ACCUMLATE_HPP +#define SPROUT_RANGE_NUMERIC_UNSTABLE_ACCUMLATE_HPP + +#include +#include + +namespace sprout { + namespace range { + // + // unstable_accumulate + // + template + inline SPROUT_CONSTEXPR T + unstable_accumulate(Range const& range, T init, BinaryOperation binary_op) { + return sprout::unstable_accumulate(sprout::begin(range), sprout::end(range), init, binary_op); + } + + template + inline SPROUT_CONSTEXPR T + unstable_accumulate(Range const& range, T init) { + return sprout::unstable_accumulate(sprout::begin(range), sprout::end(range), init); + } + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_UNSTABLE_ACCUMLATE_HPP diff --git a/sprout/range/numeric/unstable_inner_product.hpp b/sprout/range/numeric/unstable_inner_product.hpp new file mode 100644 index 00000000..01ba669d --- /dev/null +++ b/sprout/range/numeric/unstable_inner_product.hpp @@ -0,0 +1,30 @@ +#ifndef SPROUT_RANGE_NUMERIC_UNSTABLE_INNER_PRODUCT_HPP +#define SPROUT_RANGE_NUMERIC_UNSTABLE_INNER_PRODUCT_HPP + +#include +#include + +namespace sprout { + namespace range { + // + // unstable_inner_product + // + template + inline SPROUT_CONSTEXPR T + unstable_inner_product( + Range1 const& range1, Range2 const& range2, T init, + BinaryOperation1 binary_op1, BinaryOperation2 binary_op2 + ) + { + return sprout::unstable_inner_product(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init, binary_op1, binary_op2); + } + + template + inline SPROUT_CONSTEXPR T + unstable_inner_product(Range1 const& range1, Range2 const& range2, T init) { + return sprout::unstable_inner_product(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init); + } + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_NUMERIC_UNSTABLE_INNER_PRODUCT_HPP