1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ALGORITHM_COUNT_HPP
12 #define BOOST_COMPUTE_ALGORITHM_COUNT_HPP
14 #include <boost/compute/lambda.hpp>
15 #include <boost/compute/system.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/count_if.hpp>
18 #include <boost/compute/type_traits/vector_size.hpp>
23 /// Returns the number of occurrences of \p value in the range
24 /// [\p first, \p last).
26 /// Space complexity on CPUs: \Omega(1)<br>
27 /// Space complexity on GPUs: \Omega(n)
30 template<class InputIterator, class T>
31 inline size_t count(InputIterator first,
34 command_queue &queue = system::default_queue())
36 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
38 using ::boost::compute::_1;
39 using ::boost::compute::lambda::all;
41 if(vector_size<value_type>::value == 1){
42 return ::boost::compute::count_if(first,
48 return ::boost::compute::count_if(first,
55 } // end compute namespace
56 } // end boost namespace
58 #endif // BOOST_COMPUTE_ALGORITHM_COUNT_HPP