Bolt  1.1
C++ template library with support for OpenCL
Functions
Amp-transform_reduce

Functions

template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
bolt::amp::transform_reduce (InputIterator first, InputIterator last, UnaryFunction transform_op, T init, BinaryFunction reduce_op)
 transform_reduce fuses transform and reduce operations together, increasing performance by reducing memory passes.
 
template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
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.
 

Detailed Description

Function Documentation

template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
T bolt::amp::transform_reduce ( InputIterator  first,
InputIterator  last,
UnaryFunction  transform_op,
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
firstThe beginning of the input sequence.
lastThe end of the input sequence.
transform_opA unary tranformation operation.
initThe initial value for the accumulator.
reduce_opThe 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
TThe type of the result.
InputIteratoris a model of an InputIterator. and InputIterator's value_type is convertible to BinaryFunction's first_argument_type.
UnaryFunctionis a model of Unary Function. and UnaryFunction's result_type is convertible to InputIterator's value_type.
BinaryFunctionis 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;
// output is 76
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
template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
T bolt::amp::transform_reduce ( control &  ctl,
InputIterator  first1,
InputIterator  last1,
UnaryFunction  transform_op,
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
ctlOptional Control structure to control accelerator, debug, tuning, etc. See bolt::amp::control.
firstThe beginning of the input sequence.
lastThe end of the input sequence.
transform_opA unary tranformation operation.
initThe initial value for the accumulator.
reduce_opThe 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
TThe type of the result.
InputIteratoris a model of an InputIterator. and InputIterator's value_type is convertible to BinaryFunction's first_argument_type.
UnaryFunctionis a model of Unary Function. and UnaryFunction's result_type is convertible to InputIterator's value_type.
BinaryFunctionis 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;
// output is 76
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