Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Function max_element

boost::compute::max_element

Synopsis

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


template<typename InputIterator, typename Compare> 
  InputIterator 
  max_element(InputIterator first, InputIterator last, Compare compare, 
              command_queue & queue = system::default_queue());
template<typename InputIterator> 
  InputIterator 
  max_element(InputIterator first, InputIterator last, 
              command_queue & queue = system::default_queue());

Description

Returns an iterator pointing to the element in the range [first, last) with the maximum value.

For example, to find int2 value with maximum first component in given vector:

// comparison function object
BOOST_COMPUTE_FUNCTION(bool, compare_first, (const int2_ &a, const int2_ &b),
{
    return a.x < b.x;
});

// create vector
boost::compute::vector<uint2_> data = ...

boost::compute::vector<uint2_>::iterator max =
    boost::compute::max_element(data.begin(), data.end(), compare_first, queue);

Space complexity on CPUs: \Omega(1)
Space complexity on GPUs: \Omega(N)

See Also:

min_element()

Parameters:

compare

comparison function object which returns true if the first argument is less than (i.e. is ordered before) the second.

first

first element in the input range

last

last element in the input range

queue

command queue to perform the operation


PrevUpHomeNext