• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
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
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP
12 #define BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP
13 
14 #include <iterator>
15 
16 #include <boost/compute/algorithm/transform.hpp>
17 #include <boost/compute/iterator/counting_iterator.hpp>
18 
19 namespace boost {
20 namespace compute {
21 namespace experimental {
22 
23 template<class Iterator, class UnaryFunction>
tabulate(Iterator first,Iterator last,UnaryFunction function,command_queue & queue)24 inline void tabulate(Iterator first,
25                      Iterator last,
26                      UnaryFunction function,
27                      command_queue &queue)
28 {
29     size_t n = detail::iterator_range_size(first, last);
30 
31     ::boost::compute::transform(
32         ::boost::compute::make_counting_iterator<int>(0),
33         ::boost::compute::make_counting_iterator<int>(n),
34         first,
35         function,
36         queue
37     );
38 }
39 
40 } // end experimental namespace
41 } // end compute namespace
42 } // end boost namespace
43 
44 #endif // BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP
45