ReactOS 0.4.15-dev-7998-gdb93cb1
_numeric.h File Reference
#include <stl/_function_base.h>
#include <stl/_iterator_base.h>
#include <stl/_numeric.c>
Include dependency graph for _numeric.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class _InputIterator , class _Tp >
_STLP_BEGIN_NAMESPACE _STLP_INLINE_LOOP _Tp accumulate (_InputIterator __first, _InputIterator __last, _Tp _Init)
 
template<class _InputIterator , class _Tp , class _BinaryOperation >
_STLP_INLINE_LOOP _Tp accumulate (_InputIterator __first, _InputIterator __last, _Tp _Init, _BinaryOperation __binary_op)
 
template<class _InputIterator1 , class _InputIterator2 , class _Tp >
_STLP_INLINE_LOOP _Tp inner_product (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp _Init)
 
template<class _InputIterator1 , class _InputIterator2 , class _Tp , class _BinaryOperation1 , class _BinaryOperation2 >
_STLP_INLINE_LOOP _Tp inner_product (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp _Init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
 
template<class _InputIterator , class _OutputIterator , class _Tp , class _BinaryOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __partial_sum (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp *, _BinaryOperation __binary_op)
 
template<class _InputIterator , class _OutputIterator >
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator partial_sum (_InputIterator __first, _InputIterator __last, _OutputIterator __result)
 
template<class _InputIterator , class _OutputIterator , class _BinaryOperation >
_OutputIterator partial_sum (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op)
 
template<class _InputIterator , class _OutputIterator , class _Tp , class _BinaryOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __adjacent_difference (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp *, _BinaryOperation __binary_op)
 
template<class _InputIterator , class _OutputIterator >
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator adjacent_difference (_InputIterator __first, _InputIterator __last, _OutputIterator __result)
 
template<class _InputIterator , class _OutputIterator , class _BinaryOperation >
_OutputIterator adjacent_difference (_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op)
 
template<class _Tp , class _Integer , class _MonoidOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _Tp __power (_Tp __x, _Integer __n, _MonoidOperation __opr)
 
template<class _Tp , class _Integer >
_STLP_MOVE_TO_STD_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _Tp __power (_Tp __x, _Integer __n)
 
template<class _Tp , class _Integer , class _MonoidOperation >
_STLP_MOVE_TO_STD_NAMESPACE _Tp power (_Tp __x, _Integer __n, _MonoidOperation __opr)
 
template<class _Tp , class _Integer >
_Tp power (_Tp __x, _Integer __n)
 
template<class _ForwardIterator , class _Tp >
_STLP_INLINE_LOOP void iota (_ForwardIterator __first, _ForwardIterator __last, _Tp __val)
 

Function Documentation

◆ __adjacent_difference()

template<class _InputIterator , class _OutputIterator , class _Tp , class _BinaryOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __adjacent_difference ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result,
_Tp *  ,
_BinaryOperation  __binary_op 
)

Definition at line 57 of file _numeric.c.

59 {
60 _STLP_DEBUG_CHECK(__check_range(__first, __last))
61 if (__first == __last) return __result;
62 *__result = *__first;
63 _Tp __val = *__first;
64 while (++__first != __last) {
65 _Tp __tmp = *__first;
66 *++__result = __binary_op(__tmp, __val);
67 __val = __tmp;
68 }
69 return ++__result;
70}
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_DEBUG_CHECK(expr)
Definition: _debug.h:440

Referenced by adjacent_difference().

◆ __partial_sum()

template<class _InputIterator , class _OutputIterator , class _Tp , class _BinaryOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __partial_sum ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result,
_Tp *  ,
_BinaryOperation  __binary_op 
)

Definition at line 40 of file _numeric.c.

41 {
42 _STLP_DEBUG_CHECK(__check_range(__first, __last))
43 if (__first == __last) return __result;
44 *__result = *__first;
45
46 _Tp __val = *__first;
47 while (++__first != __last) {
48 __val = __binary_op(__val, *__first);
49 *++__result = __val;
50 }
51 return ++__result;
52}

Referenced by partial_sum().

◆ __power() [1/2]

template<class _Tp , class _Integer >
_STLP_MOVE_TO_STD_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _Tp __power ( _Tp  __x,
_Integer  __n 
)
inline

Definition at line 152 of file _numeric.h.

152 {
153 return __power(__x, __n, multiplies<_Tp>());
154}
return __n
Definition: _algo.h:75
_STLP_MOVE_TO_PRIV_NAMESPACE _Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr)
Definition: _numeric.c:74

◆ __power() [2/2]

template<class _Tp , class _Integer , class _MonoidOperation >
_STLP_MOVE_TO_PRIV_NAMESPACE _Tp __power ( _Tp  __x,
_Integer  __n,
_MonoidOperation  __opr 
)

Definition at line 74 of file _numeric.c.

74 {
76 if (__n == 0)
77 return __identity_element(__opr);
78 else {
79 while ((__n & 1) == 0) {
80 __n >>= 1;
81 __x = __opr(__x, __x);
82 }
83 _Tp __result = __x;
85 __n >>= 1;
86 while (__n != 0) {
87 __x = __opr(__x, __x);
88 if ((__n & 1) != 0)
89 __result = __opr(__result, __x);
90 __n >>= 1;
91 }
92 return __result;
94 }
95 _STLP_MPWFIX_CATCH_ACTION(__x = _Tp())
96}
#define _STLP_MPWFIX_CATCH
Definition: _apple.h:111
#define _STLP_MPWFIX_CATCH_ACTION(action)
Definition: _apple.h:112
#define _STLP_MPWFIX_TRY
Definition: _apple.h:110
_Tp __identity_element(plus< _Tp >)

Referenced by __power(), power(), powT(), and rope< _CharT, _Alloc >::rope().

◆ accumulate() [1/2]

template<class _InputIterator , class _Tp >
_STLP_BEGIN_NAMESPACE _STLP_INLINE_LOOP _Tp accumulate ( _InputIterator  __first,
_InputIterator  __last,
_Tp  _Init 
)

Definition at line 42 of file _numeric.h.

42 {
43 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
44 for ( ; __first != __last; ++__first)
45 _Init = _Init + *__first;
46 return _Init;
47}
#define _STLP_PRIV
Definition: _dm.h:70

Referenced by gslice::_M_size(), AccumTest::accum1(), AccumTest::accum2(), DivideTest::div(), valarray< _Tp >::sum(), and TimesTest::times().

◆ accumulate() [2/2]

template<class _InputIterator , class _Tp , class _BinaryOperation >
_STLP_INLINE_LOOP _Tp accumulate ( _InputIterator  __first,
_InputIterator  __last,
_Tp  _Init,
_BinaryOperation  __binary_op 
)

Definition at line 51 of file _numeric.h.

52 {
53 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
54 for ( ; __first != __last; ++__first)
55 _Init = __binary_op(_Init, *__first);
56 return _Init;
57}

◆ adjacent_difference() [1/2]

template<class _InputIterator , class _OutputIterator >
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator adjacent_difference ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result 
)
inline

Definition at line 121 of file _numeric.h.

122 {
123 return _STLP_PRIV __adjacent_difference(__first, __last, __result,
124 _STLP_VALUE_TYPE(__first, _InputIterator),
125 _STLP_PRIV __minus(_STLP_VALUE_TYPE(__first, _InputIterator)));
126}
minus< _Tp > __minus(_Tp *)
#define _STLP_VALUE_TYPE(_It, _Tp)
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp *, _BinaryOperation __binary_op)
Definition: _numeric.c:57

Referenced by AdjTest::adjdiff0(), AdjTest::adjdiff1(), and AdjTest::adjdiff2().

◆ adjacent_difference() [2/2]

template<class _InputIterator , class _OutputIterator , class _BinaryOperation >
_OutputIterator adjacent_difference ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result,
_BinaryOperation  __binary_op 
)

Definition at line 130 of file _numeric.h.

131 {
132 return _STLP_PRIV __adjacent_difference(__first, __last, __result,
133 _STLP_VALUE_TYPE(__first, _InputIterator),
134 __binary_op);
135}

◆ inner_product() [1/2]

template<class _InputIterator1 , class _InputIterator2 , class _Tp >
_STLP_INLINE_LOOP _Tp inner_product ( _InputIterator1  __first1,
_InputIterator1  __last1,
_InputIterator2  __first2,
_Tp  _Init 
)

Definition at line 61 of file _numeric.h.

62 {
63 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
64 for ( ; __first1 != __last1; ++__first1, ++__first2)
65 _Init = _Init + (*__first1 * *__first2);
66 return _Init;
67}

Referenced by InnerprodTest::inprod0(), InnerprodTest::inprod1(), InnerprodTest::inprod2(), and PlusMinusTest::plus0().

◆ inner_product() [2/2]

template<class _InputIterator1 , class _InputIterator2 , class _Tp , class _BinaryOperation1 , class _BinaryOperation2 >
_STLP_INLINE_LOOP _Tp inner_product ( _InputIterator1  __first1,
_InputIterator1  __last1,
_InputIterator2  __first2,
_Tp  _Init,
_BinaryOperation1  __binary_op1,
_BinaryOperation2  __binary_op2 
)

Definition at line 72 of file _numeric.h.

75 {
76 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
77 for ( ; __first1 != __last1; ++__first1, ++__first2)
78 _Init = __binary_op1(_Init, __binary_op2(*__first1, *__first2));
79 return _Init;
80}

◆ iota()

template<class _ForwardIterator , class _Tp >
_STLP_INLINE_LOOP void iota ( _ForwardIterator  __first,
_ForwardIterator  __last,
_Tp  __val 
)

Definition at line 174 of file _numeric.h.

174 {
175 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
176 while (__first != __last)
177 *__first++ = __val++;
178}

Referenced by __iota(), and IotaTest::iota1().

◆ partial_sum() [1/2]

template<class _InputIterator , class _OutputIterator >
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator partial_sum ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result 
)
inline

Definition at line 94 of file _numeric.h.

95 {
96 return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
97 _STLP_PRIV __plus(_STLP_VALUE_TYPE(__first, _InputIterator)));
98}
_STLP_MOVE_TO_PRIV_NAMESPACE plus< _Tp > __plus(_Tp *)
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIterator __partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp *, _BinaryOperation __binary_op)
Definition: _numeric.c:40

Referenced by PartialTest::partsum0(), PartialTest::partsum1(), and PartialTest::partsum2().

◆ partial_sum() [2/2]

template<class _InputIterator , class _OutputIterator , class _BinaryOperation >
_OutputIterator partial_sum ( _InputIterator  __first,
_InputIterator  __last,
_OutputIterator  __result,
_BinaryOperation  __binary_op 
)
inline

Definition at line 102 of file _numeric.h.

103 {
104 return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
105 __binary_op);
106}

◆ power() [1/2]

template<class _Tp , class _Integer >
_Tp power ( _Tp  __x,
_Integer  __n 
)
inline

Definition at line 166 of file _numeric.h.

166 {
167 return _STLP_PRIV __power(__x, __n, multiplies<_Tp>());
168}

◆ power() [2/2]

template<class _Tp , class _Integer , class _MonoidOperation >
_STLP_MOVE_TO_STD_NAMESPACE _Tp power ( _Tp  __x,
_Integer  __n,
_MonoidOperation  __opr 
)
inline

Definition at line 161 of file _numeric.h.

161 {
162 return _STLP_PRIV __power(__x, __n, __opr);
163}