| 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 _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> |
| 26 |
_Tp __brick_transform_reduce(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, _BinaryOperation1, |
| 27 |
_BinaryOperation2, |
| 28 |
/*__is_vector=*/std::true_type) noexcept; |
| 29 |
|
| 30 |
template <class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> |
| 31 |
_Tp __brick_transform_reduce(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, _BinaryOperation1, |
| 32 |
_BinaryOperation2, |
| 33 |
/*__is_vector=*/std::false_type) noexcept; |
| 34 |
|
| 35 |
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, |
| 36 |
class _BinaryOperation2, class _IsVector> |
| 37 |
_Tp |
| 38 |
__pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, |
| 39 |
_BinaryOperation1, _BinaryOperation2, _IsVector, |
| 40 |
/*is_parallel=*/std::false_type) noexcept; |
| 41 |
|
| 42 |
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Tp, |
| 43 |
class _BinaryOperation1, class _BinaryOperation2, class _IsVector> |
| 44 |
_Tp |
| 45 |
__pattern_transform_reduce(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, |
| 46 |
_Tp, _BinaryOperation1, _BinaryOperation2, _IsVector __is_vector, |
| 47 |
/*is_parallel=*/std::true_type); |
| 48 |
|
| 49 |
//------------------------------------------------------------------------ |
| 50 |
// transform_reduce (version with unary and binary functions) |
| 51 |
//------------------------------------------------------------------------ |
| 52 |
|
| 53 |
template <class _ForwardIterator, class _Tp, class _UnaryOperation, class _BinaryOperation> |
| 54 |
_Tp __brick_transform_reduce(_ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, _UnaryOperation, |
| 55 |
/*is_vector=*/std::true_type) noexcept; |
| 56 |
|
| 57 |
template <class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> |
| 58 |
_Tp __brick_transform_reduce(_ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, _UnaryOperation, |
| 59 |
/*is_vector=*/std::false_type) noexcept; |
| 60 |
|
| 61 |
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation, |
| 62 |
class _IsVector> |
| 63 |
_Tp |
| 64 |
__pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, |
| 65 |
_UnaryOperation, _IsVector, |
| 66 |
/*is_parallel=*/std::false_type) noexcept; |
| 67 |
|
| 68 |
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation, |
| 69 |
class _IsVector> |
| 70 |
_Tp |
| 71 |
__pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, |
| 72 |
_UnaryOperation, _IsVector, |
| 73 |
/*is_parallel=*/std::true_type); |
| 74 |
|
| 75 |
//------------------------------------------------------------------------ |
| 76 |
// transform_exclusive_scan |
| 77 |
// |
| 78 |
// walk3 evaluates f(x,y,z) for (x,y,z) drawn from [first1,last1), [first2,...), [first3,...) |
| 79 |
//------------------------------------------------------------------------ |
| 80 |
|
| 81 |
template <class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation> |
| 82 |
std::pair<_OutputIterator, _Tp> __brick_transform_scan(_ForwardIterator, _ForwardIterator, _OutputIterator, |
| 83 |
_UnaryOperation, _Tp, _BinaryOperation, |
| 84 |
/*Inclusive*/ std::false_type) noexcept; |
| 85 |
|
| 86 |
template <class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation> |
| 87 |
std::pair<_OutputIterator, _Tp> __brick_transform_scan(_ForwardIterator, _ForwardIterator, _OutputIterator, |
| 88 |
_UnaryOperation, _Tp, _BinaryOperation, |
| 89 |
/*Inclusive*/ std::true_type) noexcept; |
| 90 |
|
| 91 |
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, |
| 92 |
class _BinaryOperation, class _Inclusive, class _IsVector> |
| 93 |
_OutputIterator |
| 94 |
__pattern_transform_scan(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _UnaryOperation, _Tp, |
| 95 |
_BinaryOperation, _Inclusive, _IsVector, |
| 96 |
/*is_parallel=*/std::false_type) noexcept; |
| 97 |
|
| 98 |
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp, |
| 99 |
class _BinaryOperation, class _Inclusive, class _IsVector> |
| 100 |
typename std::enable_if<!std::is_floating_point<_Tp>::value, _OutputIterator>::type |
| 101 |
__pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator, |
| 102 |
_UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type); |
| 103 |
|
| 104 |
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp, |
| 105 |
class _BinaryOperation, class _Inclusive, class _IsVector> |
| 106 |
typename std::enable_if<std::is_floating_point<_Tp>::value, _OutputIterator>::type |
| 107 |
__pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator, |
| 108 |
_UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type); |
| 109 |
|
| 110 |
//------------------------------------------------------------------------ |
| 111 |
// adjacent_difference |
| 112 |
//------------------------------------------------------------------------ |
| 113 |
|
| 114 |
template <class _ForwardIterator, class _OutputIterator, class _BinaryOperation> |
| 115 |
_OutputIterator __brick_adjacent_difference(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation, |
| 116 |
/*is_vector*/ std::false_type) noexcept; |
| 117 |
|
| 118 |
template <class _ForwardIterator, class _OutputIterator, class _BinaryOperation> |
| 119 |
_OutputIterator __brick_adjacent_difference(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation, |
| 120 |
/*is_vector*/ std::true_type) noexcept; |
| 121 |
|
| 122 |
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation, |
| 123 |
class _IsVector> |
| 124 |
_OutputIterator |
| 125 |
__pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation, |
| 126 |
_IsVector, /*is_parallel*/ std::false_type) noexcept; |
| 127 |
|
| 128 |
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation, |
| 129 |
class _IsVector> |
| 130 |
_OutputIterator |
| 131 |
__pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation, |
| 132 |
_IsVector, /*is_parallel*/ std::true_type); |
| 133 |
|
| 134 |
} // namespace __internal |
| 135 |
} // namespace __pstl |
| 136 |
#endif /* _PSTL_NUMERIC_FWD_H */ |