Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:00

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_EXPERIMENTAL_CLAMP_RANGE_HPP
0012 #define BOOST_COMPUTE_EXPERIMENTAL_CLAMP_RANGE_HPP
0013 
0014 #include <iterator>
0015 
0016 #include <boost/compute/lambda.hpp>
0017 #include <boost/compute/algorithm/transform.hpp>
0018 
0019 namespace boost {
0020 namespace compute {
0021 namespace experimental {
0022 
0023 template<class InputIterator, class OutputIterator>
0024 inline OutputIterator
0025 clamp_range(InputIterator first,
0026             InputIterator last,
0027             OutputIterator result,
0028             typename std::iterator_traits<InputIterator>::value_type lo,
0029             typename std::iterator_traits<InputIterator>::value_type hi,
0030             command_queue &queue)
0031 {
0032     using ::boost::compute::lambda::_1;
0033     using ::boost::compute::lambda::_2;
0034     using ::boost::compute::lambda::clamp;
0035 
0036     return ::boost::compute::transform(
0037         first,
0038         last,
0039         result,
0040         clamp(_1, lo, hi),
0041         queue
0042     );
0043 }
0044 
0045 } // end experimental namespace
0046 } // end compute namespace
0047 } // end boost namespace
0048 
0049 #endif // BOOST_COMPUTE_EXPERIMENTAL_CLAMP_RANGE_HPP