|
Go to the documentation of this file. 9 #ifndef ADOBE_NUMERIC_HPP 10 #define ADOBE_NUMERIC_HPP 17 #include <boost/bind.hpp> 20 #if defined(__MWERKS__) 21 #pragma warn_unusedarg off 24 #include <boost/range.hpp> 26 #if defined(__MWERKS__) 27 #pragma warn_unusedarg reset 53 template < typename ForwardIterator> 56 typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; 58 ForwardIterator result(first); 60 if (first == last) return result; 62 ForwardIterator previous(first); 65 if (first == last) return result; 67 value_type result_difference(*first - *previous); 68 previous = first; ++first; 72 value_type difference(*first - *previous); 74 if (result_difference < difference) 76 result_difference = difference; 89 template < typename ForwardRange> 90 inline typename boost::range_iterator<ForwardRange>::type 99 template < typename ForwardRange> 100 inline typename boost::range_const_iterator<ForwardRange>::type 122 template < typename InputRange, typename T> 133 template < typename InputIterator, typename T, typename BinaryOperation> 134 inline T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) 136 return std::accumulate(first, last, init, boost::bind(binary_op, _1, _2)); 144 template < typename InputRange, typename T, typename BinaryOperation> 145 inline T accumulate( const InputRange& range, T init, BinaryOperation binary_op) 147 return adobe::accumulate(boost::begin(range), boost::end(range), init, binary_op); 160 template < typename InputRange, typename InputIterator, typename T> 161 inline T inner_product( const InputRange& range, InputIterator first, T init) 171 template < typename InputIterator1, typename InputIterator2, typename T, 172 typename BinaryOperation1, typename BinaryOperation2> 173 inline T inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init, 174 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2) 176 return std::inner_product(first1, last1, first2, init, boost::bind(binary_op1, _1, _2), 177 boost::bind(binary_op2, _1, _2)); 185 template < typename InputRange, typename InputIterator, typename T, 186 typename BinaryOperation1, typename BinaryOperation2> 187 inline T inner_product( const InputRange& range, InputIterator first, T init, 188 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2) 204 template < typename InputRange, typename OutputIterator> 205 inline OutputIterator partial_sum( const InputRange& range, OutputIterator result) 215 template < typename InputIterator, typename OutputIterator, typename BinaryOperation> 216 inline OutputIterator partial_sum(InputIterator first, InputIterator last, OutputIterator result, 217 BinaryOperation binary_op) 219 return std::partial_sum(first, last, result, boost::bind(binary_op, _1, _2)); 227 template < typename InputRange, typename OutputIterator, typename BinaryOperation> 228 inline OutputIterator partial_sum( const InputRange& range, OutputIterator result, 229 BinaryOperation binary_op) 243 template < typename InputRange, typename OutputIterator> 254 template < typename InputIterator, typename OutputIterator, typename BinaryOperation> 256 OutputIterator result, BinaryOperation binary_op) 266 template < typename InputRange, typename OutputIterator, typename BinaryOperation> 268 BinaryOperation binary_op) T accumulate(const InputRange &range, T init)
T accumulate(const InputRange &range, T init, BinaryOperation binary_op)
ForwardIterator max_adjacent_difference(ForwardIterator first, ForwardIterator last)
T inner_product(const InputRange &range, InputIterator first, T init)
OutputIterator partial_sum(const InputRange &range, OutputIterator result, BinaryOperation binary_op)
OutputIterator adjacent_difference(const InputRange &range, OutputIterator result)
T inner_product(const InputRange &range, InputIterator first, T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2)
OutputIterator adjacent_difference(const InputRange &range, OutputIterator result, BinaryOperation binary_op)
OutputIterator partial_sum(const InputRange &range, OutputIterator result)
|