You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
7.7KB

  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. #ifndef _PSTL_NUMERIC_FWD_H
  10. #define _PSTL_NUMERIC_FWD_H
  11. #include <type_traits>
  12. #include <utility>
  13. namespace __pstl
  14. {
  15. namespace __internal
  16. {
  17. //------------------------------------------------------------------------
  18. // transform_reduce (version with two binary functions, according to draft N4659)
  19. //------------------------------------------------------------------------
  20. template <class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
  21. _Tp __brick_transform_reduce(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, _BinaryOperation1,
  22. _BinaryOperation2,
  23. /*__is_vector=*/std::true_type) noexcept;
  24. template <class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
  25. _Tp __brick_transform_reduce(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp, _BinaryOperation1,
  26. _BinaryOperation2,
  27. /*__is_vector=*/std::false_type) noexcept;
  28. template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp, class _BinaryOperation1,
  29. class _BinaryOperation2, class _IsVector>
  30. _Tp
  31. __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp,
  32. _BinaryOperation1, _BinaryOperation2, _IsVector,
  33. /*is_parallel=*/std::false_type) noexcept;
  34. template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Tp,
  35. class _BinaryOperation1, class _BinaryOperation2, class _IsVector>
  36. _Tp
  37. __pattern_transform_reduce(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
  38. _Tp, _BinaryOperation1, _BinaryOperation2, _IsVector __is_vector,
  39. /*is_parallel=*/std::true_type);
  40. //------------------------------------------------------------------------
  41. // transform_reduce (version with unary and binary functions)
  42. //------------------------------------------------------------------------
  43. template <class _ForwardIterator, class _Tp, class _UnaryOperation, class _BinaryOperation>
  44. _Tp __brick_transform_reduce(_ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, _UnaryOperation,
  45. /*is_vector=*/std::true_type) noexcept;
  46. template <class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
  47. _Tp __brick_transform_reduce(_ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation, _UnaryOperation,
  48. /*is_vector=*/std::false_type) noexcept;
  49. template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation,
  50. class _IsVector>
  51. _Tp
  52. __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation,
  53. _UnaryOperation, _IsVector,
  54. /*is_parallel=*/std::false_type) noexcept;
  55. template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation,
  56. class _IsVector>
  57. _Tp
  58. __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation,
  59. _UnaryOperation, _IsVector,
  60. /*is_parallel=*/std::true_type);
  61. //------------------------------------------------------------------------
  62. // transform_exclusive_scan
  63. //
  64. // walk3 evaluates f(x,y,z) for (x,y,z) drawn from [first1,last1), [first2,...), [first3,...)
  65. //------------------------------------------------------------------------
  66. template <class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation>
  67. std::pair<_OutputIterator, _Tp> __brick_transform_scan(_ForwardIterator, _ForwardIterator, _OutputIterator,
  68. _UnaryOperation, _Tp, _BinaryOperation,
  69. /*Inclusive*/ std::false_type) noexcept;
  70. template <class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp, class _BinaryOperation>
  71. std::pair<_OutputIterator, _Tp> __brick_transform_scan(_ForwardIterator, _ForwardIterator, _OutputIterator,
  72. _UnaryOperation, _Tp, _BinaryOperation,
  73. /*Inclusive*/ std::true_type) noexcept;
  74. template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
  75. class _BinaryOperation, class _Inclusive, class _IsVector>
  76. _OutputIterator
  77. __pattern_transform_scan(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _UnaryOperation, _Tp,
  78. _BinaryOperation, _Inclusive, _IsVector,
  79. /*is_parallel=*/std::false_type) noexcept;
  80. template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
  81. class _BinaryOperation, class _Inclusive, class _IsVector>
  82. typename std::enable_if<!std::is_floating_point<_Tp>::value, _OutputIterator>::type
  83. __pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator,
  84. _UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type);
  85. template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
  86. class _BinaryOperation, class _Inclusive, class _IsVector>
  87. typename std::enable_if<std::is_floating_point<_Tp>::value, _OutputIterator>::type
  88. __pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator,
  89. _UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type);
  90. //------------------------------------------------------------------------
  91. // adjacent_difference
  92. //------------------------------------------------------------------------
  93. template <class _ForwardIterator, class _OutputIterator, class _BinaryOperation>
  94. _OutputIterator __brick_adjacent_difference(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
  95. /*is_vector*/ std::false_type) noexcept;
  96. template <class _ForwardIterator, class _OutputIterator, class _BinaryOperation>
  97. _OutputIterator __brick_adjacent_difference(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
  98. /*is_vector*/ std::true_type) noexcept;
  99. template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation,
  100. class _IsVector>
  101. _OutputIterator
  102. __pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
  103. _IsVector, /*is_parallel*/ std::false_type) noexcept;
  104. template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation,
  105. class _IsVector>
  106. _OutputIterator
  107. __pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
  108. _IsVector, /*is_parallel*/ std::true_type);
  109. } // namespace __internal
  110. } // namespace __pstl
  111. #endif /* _PSTL_NUMERIC_FWD_H */