Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:56

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_ALGORITHM_IOTA_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_IOTA_HPP
0013 
0014 #include <boost/static_assert.hpp>
0015 
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/command_queue.hpp>
0018 #include <boost/compute/algorithm/copy.hpp>
0019 #include <boost/compute/iterator/counting_iterator.hpp>
0020 #include <boost/compute/type_traits/is_device_iterator.hpp>
0021 
0022 namespace boost {
0023 namespace compute {
0024 
0025 /// Fills the range [\p first, \p last) with sequential values starting at
0026 /// \p value.
0027 ///
0028 /// For example, the following code:
0029 /// \snippet test/test_iota.cpp iota
0030 ///
0031 /// Will fill \c vec with the values (\c 0, \c 1, \c 2, \c ...).
0032 ///
0033 /// Space complexity: \Omega(1)
0034 template<class BufferIterator, class T>
0035 inline void iota(BufferIterator first,
0036                  BufferIterator last,
0037                  const T &value,
0038                  command_queue &queue = system::default_queue())
0039 {
0040     BOOST_STATIC_ASSERT(is_device_iterator<BufferIterator>::value);
0041     T count = static_cast<T>(detail::iterator_range_size(first, last));
0042 
0043     copy(
0044         ::boost::compute::make_counting_iterator(value),
0045         ::boost::compute::make_counting_iterator(value + count),
0046         first,
0047         queue
0048     );
0049 }
0050 
0051 } // end compute namespace
0052 } // end boost namespace
0053 
0054 #endif // BOOST_COMPUTE_ALGORITHM_IOTA_HPP