tabulate.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP
  11. #define BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP
  12. #include <iterator>
  13. #include <boost/compute/algorithm/transform.hpp>
  14. #include <boost/compute/iterator/counting_iterator.hpp>
  15. namespace boost {
  16. namespace compute {
  17. namespace experimental {
  18. template<class Iterator, class UnaryFunction>
  19. inline void tabulate(Iterator first,
  20. Iterator last,
  21. UnaryFunction function,
  22. command_queue &queue)
  23. {
  24. size_t n = detail::iterator_range_size(first, last);
  25. ::boost::compute::transform(
  26. ::boost::compute::make_counting_iterator<int>(0),
  27. ::boost::compute::make_counting_iterator<int>(n),
  28. first,
  29. function,
  30. queue
  31. );
  32. }
  33. } // end experimental namespace
  34. } // end compute namespace
  35. } // end boost namespace
  36. #endif // BOOST_COMPUTE_EXPERIMENTAL_TABULATE_HPP