Back to home page

EIC code displayed by LXR

 
 

    


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

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_DETAIL_RANDOM_FILL_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_DETAIL_RANDOM_FILL_HPP
0013 
0014 #include <iterator>
0015 
0016 #include <boost/compute/command_queue.hpp>
0017 #include <boost/compute/random/default_random_engine.hpp>
0018 #include <boost/compute/random/uniform_real_distribution.hpp>
0019 
0020 namespace boost {
0021 namespace compute {
0022 namespace detail {
0023 
0024 template<class OutputIterator, class Generator>
0025 inline void random_fill(OutputIterator first,
0026                         OutputIterator last,
0027                         Generator &g,
0028                         command_queue &queue)
0029 {
0030     g.fill(first, last, queue);
0031 }
0032 
0033 template<class OutputIterator>
0034 inline void
0035 random_fill(OutputIterator first,
0036             OutputIterator last,
0037             typename std::iterator_traits<OutputIterator>::value_type lo,
0038             typename std::iterator_traits<OutputIterator>::value_type hi,
0039             command_queue &queue)
0040 {
0041     typedef typename
0042         std::iterator_traits<OutputIterator>::value_type value_type;
0043     typedef typename
0044         boost::compute::default_random_engine engine_type;
0045     typedef typename
0046         boost::compute::uniform_real_distribution<value_type> distribution_type;
0047 
0048     engine_type engine(queue);
0049     distribution_type generator(lo, hi);
0050     generator.fill(first, last, engine, queue);
0051 }
0052 
0053 } // end detail namespace
0054 } // end compute namespace
0055 } // end boost namespace
0056 
0057 #endif // BOOST_COMPUTE_ALGORITHM_DETAIL_RANDOM_FILL_HPP