|
◆ transform_reduce_index()
template<typename IndexType , typename ExecutionPolicy , typename T , typename BinaryFunction , typename UnaryFunction , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
T stdgpu::transform_reduce_index |
( |
ExecutionPolicy && |
policy, |
|
|
IndexType |
size, |
|
|
T |
init, |
|
|
BinaryFunction |
reduce, |
|
|
UnaryFunction |
f |
|
) |
| |
Calls the given unary function with an index from the range [0, size) and performs a reduction afterwards.
- Template Parameters
-
IndexType | The type of the index values |
ExecutionPolicy | The type of the execution policy |
T | The type of the reduced value |
BinaryFunction | The type of the binary function for the reduction |
UnaryFunction | The type of the unary function applied before reduction |
- Parameters
-
[in] | policy | The execution policy, e.g. host or device |
[in] | size | The number of indices, i.e. the upper bound of [0, size) |
[in] | init | The initial value which also participates in the reduction |
[in] | reduce | The binary function to reduce the values f(i) |
[in] | f | The unary function to call with an index i |
- Returns
- The result of the reduction of f(i) over the index range [0, size) along with the initial value
|