1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@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_ROTATE_COPY_HPP
12 #define BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy.hpp>
20 /// Performs left rotation such that element at n_first comes to the
21 /// beginning and the output is stored in range starting at result.
23 /// Space complexity: \Omega(1)
26 template<class InputIterator, class OutputIterator>
27 inline void rotate_copy(InputIterator first,
28 InputIterator n_first,
30 OutputIterator result,
31 command_queue &queue = system::default_queue())
33 size_t count = detail::iterator_range_size(first, n_first);
34 size_t count2 = detail::iterator_range_size(n_first, last);
36 ::boost::compute::copy(first+count, last, result, queue);
37 ::boost::compute::copy(first, first+count, result+count2, queue);
40 } //end compute namespace
41 } //end boost namespace
43 #endif // BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP