thrust::inclusive_scan_by_key#
Overloads#
inclusive_scan_by_key(exec, first1, last1, first2, result)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::inclusive_scan_by_key( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyassumesequal_toas the binary predicate used to compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment if*i == *(i+1), and belong to different segments otherwise.This version of
inclusive_scan_by_keyassumesplusas the associative operator used to perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
inclusive_scan_by_keyusing thethrust::hostexecution policy for parallelization:#include <thrust/scan.h> #include <thrust/execution_policy.h> ... int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; thrust::inclusive_scan_by_key(thrust::host, keys, keys + 10, data, data); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.
inclusive_scan_by_key(first1, last1, first2, result)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator thrust::inclusive_scan_by_key( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyassumesequal_toas the binary predicate used to compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment if*i == *(i+1), and belong to different segments otherwise.This version of
inclusive_scan_by_keyassumesplusas the associative operator used to perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
The following code snippet demonstrates how to use
inclusive_scan_by_key#include <thrust/scan.h> int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; thrust::inclusive_scan_by_key(keys, keys + 10, data, data); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
- Template Parameters:
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.
inclusive_scan_by_key(exec, first1, last1, first2, result, binary_pred)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryPredicate>
OutputIterator thrust::inclusive_scan_by_key( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
- BinaryPredicate binary_pred,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyuses the binary predicatepredto compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment ifbinary_pred(*i, *(i+1))is true, and belong to different segments otherwise.This version of
inclusive_scan_by_keyassumesplusas the associative operator used to perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
inclusive_scan_by_keyusing thethrust::hostexecution policy for parallelization:#include <thrust/scan.h> #include <thrust/functional.h> #include <thrust/execution_policy.h> ... int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; ::cuda::std::equal_to<int> binary_pred; thrust::inclusive_scan_by_key(thrust::host, keys, keys + 10, data, data, binary_pred); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
binary_pred – The binary predicate used to determine equality of keys.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.BinaryPredicate – is a model of Binary Predicate.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.
inclusive_scan_by_key(first1, last1, first2, result, binary_pred)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryPredicate>
OutputIterator thrust::inclusive_scan_by_key( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
- BinaryPredicate binary_pred,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyuses the binary predicatepredto compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment ifbinary_pred(*i, *(i+1))is true, and belong to different segments otherwise.This version of
inclusive_scan_by_keyassumesplusas the associative operator used to perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
The following code snippet demonstrates how to use
inclusive_scan_by_key#include <thrust/scan.h> #include <thrust/functional.h> int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; ::cuda::std::equal_to<int> binary_pred; thrust::inclusive_scan_by_key(keys, keys + 10, data, data, binary_pred); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
binary_pred – The binary predicate used to determine equality of keys.
- Template Parameters:
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.BinaryPredicate – is a model of Binary Predicate.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.
inclusive_scan_by_key(exec, first1, last1, first2, result, binary_pred, binary_op)#
-
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryPredicate, typename AssociativeOperator>
OutputIterator thrust::inclusive_scan_by_key( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
- BinaryPredicate binary_pred,
- AssociativeOperator binary_op,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyuses the binary predicatepredto compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment ifbinary_pred(*i, *(i+1))is true, and belong to different segments otherwise.This version of
inclusive_scan_by_keyuses the associative operatorbinary_opto perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
inclusive_scan_by_keyusing thethrust::hostexecution policy for parallelization:#include <thrust/scan.h> #include <thrust/functional.h> #include <thrust/execution_policy.h> ... int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; ::cuda::std::equal_to<int> binary_pred; ::cuda::std::plus<int> binary_op; thrust::inclusive_scan_by_key(thrust::host, keys, keys + 10, data, data, binary_pred, binary_op); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
binary_pred – The binary predicate used to determine equality of keys.
binary_op – The associative operator used to ‘sum’ values.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.BinaryPredicate – is a model of Binary Predicate.
AssociativeOperator – The function’s return type must be convertible to
OutputIterator'svalue_type.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.
inclusive_scan_by_key(first1, last1, first2, result, binary_pred, binary_op)#
-
template<typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryPredicate, typename AssociativeOperator>
OutputIterator thrust::inclusive_scan_by_key( - InputIterator1 first1,
- InputIterator1 last1,
- InputIterator2 first2,
- OutputIterator result,
- BinaryPredicate binary_pred,
- AssociativeOperator binary_op,
inclusive_scan_by_keycomputes an inclusive key-value or ‘segmented’ prefix sum operation. The term ‘inclusive’ means that each result includes the corresponding input operand in the partial sum. The term ‘segmented’ means that the partial sums are broken into distinct segments. In other words, within each segment a separate inclusive scan operation is computed. Refer to the code sample below for example usage.This version of
inclusive_scan_by_keyuses the binary predicatepredto compare adjacent keys. Specifically, consecutive iteratorsiandi+1in the range[first1, last1)belong to the same segment ifbinary_pred(*i, *(i+1))is true, and belong to different segments otherwise.Results are not deterministic for pseudo-associative operators (e.g., addition of floating-point types). Results for pseudo-associative operators may vary from run to run.
This version of
inclusive_scan_by_keyuses the associative operatorbinary_opto perform the prefix sum. When the input and output sequences are the same, the scan is performed in-place.The following code snippet demonstrates how to use
inclusive_scan_by_key#include <thrust/scan.h> #include <thrust/functional.h> int data[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; ::cuda::std::equal_to<int> binary_pred; ::cuda::std::plus<int> binary_op; thrust::inclusive_scan_by_key(keys, keys + 10, data, data, binary_pred, binary_op); // in-place scan // data is now {1, 2, 3, 1, 2, 1, 1, 2, 3, 4};
See also
See also
- Parameters:
first1 – The beginning of the key sequence.
last1 – The end of the key sequence.
first2 – The beginning of the input value sequence.
result – The beginning of the output value sequence.
binary_pred – The binary predicate used to determine equality of keys.
binary_op – The associative operator used to ‘sum’ values.
- Template Parameters:
InputIterator1 – is a model of Input Iterator
InputIterator2 – is a model of Input Iterator and
InputIterator2'svalue_typeis convertible toOutputIterator'svalue_type.OutputIterator – is a model of Output Iterator, and if
xandyare objects ofOutputIterator'svalue_type, thenbinary_op(x,y)is defined.BinaryPredicate – is a model of Binary Predicate.
AssociativeOperator – The function’s return type must be convertible to
OutputIterator'svalue_type.
- Returns:
The end of the output sequence.
- Pre:
first1may equalresultbut the range[first1, last1)and the range[result, result + (last1 - first1))shall not overlap otherwise.- Pre:
first2may equalresultbut the range[first2, first2 + (last1 - first1)and the range[result, result + (last1 - first1))shall not overlap otherwise.