File indexing completed on 2025-01-18 09:29:54
0001
0002
0003
0004
0005
0006
0007
0008
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 }
0054 }
0055 }
0056
0057 #endif