| 1 |
// -*- C++ -*- |
| 2 |
//===-- numeric_fwd.h --------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _PSTL_NUMERIC_FWD_H |
| 11 |
#define _PSTL_NUMERIC_FWD_H |
| 12 |
|
| 13 |
#include <type_traits> |
| 14 |
#include <utility> |
| 15 |
|
| 16 |
namespace __pstl |
| 17 |
{ |
| 18 |
namespace __internal |
| 19 |
{ |
| 20 |
|
| 21 |
//------------------------------------------------------------------------ |
| 22 |
// transform_reduce (version with two binary functions, according to draft N4659) |
| 23 |
//------------------------------------------------------------------------ |
| 24 |
|
| 25 |
template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Tp, class _BinaryOperation1, |
| 26 |
class _BinaryOperation2> |
| 27 |
_Tp __brick_transform_reduce(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Tp, |
| 28 |
_BinaryOperation1, _BinaryOperation2, |
| 29 |
/*__is_vector=*/std::true_type) noexcept; |
| 30 |
|
| 31 |
template <class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> |
| 32 |
_Tp __brick_transform_reduce(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, _BinaryOperation1, |
| 33 |
_BinaryOperation2, |
| 34 |
/*__is_vector=*/std::false_type) noexcept; |
| 35 |
|
| 36 |
template <class _Tag, class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp, |
| 37 |
class _BinaryOperation1, class _BinaryOperation2> |
| 38 |
_Tp |
| 39 |
__pattern_transform_reduce(_Tag, _ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, |
| 40 |
_BinaryOperation1, _BinaryOperation2) noexcept; |
| 41 |
|
| 42 |
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, |
| 43 |
class _Tp, class _BinaryOperation1, class _BinaryOperation2> |
| 44 |
_Tp |
| 45 |
__pattern_transform_reduce(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator1, |
| 46 |
_RandomAccessIterator1, _RandomAccessIterator2, _Tp, _BinaryOperation1, _BinaryOperation2); |
| 47 |
|
| 48 |
//------------------------------------------------------------------------ |
| 49 |
// transform_reduce (version with unary and binary functions) |
| 50 |
//------------------------------------------------------------------------ |
| 51 |
|
| 52 |
template <class _RandomAccessIterator, class _Tp, class _UnaryOperation, class _BinaryOperation> |
| 53 |
_Tp __brick_transform_reduce(_RandomAccessIterator, _RandomAccessIterator, _Tp, _BinaryOperation, _UnaryOperation, |
| 54 |
/*is_vector=*/std::true_type) noexcept; |
| 55 |
|
| 56 |
template <class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> |
| 57 |
_Tp __brick_transform_reduce(_ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, _UnaryOperation, |
| 58 |
/*is_vector=*/std::false_type) noexcept; |
| 59 |
|
| 60 |
template <class _Tag, class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, |
| 61 |
class _UnaryOperation> |
| 62 |
_Tp |
| 63 |
__pattern_transform_reduce(_Tag, _ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, |
| 64 |
_UnaryOperation) noexcept; |
| 65 |
|
| 66 |
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _Tp, class _BinaryOperation, |
| 67 |
class _UnaryOperation> |
| 68 |
_Tp |
| 69 |
__pattern_transform_reduce(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, |
| 70 |
_Tp, _BinaryOperation, _UnaryOperation); |
| 71 |
|
| 72 |
//------------------------------------------------------------------------ |
| 73 |
// transform_exclusive_scan |
| 74 |
// |
| 75 |
// walk3 evaluates f(x,y,z) for (x,y,z) drawn from [first1,last1), [first2,...), [first3,...) |
| 76 |
//------------------------------------------------------------------------ |
| 77 |
|
| 78 |
template <class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation> |
| 79 |
std::pair<_OutputIterator, _Tp> __brick_transform_scan(_ForwardIterator, _ForwardIterator, _OutputIterator, |
| 80 |
_UnaryOperation, _Tp, _BinaryOperation, |
| 81 |
/*Inclusive*/ std::false_type) noexcept; |
| 82 |
|
| 83 |
template <class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation> |
| 84 |
std::pair<_OutputIterator, _Tp> __brick_transform_scan(_RandomAccessIterator, _RandomAccessIterator, _OutputIterator, |
| 85 |
_UnaryOperation, _Tp, _BinaryOperation, |
| 86 |
/*Inclusive*/ std::true_type) noexcept; |
| 87 |
|
| 88 |
template <class _Tag, class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _UnaryOperation, |
| 89 |
class _Tp, class _BinaryOperation, class _Inclusive> |
| 90 |
_OutputIterator |
| 91 |
__pattern_transform_scan(_Tag, _ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _UnaryOperation, |
| 92 |
_Tp, _BinaryOperation, _Inclusive) noexcept; |
| 93 |
|
| 94 |
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, |
| 95 |
class _UnaryOperation, class _Tp, class _BinaryOperation, class _Inclusive> |
| 96 |
typename std::enable_if<!std::is_floating_point<_Tp>::value, _OutputIterator>::type |
| 97 |
__pattern_transform_scan(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&&, _RandomAccessIterator, |
| 98 |
_RandomAccessIterator, _OutputIterator, _UnaryOperation, _Tp, _BinaryOperation, _Inclusive); |
| 99 |
|
| 100 |
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, |
| 101 |
class _UnaryOperation, class _Tp, class _BinaryOperation, class _Inclusive> |
| 102 |
typename std::enable_if<std::is_floating_point<_Tp>::value, _OutputIterator>::type |
| 103 |
__pattern_transform_scan(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, |
| 104 |
_OutputIterator, _UnaryOperation, _Tp, _BinaryOperation, _Inclusive); |
| 105 |
|
| 106 |
//------------------------------------------------------------------------ |
| 107 |
// adjacent_difference |
| 108 |
//------------------------------------------------------------------------ |
| 109 |
|
| 110 |
template <class _ForwardIterator, class _OutputIterator, class _BinaryOperation> |
| 111 |
_OutputIterator __brick_adjacent_difference(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation, |
| 112 |
/*is_vector*/ std::false_type) noexcept; |
| 113 |
|
| 114 |
template <class _RandomAccessIterator, class _OutputIterator, class _BinaryOperation> |
| 115 |
_OutputIterator __brick_adjacent_difference(_RandomAccessIterator, _RandomAccessIterator, _OutputIterator, |
| 116 |
_BinaryOperation, |
| 117 |
/*is_vector*/ std::true_type) noexcept; |
| 118 |
|
| 119 |
template <class _Tag, class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation> |
| 120 |
_OutputIterator |
| 121 |
__pattern_adjacent_difference(_Tag, _ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, |
| 122 |
_BinaryOperation) noexcept; |
| 123 |
|
| 124 |
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, |
| 125 |
class _BinaryOperation> |
| 126 |
_OutputIterator |
| 127 |
__pattern_adjacent_difference(_ExecutionPolicy&&, _OutputIterator, _OutputIterator, _OutputIterator, _BinaryOperation, |
| 128 |
_IsVector, /*is_parallel*/ std::true_type); |
| 129 |
|
| 130 |
} // namespace __internal |
| 131 |
} // namespace __pstl |
| 132 |
#endif /* _PSTL_NUMERIC_FWD_H */ |