tmp/tmpfr4z3lk6/{from.md → to.md}
RENAMED
|
@@ -1,51 +1,243 @@
|
|
| 1 |
### Header `<numeric>` synopsis <a id="numeric.ops.overview">[[numeric.ops.overview]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
|
|
|
| 5 |
template <class InputIterator, class T>
|
| 6 |
T accumulate(InputIterator first, InputIterator last, T init);
|
| 7 |
template <class InputIterator, class T, class BinaryOperation>
|
| 8 |
T accumulate(InputIterator first, InputIterator last, T init,
|
| 9 |
BinaryOperation binary_op);
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
template <class InputIterator1, class InputIterator2, class T>
|
| 12 |
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
| 13 |
InputIterator2 first2, T init);
|
| 14 |
template <class InputIterator1, class InputIterator2, class T,
|
| 15 |
class BinaryOperation1, class BinaryOperation2>
|
| 16 |
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
| 17 |
InputIterator2 first2, T init,
|
| 18 |
BinaryOperation1 binary_op1,
|
| 19 |
BinaryOperation2 binary_op2);
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
template <class InputIterator, class OutputIterator>
|
| 22 |
OutputIterator partial_sum(InputIterator first,
|
| 23 |
InputIterator last,
|
| 24 |
OutputIterator result);
|
| 25 |
-
template <class InputIterator, class OutputIterator,
|
| 26 |
-
class BinaryOperation>
|
| 27 |
OutputIterator partial_sum(InputIterator first,
|
| 28 |
InputIterator last,
|
| 29 |
OutputIterator result,
|
| 30 |
BinaryOperation binary_op);
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
template <class InputIterator, class OutputIterator>
|
| 33 |
OutputIterator adjacent_difference(InputIterator first,
|
| 34 |
InputIterator last,
|
| 35 |
OutputIterator result);
|
| 36 |
-
template <class InputIterator, class OutputIterator,
|
| 37 |
-
class BinaryOperation>
|
| 38 |
OutputIterator adjacent_difference(InputIterator first,
|
| 39 |
InputIterator last,
|
| 40 |
OutputIterator result,
|
| 41 |
BinaryOperation binary_op);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
|
|
|
| 43 |
template <class ForwardIterator, class T>
|
| 44 |
void iota(ForwardIterator first, ForwardIterator last, T value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
```
|
| 47 |
|
| 48 |
The requirements on the types of algorithms’ arguments that are
|
| 49 |
described in the introduction to Clause [[algorithms]] also apply to
|
| 50 |
the following algorithms.
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### Header `<numeric>` synopsis <a id="numeric.ops.overview">[[numeric.ops.overview]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
+
// [accumulate], accumulate
|
| 6 |
template <class InputIterator, class T>
|
| 7 |
T accumulate(InputIterator first, InputIterator last, T init);
|
| 8 |
template <class InputIterator, class T, class BinaryOperation>
|
| 9 |
T accumulate(InputIterator first, InputIterator last, T init,
|
| 10 |
BinaryOperation binary_op);
|
| 11 |
|
| 12 |
+
// [reduce], reduce
|
| 13 |
+
template<class InputIterator>
|
| 14 |
+
typename iterator_traits<InputIterator>::value_type
|
| 15 |
+
reduce(InputIterator first, InputIterator last);
|
| 16 |
+
template<class InputIterator, class T>
|
| 17 |
+
T reduce(InputIterator first, InputIterator last, T init);
|
| 18 |
+
template<class InputIterator, class T, class BinaryOperation>
|
| 19 |
+
T reduce(InputIterator first, InputIterator last, T init,
|
| 20 |
+
BinaryOperation binary_op);
|
| 21 |
+
template<class ExecutionPolicy, class ForwardIterator>
|
| 22 |
+
typename iterator_traits<ForwardIterator>::value_type
|
| 23 |
+
reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 24 |
+
ForwardIterator first, ForwardIterator last);
|
| 25 |
+
template<class ExecutionPolicy, class ForwardIterator, class T>
|
| 26 |
+
T reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 27 |
+
ForwardIterator first, ForwardIterator last, T init);
|
| 28 |
+
template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation>
|
| 29 |
+
T reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 30 |
+
ForwardIterator first, ForwardIterator last, T init,
|
| 31 |
+
BinaryOperation binary_op);
|
| 32 |
+
|
| 33 |
+
// [inner.product], inner product
|
| 34 |
template <class InputIterator1, class InputIterator2, class T>
|
| 35 |
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
| 36 |
InputIterator2 first2, T init);
|
| 37 |
template <class InputIterator1, class InputIterator2, class T,
|
| 38 |
class BinaryOperation1, class BinaryOperation2>
|
| 39 |
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
| 40 |
InputIterator2 first2, T init,
|
| 41 |
BinaryOperation1 binary_op1,
|
| 42 |
BinaryOperation2 binary_op2);
|
| 43 |
|
| 44 |
+
// [transform.reduce], transform reduce
|
| 45 |
+
template<class InputIterator1, class InputIterator2, class T>
|
| 46 |
+
T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
| 47 |
+
InputIterator2 first2,
|
| 48 |
+
T init);
|
| 49 |
+
template<class InputIterator1, class InputIterator2, class T,
|
| 50 |
+
class BinaryOperation1, class BinaryOperation2>
|
| 51 |
+
T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
| 52 |
+
InputIterator2 first2,
|
| 53 |
+
T init,
|
| 54 |
+
BinaryOperation1 binary_op1,
|
| 55 |
+
BinaryOperation2 binary_op2);
|
| 56 |
+
template<class InputIterator, class T,
|
| 57 |
+
class BinaryOperation, class UnaryOperation>
|
| 58 |
+
T transform_reduce(InputIterator first, InputIterator last,
|
| 59 |
+
T init,
|
| 60 |
+
BinaryOperation binary_op, UnaryOperation unary_op);
|
| 61 |
+
template<class ExecutionPolicy,
|
| 62 |
+
class ForwardIterator1, class ForwardIterator2, class T>
|
| 63 |
+
T transform_reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 64 |
+
ForwardIterator1 first1, ForwardIterator1 last1,
|
| 65 |
+
ForwardIterator2 first2,
|
| 66 |
+
T init);
|
| 67 |
+
template<class ExecutionPolicy,
|
| 68 |
+
class ForwardIterator1, class ForwardIterator2, class T,
|
| 69 |
+
class BinaryOperation1, class BinaryOperation2>
|
| 70 |
+
T transform_reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 71 |
+
ForwardIterator1 first1, ForwardIterator1 last1,
|
| 72 |
+
ForwardIterator2 first2,
|
| 73 |
+
T init,
|
| 74 |
+
BinaryOperation1 binary_op1,
|
| 75 |
+
BinaryOperation2 binary_op2);
|
| 76 |
+
template<class ExecutionPolicy,
|
| 77 |
+
class ForwardIterator, class T,
|
| 78 |
+
class BinaryOperation, class UnaryOperation>
|
| 79 |
+
T transform_reduce(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 80 |
+
ForwardIterator first, ForwardIterator last,
|
| 81 |
+
T init,
|
| 82 |
+
BinaryOperation binary_op, UnaryOperation unary_op);
|
| 83 |
+
|
| 84 |
+
// [partial.sum], partial sum
|
| 85 |
template <class InputIterator, class OutputIterator>
|
| 86 |
OutputIterator partial_sum(InputIterator first,
|
| 87 |
InputIterator last,
|
| 88 |
OutputIterator result);
|
| 89 |
+
template <class InputIterator, class OutputIterator, class BinaryOperation>
|
|
|
|
| 90 |
OutputIterator partial_sum(InputIterator first,
|
| 91 |
InputIterator last,
|
| 92 |
OutputIterator result,
|
| 93 |
BinaryOperation binary_op);
|
| 94 |
|
| 95 |
+
// [exclusive.scan], exclusive scan
|
| 96 |
+
template<class InputIterator, class OutputIterator, class T>
|
| 97 |
+
OutputIterator exclusive_scan(InputIterator first, InputIterator last,
|
| 98 |
+
OutputIterator result,
|
| 99 |
+
T init);
|
| 100 |
+
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
|
| 101 |
+
OutputIterator exclusive_scan(InputIterator first, InputIterator last,
|
| 102 |
+
OutputIterator result,
|
| 103 |
+
T init, BinaryOperation binary_op);
|
| 104 |
+
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T>
|
| 105 |
+
ForwardIterator2 exclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 106 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 107 |
+
ForwardIterator2 result,
|
| 108 |
+
T init);
|
| 109 |
+
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T,
|
| 110 |
+
class BinaryOperation>
|
| 111 |
+
ForwardIterator2 exclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 112 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 113 |
+
ForwardIterator2 result,
|
| 114 |
+
T init, BinaryOperation binary_op);
|
| 115 |
+
|
| 116 |
+
// [inclusive.scan], inclusive scan
|
| 117 |
+
template<class InputIterator, class OutputIterator>
|
| 118 |
+
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
|
| 119 |
+
OutputIterator result);
|
| 120 |
+
template<class InputIterator, class OutputIterator, class BinaryOperation>
|
| 121 |
+
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
|
| 122 |
+
OutputIterator result,
|
| 123 |
+
BinaryOperation binary_op);
|
| 124 |
+
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
|
| 125 |
+
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
|
| 126 |
+
OutputIterator result,
|
| 127 |
+
BinaryOperation binary_op, T init);
|
| 128 |
+
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 129 |
+
ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 130 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 131 |
+
ForwardIterator2 result);
|
| 132 |
+
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
| 133 |
+
class BinaryOperation>
|
| 134 |
+
ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 135 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 136 |
+
ForwardIterator2 result,
|
| 137 |
+
BinaryOperation binary_op);
|
| 138 |
+
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
| 139 |
+
class BinaryOperation, class T>
|
| 140 |
+
ForwardIterator2 inclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 141 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 142 |
+
ForwardIterator2 result,
|
| 143 |
+
BinaryOperation binary_op, T init);
|
| 144 |
+
|
| 145 |
+
// [transform.exclusive.scan], transform exclusive scan
|
| 146 |
+
template<class InputIterator, class OutputIterator, class T,
|
| 147 |
+
class BinaryOperation, class UnaryOperation>
|
| 148 |
+
OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
|
| 149 |
+
OutputIterator result,
|
| 150 |
+
T init,
|
| 151 |
+
BinaryOperation binary_op,
|
| 152 |
+
UnaryOperation unary_op);
|
| 153 |
+
template<class ExecutionPolicy,
|
| 154 |
+
class ForwardIterator1, class ForwardIterator2, class T,
|
| 155 |
+
class BinaryOperation, class UnaryOperation>
|
| 156 |
+
ForwardIterator2 transform_exclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 157 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 158 |
+
ForwardIterator2 result,
|
| 159 |
+
T init,
|
| 160 |
+
BinaryOperation binary_op,
|
| 161 |
+
UnaryOperation unary_op);
|
| 162 |
+
|
| 163 |
+
// [transform.inclusive.scan], transform inclusive scan
|
| 164 |
+
template<class InputIterator, class OutputIterator,
|
| 165 |
+
class BinaryOperation, class UnaryOperation>
|
| 166 |
+
OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
|
| 167 |
+
OutputIterator result,
|
| 168 |
+
BinaryOperation binary_op,
|
| 169 |
+
UnaryOperation unary_op);
|
| 170 |
+
template<class InputIterator, class OutputIterator,
|
| 171 |
+
class BinaryOperation, class UnaryOperation, class T>
|
| 172 |
+
OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
|
| 173 |
+
OutputIterator result,
|
| 174 |
+
BinaryOperation binary_op,
|
| 175 |
+
UnaryOperation unary_op,
|
| 176 |
+
T init);
|
| 177 |
+
template<class ExecutionPolicy,
|
| 178 |
+
class ForwardIterator1, class ForwardIterator2,
|
| 179 |
+
class BinaryOperation, class UnaryOperation>
|
| 180 |
+
ForwardIterator2 transform_inclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 181 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 182 |
+
ForwardIterator2 result,
|
| 183 |
+
BinaryOperation binary_op,
|
| 184 |
+
UnaryOperation unary_op);
|
| 185 |
+
template<class ExecutionPolicy,
|
| 186 |
+
class ForwardIterator1, class ForwardIterator2,
|
| 187 |
+
class BinaryOperation, class UnaryOperation, class T>
|
| 188 |
+
ForwardIterator2 transform_inclusive_scan(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 189 |
+
ForwardIterator1 first, ForwardIterator1 last,
|
| 190 |
+
ForwardIterator2 result,
|
| 191 |
+
BinaryOperation binary_op,
|
| 192 |
+
UnaryOperation unary_op,
|
| 193 |
+
T init);
|
| 194 |
+
|
| 195 |
+
// [adjacent.difference], adjacent difference
|
| 196 |
template <class InputIterator, class OutputIterator>
|
| 197 |
OutputIterator adjacent_difference(InputIterator first,
|
| 198 |
InputIterator last,
|
| 199 |
OutputIterator result);
|
| 200 |
+
template <class InputIterator, class OutputIterator, class BinaryOperation>
|
|
|
|
| 201 |
OutputIterator adjacent_difference(InputIterator first,
|
| 202 |
InputIterator last,
|
| 203 |
OutputIterator result,
|
| 204 |
BinaryOperation binary_op);
|
| 205 |
+
template <class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
| 206 |
+
ForwardIterator2 adjacent_difference(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 207 |
+
ForwardIterator1 first,
|
| 208 |
+
ForwardIterator1 last,
|
| 209 |
+
ForwardIterator2 result);
|
| 210 |
+
template <class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
| 211 |
+
class BinaryOperation>
|
| 212 |
+
ForwardIterator2 adjacent_difference(ExecutionPolicy&& exec, // see [algorithms.parallel.overloads]
|
| 213 |
+
ForwardIterator1 first,
|
| 214 |
+
ForwardIterator1 last,
|
| 215 |
+
ForwardIterator2 result,
|
| 216 |
+
BinaryOperation binary_op);
|
| 217 |
|
| 218 |
+
// [numeric.iota], iota
|
| 219 |
template <class ForwardIterator, class T>
|
| 220 |
void iota(ForwardIterator first, ForwardIterator last, T value);
|
| 221 |
+
|
| 222 |
+
// [numeric.ops.gcd], greatest common divisor
|
| 223 |
+
template <class M, class N>
|
| 224 |
+
constexpr common_type_t<M,N> gcd(M m, N n);
|
| 225 |
+
|
| 226 |
+
// [numeric.ops.lcm], least common multiple
|
| 227 |
+
template <class M, class N>
|
| 228 |
+
constexpr common_type_t<M,N> lcm(M m, N n);
|
| 229 |
}
|
| 230 |
```
|
| 231 |
|
| 232 |
The requirements on the types of algorithms’ arguments that are
|
| 233 |
described in the introduction to Clause [[algorithms]] also apply to
|
| 234 |
the following algorithms.
|
| 235 |
|
| 236 |
+
Throughout this subclause, the parameters `UnaryOperation`,
|
| 237 |
+
`BinaryOperation`, `BinaryOperation1`, and `BinaryOperation2` are used
|
| 238 |
+
whenever an algorithm expects a function object ([[function.objects]]).
|
| 239 |
+
|
| 240 |
+
[*Note 1*: The use of closed ranges as well as semi-open ranges to
|
| 241 |
+
specify requirements throughout this subclause is
|
| 242 |
+
intentional. — *end note*]
|
| 243 |
+
|