template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
T bolt::amp::transform_reduce |
( |
control & |
ctl, |
|
|
InputIterator |
first1, |
|
|
InputIterator |
last1, |
|
|
UnaryFunction |
transform_op, |
|
|
T |
init, |
|
|
BinaryFunction |
reduce_op |
|
) |
| |
transform_reduce
fuses transform and reduce operations together, increasing performance by reducing memory passes.
Logically, a transform operation is performed over the input sequence using the unary function and stored into a temporary sequence; then, a reduction operation is applied using the binary function to return a single value.
- Parameters
-
ctl | Optional Control structure to control accelerator, debug, tuning, etc. See bolt::amp::control. |
first | The beginning of the input sequence. |
last | The end of the input sequence. |
transform_op | A unary tranformation operation. |
init | The initial value for the accumulator. |
reduce_op | The binary operation used to combine two values. By default, the binary operation is plus<>(). |
- Returns
- The result of the combined transform and reduction.
- Template Parameters
-
T | The type of the result. |
InputIterator | is a model of an InputIterator. and InputIterator's value_type is convertible to BinaryFunction's first_argument_type . |
UnaryFunction | is a model of Unary Function. and UnaryFunction's result_type is convertible to InputIterator's value_type . |
BinaryFunction | is a model of Binary Function. and BinaryFunction's result_type is convertible to InputIterator's value_type . |
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int output;
- See Also
- http://www.sgi.com/tech/stl/InputIterator.html
-
http://www.sgi.com/tech/stl/OutputIterator.html
-
http://www.sgi.com/tech/stl/UnaryFunction.html
-
http://www.sgi.com/tech/stl/BinaryFunction.html