6.6 KiB
[simd.reductions]
29 Numerics library [numerics]
29.10 Data-parallel types [simd]
29.10.8 basic_vec non-member operations [simd.nonmembers]
29.10.8.5 basic_vec reductions [simd.reductions]
template<class T, class Abi, class BinaryOperation = plus<>> constexpr T reduce(const basic_vec<T, Abi>& x, BinaryOperation binary_op = {});
Constraints: BinaryOperation modelsreduction-binary-operation.
Preconditions: binary_op does not modify x.
Returns: GENERALIZED_SUM(binary_op, vec<T, 1>(x[0]), …, vec<T, 1>(x[x.size() - 1]))[0] ([numerics.defns]).
Throws: Any exception thrown from binary_op.
template<class T, class Abi, class BinaryOperation = plus<>> constexpr T reduce( const basic_vec<T, Abi>& x, const typename basic_vec<T, Abi>::mask_type& mask, BinaryOperation binary_op = {}, type_identity_t<T> identity_element = see below);
Constraints:
-
BinaryOperation models reduction-binary-operation.
-
An argument for identity_element is provided for the invocation, unless BinaryOperation is one of plus<>, multiplies<>, bit_and<>, bit_or<>, or bit_xor<>.
Preconditions:
-
binary_op does not modify x.
-
For all finite values y representable by T, the results of y == binary_op(vec<T, 1>(identity_element), vec<T, 1>(y))[0] and y == binary_op(vec<T, 1>(y), vec<T, 1>(identity_element))[0] are true.
Returns: If none_of(mask) is true, returns identity_element.
Otherwise, returns GENERALIZED_SUM(binary_op, vec<T,1>(x[k0]), …, vec<T, 1>(x[kn]))[0] where k0,â¦,kn are the selected indices of mask.
Throws: Any exception thrown from binary_op.
Remarks: The default argument for identity_element is equal to
T() if BinaryOperation is plus<>,
T(1) if BinaryOperation is multiplies<>,
T(~T()) if BinaryOperation is bit_and<>,
T() if BinaryOperation is bit_or<>, or
T() if BinaryOperation is bit_xor<>.
template<class T, class Abi> constexpr T reduce_min(const basic_vec<T, Abi>& x) noexcept;
Constraints: T models totally_ordered.
Returns: The value of an element x[j] for which x[i] < x[j] isfalse for all i in the range of [0, basic_vec<T, Abi>::size()).
template<class T, class Abi> constexpr T reduce_min( const basic_vec<T, Abi>&, const typename basic_vec<T, Abi>::mask_type&) noexcept;
Constraints: T models totally_ordered.
Returns: If none_of(mask) is true, returnsnumeric_limits::max().
Otherwise, returns the value of a selected element x[j] for whichx[i] < x[j] is false for all selected indices i ofmask.
template<class T, class Abi> constexpr T reduce_max(const basic_vec<T, Abi>& x) noexcept;
Constraints: T models totally_ordered.
Returns: The value of an element x[j] for which x[j] < x[i] isfalse for all i in the range of [0, basic_vec<T, Abi>::size()).
template<class T, class Abi> constexpr T reduce_max( const basic_vec<T, Abi>&, const typename basic_vec<T, Abi>::mask_type&) noexcept;
Constraints: T models totally_ordered.
Returns: If none_of(mask) is true, returnsnumeric_limits<V::value_type>::lowest().
Otherwise, returns the value of a selected element x[j] for whichx[j] < x[i] is false for all selected indices i ofmask.