thrust::exclusive_scan_by_key
Defined in thrust/scan.h
- 
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename T>
 OutputIterator thrust::exclusive_scan_by_key(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, T init)
- exclusive_scan_by_keycomputes an exclusive key-value or ‘segmented’ prefix sum operation. The term ‘exclusive’ means that each result does not include 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 exclusive scan operation is computed. Refer to the code sample below for example usage.- This version of - exclusive_scan_by_keyuses the value- initto initialize the exclusive scan operation.- 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 - exclusive_scan_by_keyusing the- thrust::hostexecution policy for parallelization:- #include <thrust/scan.h> #include <thrust/functional.h> #include <thrust/execution_policy.h> ... int keys[10] = {0, 0, 0, 1, 1, 2, 3, 3, 3, 3}; int vals[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int init = 5; thrust::exclusive_scan_by_key(thrust::host, key, key + 10, vals, vals, init); // in-place scan // vals is now {5, 6, 7, 5, 6, 5, 5, 6, 7, 8}; - See also - exclusive_scan - See also - inclusive_scan_by_key - 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. 
- init – The initial of the exclusive sum value. 
 
- Returns
- The end of the output sequence. 
- Pre
- first1may equal- resultbut the range- [first1, last1)and the range- [result, result + (last1 - first1))shall not overlap otherwise.
- Pre
- first2may equal- resultbut the range- [first2, first2 + (last1 - first1)and the range- [result, result + (last1 - first1))shall not overlap otherwise.