| 1 |
// Copyright (C) 2006 Fokko Beekhof |
| 2 |
// Email contact: [email protected] |
| 3 |
|
| 4 |
// The OMPTL library is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU Lesser General Public |
| 6 |
// License as published by the Free Software Foundation; either |
| 7 |
// version 2.1 of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
// Lesser General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU Lesser General Public |
| 15 |
// License along with this library; if not, write to the Free Software |
| 16 |
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 |
|
| 18 |
#ifndef OMPTL_NUMERIC |
| 19 |
#define OMPTL_NUMERIC 1 |
| 20 |
|
| 21 |
#include <numeric> |
| 22 |
#include "omptl" |
| 23 |
|
| 24 |
namespace omptl |
| 25 |
{ |
| 26 |
|
| 27 |
template <class InputIterator, class T> |
| 28 |
T accumulate(InputIterator first, InputIterator last, T init, |
| 29 |
const unsigned P = _Pfunc::Pfunc()); |
| 30 |
|
| 31 |
template <class InputIterator, class T, class BinaryFunction> |
| 32 |
T accumulate(InputIterator first, InputIterator last, T init, |
| 33 |
BinaryFunction binary_op, |
| 34 |
const unsigned P = _Pfunc::Pfunc()); |
| 35 |
|
| 36 |
/* |
| 37 |
* Not (yet) paralellized due to data dependance. |
| 38 |
*/ |
| 39 |
template <class InputIterator, class OutputIterator, class BinaryFunction> |
| 40 |
OutputIterator |
| 41 |
adjacent_difference(InputIterator first, InputIterator last, |
| 42 |
OutputIterator result, BinaryFunction binary_op, |
| 43 |
const unsigned P = _Pfunc::Pfunc()); |
| 44 |
|
| 45 |
template <class InputIterator, class OutputIterator> |
| 46 |
OutputIterator adjacent_difference(InputIterator first, InputIterator last, |
| 47 |
OutputIterator result, |
| 48 |
const unsigned P = _Pfunc::Pfunc()); |
| 49 |
|
| 50 |
template <class InputIterator1, class InputIterator2, class T, |
| 51 |
class BinaryFunction1, class BinaryFunction2> |
| 52 |
T inner_product(InputIterator1 first1, InputIterator1 last1, |
| 53 |
InputIterator2 first2, T init, |
| 54 |
BinaryFunction1 binary_op1, BinaryFunction2 binary_op2, |
| 55 |
const unsigned P = _Pfunc::Pfunc()); |
| 56 |
|
| 57 |
template <class InputIterator1, class InputIterator2, class T> |
| 58 |
T inner_product(InputIterator1 first1, InputIterator1 last1, |
| 59 |
InputIterator2 first2, T init, |
| 60 |
const unsigned P = _Pfunc::Pfunc()); |
| 61 |
|
| 62 |
// Not paralellized due to dependencies and complications with OutputIterators. |
| 63 |
template <class InputIterator, class OutputIterator, |
| 64 |
class BinaryOperation> |
| 65 |
OutputIterator partial_sum(InputIterator first, InputIterator last, |
| 66 |
OutputIterator result, BinaryOperation binary_op, |
| 67 |
const unsigned P = _Pfunc::Pfunc()); |
| 68 |
|
| 69 |
template <class InputIterator, class OutputIterator> |
| 70 |
OutputIterator partial_sum(InputIterator first, InputIterator last, |
| 71 |
OutputIterator result, const unsigned P = _Pfunc::Pfunc()); |
| 72 |
|
| 73 |
} // namespace omptl |
| 74 |
|
| 75 |
#ifdef _OPENMP |
| 76 |
#include "omptl_numeric_par.h" |
| 77 |
#else |
| 78 |
#include "omptl_numeric_ser.h" |
| 79 |
#endif |
| 80 |
|
| 81 |
#include "omptl_numeric_extentions.h" |
| 82 |
|
| 83 |
#endif /* OMPTL_NUMERIC */ |