1
/*      Copyright (C) 2004 Garrett A. Kajmowicz
 
 
3
        This file is part of the uClibc++ Library.
 
 
5
        This library is free software; you can redistribute it and/or
 
 
6
        modify it under the terms of the GNU Lesser General Public
 
 
7
        License as published by the Free Software Foundation; either
 
 
8
        version 2.1 of the License, or (at your option) any later version.
 
 
10
        This library is distributed in the hope that it will be useful,
 
 
11
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 
12
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
 
13
        Lesser General Public License for more details.
 
 
15
        You should have received a copy of the GNU Lesser General Public
 
 
16
        License along with this library; if not, write to the Free Software
 
 
17
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
20
#include <basic_definitions>
 
 
23
#ifndef __STD_NUMERIC_HEADER
 
 
24
#define __STD_NUMERIC_HEADER 1
 
 
26
#pragma GCC visibility push(default)
 
 
29
        template <class InputIterator, class T> _UCXXEXPORT 
 
 
30
                T accumulate(InputIterator first, InputIterator last, T init)
 
 
39
        template <class InputIterator, class T, class BinaryOperation> _UCXXEXPORT 
 
 
40
                T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op)
 
 
43
                        init = binary_op(init, *first);
 
 
50
        template <class InputIterator1, class InputIterator2, class T> _UCXXEXPORT 
 
 
51
                T inner_product(InputIterator1 first1, InputIterator1 last1,
 
 
52
                        InputIterator2 first2, T init)
 
 
54
                while(first1 != last1){
 
 
55
                        init = init + *first1 * *first2;
 
 
62
        template <class InputIterator1, class InputIterator2, class T,
 
 
63
                class BinaryOperation1, class BinaryOperation2> _UCXXEXPORT 
 
 
64
                T inner_product(InputIterator1 first1, InputIterator1 last1,
 
 
65
                        InputIterator2 first2, T init,
 
 
66
                        BinaryOperation1 binary_op1,
 
 
67
                        BinaryOperation2 binary_op2)
 
 
69
                while(first1 != last1){
 
 
70
                        init = binary_op1(init, binary_op2(*first1, *first2));
 
 
77
        template <class InputIterator, class OutputIterator> _UCXXEXPORT 
 
 
78
                OutputIterator partial_sum(InputIterator first, InputIterator last,
 
 
79
                OutputIterator result)
 
 
81
                OutputIterator temp(result);
 
 
87
                        *result = *first + *temp;
 
 
96
        template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT 
 
 
97
                OutputIterator partial_sum(InputIterator first, InputIterator last,
 
 
98
                OutputIterator result, BinaryOperation binary_op)
 
 
100
                OutputIterator temp(result);
 
 
105
                while(first != last){
 
 
106
                        *result = binary_op(*first, *temp);
 
 
115
        template <class InputIterator, class OutputIterator> _UCXXEXPORT 
 
 
117
                adjacent_difference(InputIterator first, InputIterator last,
 
 
118
                        OutputIterator result)
 
 
120
                OutputIterator temp(first);
 
 
125
                while(first != last){
 
 
126
                        *result = *first - *temp;
 
 
136
        template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT 
 
 
138
                adjacent_difference(InputIterator first, InputIterator last,
 
 
139
                        OutputIterator result, BinaryOperation binary_op)
 
 
141
                OutputIterator temp(first);
 
 
146
                while(first != last){
 
 
147
                        *result = binary_op(*first, *temp);
 
 
158
#pragma GCC visibility pop