thrust
Functions
Transformed Prefix Sums

Functions

template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename UnaryFunction , typename AssociativeOperator >
__host__ __device__ OutputIterator thrust::transform_inclusive_scan (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, OutputIterator result, UnaryFunction unary_op, AssociativeOperator binary_op)
 
template<typename InputIterator , typename OutputIterator , typename UnaryFunction , typename AssociativeOperator >
OutputIterator thrust::transform_inclusive_scan (InputIterator first, InputIterator last, OutputIterator result, UnaryFunction unary_op, AssociativeOperator binary_op)
 
template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename UnaryFunction , typename T , typename AssociativeOperator >
__host__ __device__ OutputIterator thrust::transform_exclusive_scan (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, OutputIterator result, UnaryFunction unary_op, T init, AssociativeOperator binary_op)
 
template<typename InputIterator , typename OutputIterator , typename UnaryFunction , typename T , typename AssociativeOperator >
OutputIterator thrust::transform_exclusive_scan (InputIterator first, InputIterator last, OutputIterator result, UnaryFunction unary_op, T init, AssociativeOperator binary_op)
 

Detailed Description

Function Documentation

template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename UnaryFunction , typename T , typename AssociativeOperator >
__host__ __device__ OutputIterator thrust::transform_exclusive_scan ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
OutputIterator  result,
UnaryFunction  unary_op,
init,
AssociativeOperator  binary_op 
)

transform_exclusive_scan fuses the transform and exclusive_scan operations. transform_exclusive_scan is equivalent to performing a tranformation defined by unary_op into a temporary sequence and then performing an exclusive_scan on the tranformed sequence. In most cases, fusing these two operations together is more efficient, since fewer memory reads and writes are required. In transform_exclusive_scan, init is assigned to *result and the result of binary_op(init, unary_op(*first)) is assigned to *(result + 1), and so on. The transform scan operation is permitted to be in-place.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the input sequence.
lastThe end of the input sequence.
resultThe beginning of the output sequence.
unary_opThe function used to tranform the input sequence.
initThe initial value of the exclusive_scan
binary_opThe associatve operator used to 'sum' transformed values.
Returns
The end of the output sequence.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator and InputIterator's value_type is convertible to unary_op's input type.
OutputIteratoris a model of Output Iterator.
UnaryFunctionis a model of Unary Function and accepts inputs of InputIterator's value_type. UnaryFunction's result_type is convertable to OutputIterator's value_type.
Tis convertible to OutputIterator's value_type.
AssociativeOperatoris a model of Binary Function and AssociativeOperator's result_type is convertible to OutputIterator's value_type.
Precondition
first may equal result, but the range [first, last) and the range [result, result + (last - first)) shall not overlap otherwise.

The following code snippet demonstrates how to use transform_exclusive_scan using the thrust::host execution policy for parallelization:

...
int data[6] = {1, 0, 2, 2, 1, 3};
thrust::transform_exclusive_scan(thrust::host, data, data + 6, data, unary_op, 4, binary_op); // in-place scan
// data is now {4, 3, 3, 1, -1, -2}
See Also
transform
exclusive_scan
template<typename InputIterator , typename OutputIterator , typename UnaryFunction , typename T , typename AssociativeOperator >
OutputIterator thrust::transform_exclusive_scan ( InputIterator  first,
InputIterator  last,
OutputIterator  result,
UnaryFunction  unary_op,
init,
AssociativeOperator  binary_op 
)

transform_exclusive_scan fuses the transform and exclusive_scan operations. transform_exclusive_scan is equivalent to performing a tranformation defined by unary_op into a temporary sequence and then performing an exclusive_scan on the tranformed sequence. In most cases, fusing these two operations together is more efficient, since fewer memory reads and writes are required. In transform_exclusive_scan, init is assigned to *result and the result of binary_op(init, unary_op(*first)) is assigned to *(result + 1), and so on. The transform scan operation is permitted to be in-place.

Parameters
firstThe beginning of the input sequence.
lastThe end of the input sequence.
resultThe beginning of the output sequence.
unary_opThe function used to tranform the input sequence.
initThe initial value of the exclusive_scan
binary_opThe associatve operator used to 'sum' transformed values.
Returns
The end of the output sequence.
Template Parameters
InputIteratoris a model of Input Iterator and InputIterator's value_type is convertible to unary_op's input type.
OutputIteratoris a model of Output Iterator.
UnaryFunctionis a model of Unary Function and accepts inputs of InputIterator's value_type. UnaryFunction's result_type is convertable to OutputIterator's value_type.
Tis convertible to OutputIterator's value_type.
AssociativeOperatoris a model of Binary Function and AssociativeOperator's result_type is convertible to OutputIterator's value_type.
Precondition
first may equal result, but the range [first, last) and the range [result, result + (last - first)) shall not overlap otherwise.

The following code snippet demonstrates how to use transform_exclusive_scan

int data[6] = {1, 0, 2, 2, 1, 3};
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 Also
transform
exclusive_scan
template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename UnaryFunction , typename AssociativeOperator >
__host__ __device__ OutputIterator thrust::transform_inclusive_scan ( const thrust::detail::execution_policy_base< DerivedPolicy > &  exec,
InputIterator  first,
InputIterator  last,
OutputIterator  result,
UnaryFunction  unary_op,
AssociativeOperator  binary_op 
)

transform_inclusive_scan fuses the transform and inclusive_scan operations. transform_inclusive_scan is equivalent to performing a tranformation defined by unary_op into a temporary sequence and then performing an inclusive_scan on the tranformed sequence. In most cases, fusing these two operations together is more efficient, since fewer memory reads and writes are required. In transform_inclusive_scan, unary_op(*first) is assigned to *result and the result of binary_op(unary_op(*first), unary_op(*(first + 1))) is assigned to *(result + 1), and so on. The transform scan operation is permitted to be in-place.

The algorithm's execution is parallelized as determined by exec.

Parameters
execThe execution policy to use for parallelization.
firstThe beginning of the input sequence.
lastThe end of the input sequence.
resultThe beginning of the output sequence.
unary_opThe function used to tranform the input sequence.
binary_opThe associatve operator used to 'sum' transformed values.
Returns
The end of the output sequence.
Template Parameters
DerivedPolicyThe name of the derived execution policy.
InputIteratoris a model of Input Iterator and InputIterator's value_type is convertible to unary_op's input type.
OutputIteratoris a model of Output Iterator.
UnaryFunctionis a model of Unary Function and accepts inputs of InputIterator's value_type. UnaryFunction's result_type is convertable to OutputIterator's value_type.
AssociativeOperatoris a model of Binary Function and AssociativeOperator's result_type is convertible to OutputIterator's value_type.
Precondition
first may equal result, but the range [first, last) and the range [result, result + (last - first)) shall not overlap otherwise.

The following code snippet demonstrates how to use transform_inclusive_scan using the thrust::host execution policy for parallelization:

...
int data[6] = {1, 0, 2, 2, 1, 3};
thrust::transform_inclusive_scan(thrust::host, data, data + 6, data, unary_op, binary_op); // in-place scan
// data is now {-1, -1, -3, -5, -6, -9}
See Also
transform
inclusive_scan
template<typename InputIterator , typename OutputIterator , typename UnaryFunction , typename AssociativeOperator >
OutputIterator thrust::transform_inclusive_scan ( InputIterator  first,
InputIterator  last,
OutputIterator  result,
UnaryFunction  unary_op,
AssociativeOperator  binary_op 
)

transform_inclusive_scan fuses the transform and inclusive_scan operations. transform_inclusive_scan is equivalent to performing a tranformation defined by unary_op into a temporary sequence and then performing an inclusive_scan on the tranformed sequence. In most cases, fusing these two operations together is more efficient, since fewer memory reads and writes are required. In transform_inclusive_scan, unary_op(*first) is assigned to *result and the result of binary_op(unary_op(*first), unary_op(*(first + 1))) is assigned to *(result + 1), and so on. The transform scan operation is permitted to be in-place.

Parameters
firstThe beginning of the input sequence.
lastThe end of the input sequence.
resultThe beginning of the output sequence.
unary_opThe function used to tranform the input sequence.
binary_opThe associatve operator used to 'sum' transformed values.
Returns
The end of the output sequence.
Template Parameters
InputIteratoris a model of Input Iterator and InputIterator's value_type is convertible to unary_op's input type.
OutputIteratoris a model of Output Iterator.
UnaryFunctionis a model of Unary Function and accepts inputs of InputIterator's value_type. UnaryFunction's result_type is convertable to OutputIterator's value_type.
AssociativeOperatoris a model of Binary Function and AssociativeOperator's result_type is convertible to OutputIterator's value_type.
Precondition
first may equal result, but the range [first, last) and the range [result, result + (last - first)) shall not overlap otherwise.

The following code snippet demonstrates how to use transform_inclusive_scan

int data[6] = {1, 0, 2, 2, 1, 3};
thrust::transform_inclusive_scan(data, data + 6, data, unary_op, binary_op); // in-place scan
// data is now {-1, -1, -3, -5, -6, -9}
See Also
transform
inclusive_scan