Template Numerical Library version\ main:f17d0c8
No Matches
TNL::Algorithms::SegmentedScan< Device, Type > Struct Template Reference

Computes segmented scan (or prefix sum) on a vector. More...

Detailed Description

template<typename Device, detail::ScanType Type = detail::ScanType::Inclusive>
struct TNL::Algorithms::SegmentedScan< Device, Type >

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:

[1,0,0,1,0,0,0,1,0,1,0,0, 0, 0]
Template Parameters
Deviceparameter says on what device the reduction is gonna be performed.
Typeparameter 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.

The documentation for this struct was generated from the following file: