• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@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_ALGORITHM_ROTATE_COPY_HPP
12 #define BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP
13 
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy.hpp>
16 
17 namespace boost {
18 namespace compute {
19 
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.
22 ///
23 /// Space complexity: \Omega(1)
24 ///
25 /// \see rotate()
26 template<class InputIterator, class OutputIterator>
rotate_copy(InputIterator first,InputIterator n_first,InputIterator last,OutputIterator result,command_queue & queue=system::default_queue ())27 inline void rotate_copy(InputIterator first,
28                         InputIterator n_first,
29                         InputIterator last,
30                         OutputIterator result,
31                         command_queue &queue = system::default_queue())
32 {
33     size_t count = detail::iterator_range_size(first, n_first);
34     size_t count2 = detail::iterator_range_size(n_first, last);
35 
36     ::boost::compute::copy(first+count, last, result, queue);
37     ::boost::compute::copy(first, first+count, result+count2, queue);
38 }
39 
40 } //end compute namespace
41 } //end boost namespace
42 
43 #endif // BOOST_COMPUTE_ALGORITHM_ROTATE_COPY_HPP
44