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 min_element

boost::compute::min_element

Synopsis

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


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

Description

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

For example, to find int2 value with minimum 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 min =
    boost::compute::min_element(data.begin(), data.end(), compare_first, queue);

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

See Also:

max_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