Template Function thrust::transform_exclusive_scan(InputIterator, InputIterator, OutputIterator, UnaryFunction, T, AssociativeOperator)¶
Function Documentation¶
-
template<typename
InputIterator, typenameOutputIterator, typenameUnaryFunction, typenameT, typenameAssociativeOperator>
OutputIteratorthrust::transform_exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, UnaryFunction unary_op, T init, AssociativeOperator binary_op) transform_exclusive_scanfuses thetransformandexclusive_scanoperations.transform_exclusive_scanis equivalent to performing a tranformation defined byunary_opinto a temporary sequence and then performing anexclusive_scanon the tranformed sequence. In most cases, fusing these two operations together is more efficient, since fewer memory reads and writes are required. Intransform_exclusive_scan,initis assigned to*resultand the result ofbinary_op(init, unary_op(*first))is assigned to*(result + 1), and so on. The transform scan operation is permitted to be in-place.The following code snippet demonstrates how to use
transform_exclusive_scan- Return
The end of the output sequence.
- Pre
firstmay equalresult, but the range[first, last)and the range[result, result + (last - first))shall not overlap otherwise.- Parameters
first: The beginning of the input sequence.last: The end of the input sequence.result: The beginning of the output sequence.unary_op: The function used to tranform the input sequence.init: The initial value of theexclusive_scanbinary_op: The associatve operator used to ‘sum’ transformed values.
- Template Parameters
InputIterator: is a model of Input Iterator andInputIterator'svalue_typeis convertible tounary_op'sinput type.OutputIterator: is a model of Output Iterator.UnaryFunction: is a model of Unary Function and accepts inputs ofInputIterator'svalue_type.UnaryFunction'sresult_type is convertable toOutputIterator'svalue_type.T: is convertible toOutputIterator'svalue_type.AssociativeOperator: is a model of Binary Function andAssociativeOperator'sresult_typeis convertible toOutputIterator'svalue_type.
#include <thrust/transform_scan.h> int data[6] = {1, 0, 2, 2, 1, 3}; thrust::negate<int> unary_op; thrust::plus<int> binary_op; thrust::transform_exclusive_scan(data, data + 6, data, unary_op, 4, binary_op); // in-place scan // data is now {4, 3, 3, 1, -1, -2}
- See
transform- See
exclusive_scan