tmp/tmp66e9c8c3/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Reductions <a id="simd.reductions">[[simd.reductions]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class T, class Abi, class BinaryOperation = plus<>>
|
| 5 |
+
constexpr T reduce(const basic_vec<T, Abi>& x, BinaryOperation binary_op = {});
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
*Constraints:* `BinaryOperation` models `reduction-binary-operation<T>`.
|
| 9 |
+
|
| 10 |
+
*Preconditions:* `binary_op` does not modify `x`.
|
| 11 |
+
|
| 12 |
+
*Returns:* *GENERALIZED_SUM*(binary_op, vec\<T, 1\>(x\[0\]), …, vec\<T,
|
| 13 |
+
1\>(x\[x.size() - 1\]))\[0\] [[numerics.defns]].
|
| 14 |
+
|
| 15 |
+
*Throws:* Any exception thrown from `binary_op`.
|
| 16 |
+
|
| 17 |
+
``` cpp
|
| 18 |
+
template<class T, class Abi, class BinaryOperation = plus<>>
|
| 19 |
+
constexpr T reduce(
|
| 20 |
+
const basic_vec<T, Abi>& x, const typename basic_vec<T, Abi>::mask_type& mask,
|
| 21 |
+
BinaryOperation binary_op = {}, type_identity_t<T> identity_element = see below);
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
*Constraints:*
|
| 25 |
+
|
| 26 |
+
- `BinaryOperation` models `reduction-binary-operation<T>`.
|
| 27 |
+
- An argument for `identity_element` is provided for the invocation,
|
| 28 |
+
unless `BinaryOperation` is one of `plus<>`, `multiplies<>`,
|
| 29 |
+
`bit_and<>`, `bit_or<>`, or `bit_xor<>`.
|
| 30 |
+
|
| 31 |
+
*Preconditions:*
|
| 32 |
+
|
| 33 |
+
- `binary_op` does not modify `x`.
|
| 34 |
+
- For all finite values `y` representable by `T`, the results of
|
| 35 |
+
`y == binary_op(vec<T, 1>(identity_element), vec<T, 1>(y))[0]` and
|
| 36 |
+
`y == binary_op(vec<T, 1>(y), vec<T, 1>(identity_element))[0]` are
|
| 37 |
+
`true`.
|
| 38 |
+
|
| 39 |
+
*Returns:* If `none_of(mask)` is `true`, returns `identity_element`.
|
| 40 |
+
Otherwise, returns *GENERALIZED_SUM*(binary_op, vec\<T, 1\>(x\[k₀\]), …,
|
| 41 |
+
vec\<T, 1\>(x\[kₙ\]))\[0\] where k₀, …, kₙ are the selected indices of
|
| 42 |
+
`mask`.
|
| 43 |
+
|
| 44 |
+
*Throws:* Any exception thrown from `binary_op`.
|
| 45 |
+
|
| 46 |
+
*Remarks:* The default argument for `identity_element` is equal to
|
| 47 |
+
|
| 48 |
+
- `T()` if `BinaryOperation` is `plus<>`,
|
| 49 |
+
- `T(1)` if `BinaryOperation` is `multiplies<>`,
|
| 50 |
+
- `T(~T())` if `BinaryOperation` is `bit_and<>`,
|
| 51 |
+
- `T()` if `BinaryOperation` is `bit_or<>`, or
|
| 52 |
+
- `T()` if `BinaryOperation` is `bit_xor<>`.
|
| 53 |
+
|
| 54 |
+
``` cpp
|
| 55 |
+
template<class T, class Abi> constexpr T reduce_min(const basic_vec<T, Abi>& x) noexcept;
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
*Constraints:* `T` models `totally_ordered`.
|
| 59 |
+
|
| 60 |
+
*Returns:* The value of an element `x[`j`]` for which `x[`i`] < x[`j`]`
|
| 61 |
+
is `false` for all i in the range of \[`0`,
|
| 62 |
+
`basic_vec<T, Abi>::size()`).
|
| 63 |
+
|
| 64 |
+
``` cpp
|
| 65 |
+
template<class T, class Abi>
|
| 66 |
+
constexpr T reduce_min(
|
| 67 |
+
const basic_vec<T, Abi>&, const typename basic_vec<T, Abi>::mask_type&) noexcept;
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
*Constraints:* `T` models `totally_ordered`.
|
| 71 |
+
|
| 72 |
+
*Returns:* If `none_of(mask)` is `true`, returns
|
| 73 |
+
`numeric_limits<T>::max()`. Otherwise, returns the value of a selected
|
| 74 |
+
element `x[`j`]` for which `x[`i`] < x[`j`]` is `false` for all selected
|
| 75 |
+
indices i of `mask`.
|
| 76 |
+
|
| 77 |
+
``` cpp
|
| 78 |
+
template<class T, class Abi> constexpr T reduce_max(const basic_vec<T, Abi>& x) noexcept;
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
*Constraints:* `T` models `totally_ordered`.
|
| 82 |
+
|
| 83 |
+
*Returns:* The value of an element `x[`j`]` for which `x[`j`] < x[`i`]`
|
| 84 |
+
is `false` for all i in the range of \[`0`,
|
| 85 |
+
`basic_vec<T, Abi>::size()`).
|
| 86 |
+
|
| 87 |
+
``` cpp
|
| 88 |
+
template<class T, class Abi>
|
| 89 |
+
constexpr T reduce_max(
|
| 90 |
+
const basic_vec<T, Abi>&, const typename basic_vec<T, Abi>::mask_type&) noexcept;
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
*Constraints:* `T` models `totally_ordered`.
|
| 94 |
+
|
| 95 |
+
*Returns:* If `none_of(mask)` is `true`, returns
|
| 96 |
+
`numeric_limits<V::value_type>::lowest()`. Otherwise, returns the value
|
| 97 |
+
of a selected element `x[`j`]` for which `x[`j`] < x[`i`]` is `false`
|
| 98 |
+
for all selected indices i of `mask`.
|
| 99 |
+
|