1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-10-05 13:00:00 +00:00

porting sscrisk/CEL

This commit is contained in:
bolero-MURAKAMI 2012-04-01 22:15:09 +09:00
commit db20f64991
181 changed files with 2531 additions and 607 deletions

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_NUMERIC_ACCUMLATE_HPP
#define SPROUT_NUMERIC_ACCUMLATE_HPP
#include <iterator>
#include <sprout/config.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 26.7.2 Accumulate
template<class InputIterator, typename T, typename BinaryOperation>
SPROUT_CONSTEXPR T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) {
return first == last ? init
: sprout::accumulate(first + 1, last, binary_op(init, *first), binary_op)
;
}
template<class InputIterator, typename T>
SPROUT_CONSTEXPR T accumulate(InputIterator first, InputIterator last, T init) {
return sprout::accumulate(first, last, init, NS_SSCRISK_CEL_OR_SPROUT::plus<typename std::iterator_traits<InputIterator>::value_type>());
}
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_ACCUMLATE_HPP

View file

@ -7,8 +7,8 @@
#include <sprout/numeric/fixed/adjacent_difference.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fit {
@ -24,7 +24,7 @@ namespace sprout {
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::adjacent_difference(first, last, result)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result))
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail
@ -54,7 +54,7 @@ namespace sprout {
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::adjacent_difference(first, last, result, binary_op)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result))
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail

View file

@ -7,8 +7,8 @@
#include <sprout/numeric/fixed/partial_sum.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fit {
@ -24,7 +24,7 @@ namespace sprout {
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::partial_sum(first, last, result)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result))
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail
@ -54,7 +54,7 @@ namespace sprout {
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::partial_sum(first, last, result, binary_op)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::min(NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last), sprout::size(result))
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail

View file

@ -0,0 +1,54 @@
#ifndef SPROUT_NUMERIC_INNNER_PRODUCT_HPP
#define SPROUT_NUMERIC_INNNER_PRODUCT_HPP
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 26.7.3 Inner product
template<class InputIterator1, class InputIterator2, typename T, typename BinaryOperation1, typename BinaryOperation2>
SPROUT_CONSTEXPR T inner_product(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
T init,
BinaryOperation1 binary_op1,
BinaryOperation2 binary_op2
)
{
return first1 == last1 ? init
: sprout::inner_product(
sprout::next(first1),
last1,
sprout::next(first2),
binary_op1(init, binary_op2(*first1, *first2)),
binary_op1,
binary_op2
)
;
}
template<class InputIterator1, typename InputIterator2, typename T>
SPROUT_CONSTEXPR T inner_product(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
T init
)
{
return sprout::inner_product(
first1,
last1,
first2,
init,
sprout::plus<typename std::iterator_traits<InputIterator1>::value_type>(),
NS_SSCRISK_CEL_OR_SPROUT::multiplies<typename std::iterator_traits<InputIterator1>::value_type>()
);
}
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_INNNER_PRODUCT_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_MODIFYIING_HPP
#define SPROUT_NUMERIC_MODIFYIING_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/fixed.hpp>
#include <sprout/numeric/fit.hpp>
#endif // #ifndef SPROUT_NUMERIC_MODIFYIING_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_NON_MODIFYIING_HPP
#define SPROUT_NUMERIC_NON_MODIFYIING_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/accumulate.hpp>
#include <sprout/numeric/inner_product.hpp>
#endif // #ifndef SPROUT_NUMERIC_NON_MODIFYIING_HPP