PrevUpHomeNext

Function transform

boost::compute::transform

Synopsis

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


template<typename InputIterator, typename OutputIterator, 
         typename UnaryOperator> 
  OutputIterator 
  transform(InputIterator first, InputIterator last, OutputIterator result, 
            UnaryOperator op, 
            command_queue & queue = system::default_queue());
template<typename InputIterator1, typename InputIterator2, 
         typename OutputIterator, typename BinaryOperator> 
  OutputIterator 
  transform(InputIterator1 first1, InputIterator1 last1, 
            InputIterator2 first2, OutputIterator result, BinaryOperator op, 
            command_queue & queue = system::default_queue());

Description

Transforms the elements in the range [first, last) using transform and stores the results in the range beginning at result.

For example, to calculate the absolute value for each element in a vector:

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

using boost::compute::abs;

// calculate the absolute value for each element in-place
boost::compute::transform(
    vec.begin(), vec.end(), vec.begin(), abs<int>(), queue
);

// vec == { 1, 2, 3, 4 }

See Also:

copy()


PrevUpHomeNext