56 #ifndef _STL_NUMERIC_H
57 #define _STL_NUMERIC_H 1
63 #if __cplusplus >= 201103L
67 _GLIBCXX_BEGIN_NAMESPACE_VERSION
80 template<
typename _ForwardIterator,
typename _Tp>
82 iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
88 typename iterator_traits<_ForwardIterator>::value_type>)
91 for (; __first != __last; ++__first)
98 _GLIBCXX_END_NAMESPACE_VERSION
105 _GLIBCXX_BEGIN_NAMESPACE_ALGO
118 template<
typename _InputIterator,
typename _Tp>
120 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
126 for (; __first != __last; ++__first)
127 __init = __init + *__first;
144 template<
typename _InputIterator,
typename _Tp,
typename _BinaryOperation>
146 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
147 _BinaryOperation __binary_op)
153 for (; __first != __last; ++__first)
154 __init = __binary_op(__init, *__first);
172 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp>
174 inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
175 _InputIterator2 __first2, _Tp __init)
182 for (; __first1 != __last1; ++__first1, ++__first2)
183 __init = __init + (*__first1 * *__first2);
203 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp,
204 typename _BinaryOperation1,
typename _BinaryOperation2>
206 inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
207 _InputIterator2 __first2, _Tp __init,
208 _BinaryOperation1 __binary_op1,
209 _BinaryOperation2 __binary_op2)
216 for (; __first1 != __last1; ++__first1, ++__first2)
217 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
235 template<
typename _InputIterator,
typename _OutputIterator>
237 partial_sum(_InputIterator __first, _InputIterator __last,
238 _OutputIterator __result)
240 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
248 if (__first == __last)
250 _ValueType __value = *__first;
252 while (++__first != __last)
254 __value = __value + *__first;
255 *++__result = __value;
275 template<
typename _InputIterator,
typename _OutputIterator,
276 typename _BinaryOperation>
278 partial_sum(_InputIterator __first, _InputIterator __last,
279 _OutputIterator __result, _BinaryOperation __binary_op)
281 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
289 if (__first == __last)
291 _ValueType __value = *__first;
293 while (++__first != __last)
295 __value = __binary_op(__value, *__first);
296 *++__result = __value;
315 template<
typename _InputIterator,
typename _OutputIterator>
317 adjacent_difference(_InputIterator __first,
318 _InputIterator __last, _OutputIterator __result)
320 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
328 if (__first == __last)
330 _ValueType __value = *__first;
332 while (++__first != __last)
334 _ValueType __tmp = *__first;
335 *++__result = __tmp - __value;
357 template<
typename _InputIterator,
typename _OutputIterator,
358 typename _BinaryOperation>
360 adjacent_difference(_InputIterator __first, _InputIterator __last,
361 _OutputIterator __result, _BinaryOperation __binary_op)
363 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
371 if (__first == __last)
373 _ValueType __value = *__first;
375 while (++__first != __last)
377 _ValueType __tmp = *__first;
378 *++__result = __binary_op(__tmp, __value);
384 _GLIBCXX_END_NAMESPACE_ALGO
#define __glibcxx_function_requires(...)
Definition: concept_check.h:47
#define _GLIBCXX_MOVE(__val)
Definition: move.h:145
namespace std _GLIBCXX_VISIBILITY(default)
Definition: stl_numeric.h:103
#define __glibcxx_requires_valid_range(_First, _Last)
Definition: debug.h:65