Template Numerical Library version\ main:94209208
Loading...
Searching...
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

[1,3,5][2,4,6,9][3,5],[3,6,9,12,15]

and we want to compute inclusive or exclusive scan of each segment. For inclusive segmented prefix sum we get

[1,4,9][2,6,12,21][3,8][3,9,18,30,45]

and for exclusive segmented prefix sum it is

[0,1,4][0,2,6,12][0,3][0,3,9,18,30]

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]
[1,3,5,2,4,6,9,3,5,3,6,9,12,15]
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: