Template Numerical Library version\ main:df396df
|
Computes segmented scan (or prefix sum) on a vector. More...
Computes segmented scan (or prefix sum) on a vector.
Segmented scan is a modification of common scan. In this case the sequence of numbers in hand is divided into segments like this, for example
and we want to compute inclusive or exclusive scan of each segment. For inclusive segmented prefix sum we get
and for exclusive segmented prefix sum it is
In addition to common scan, we need to encode the segments of the input sequence. It is done by auxiliary flags array (it can be array of booleans) having 1
at the beginning of each segment and 0
on all other positions. In our example, it would be like this:
Device | parameter says on what device the reduction is gonna be performed. |
Type | parameter says if inclusive or exclusive is scan is to be computed. |
See SegmentedScan< Devices::Host, Type > and SegmentedScan< Devices::Cuda, Type >.
Note: Segmented scan is not implemented for CUDA yet.