![]() |
hpx::parallel::v1::reduce
// In header: <hpx/parallel/detail/reduce.hpp> template<typename ExPolicy, typename InIter> unspecified reduce(ExPolicy && policy, InIter first, InIter last);
Returns GENERALIZED_SUM(+, T(), *first, ..., *(first + (last - first) - 1)).
![]() |
Note |
---|---|
Complexity: O(last - first) applications of the operator+(). |
The reduce operations in the parallel reduce algorithm invoked with an execution policy object of type sequential_execution_policy
execute in sequential order in the calling thread.
The reduce operations in the parallel copy_if algorithm invoked with an execution policy object of type parallel_execution_policy
or task_execution_policy
are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
![]() |
Note |
---|---|
The type of the initial value (and the result type) T is determined from the value_type of the used InIter. GENERALIZED_SUM(+, a1, ..., aN) is defined as follows:
|
The difference between reduce and accumulate is that the behavior of reduce may be non-deterministic for non-associative or non-commutative binary predicate.
Parameters: |
|
||||||
Template Parameters: |
|
||||||
Returns: |
The reduce algorithm returns a hpx::future<T> if the execution policy is of type task_execution_policy and returns T otherwise (where T is the the value_type of InIter). The reduce algorithm returns the result of the generalized sum (applying operator+()) over the elements given by the input range [first, last). |