PrevUpHomeNext

Function template exclusive_scan

boost::compute::exclusive_scan

Synopsis

// In header: <boost/compute/algorithm/exclusive_scan.hpp>


template<typename InputIterator, typename OutputIterator> 
  OutputIterator 
  exclusive_scan(InputIterator first, InputIterator last, 
                 OutputIterator result, 
                 command_queue & queue = system::default_queue());

Description

Performs an exclusive scan of the elements in the range [first, last) and stores the results in the range beginning at result.

Each element in the output is assigned to the sum of all the previous values in the input.

// setup input
int data[] = { 1, 2, 3, 4 };
boost::compute::vector<int> input(data, data + 4, queue);

// setup output
boost::compute::vector<int> output(4, context);

// scan values
boost::compute::exclusive_scan(
    input.begin(), input.end(), output.begin(), queue
);

// output = [ 0, 1, 3, 6 ]

See Also:

inclusive_scan()

Parameters:

first

first element in the range to scan

last

last element in the range to scan

queue

command queue to perform the operation

result

first element in the result range

Returns:

OutputIterator to the end of the result range


PrevUpHomeNext