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 #define BOOST_TEST_MODULE TestBernoulliDistribution 12 #include <boost/test/unit_test.hpp> 13 14 #include <boost/compute/system.hpp> 15 #include <boost/compute/command_queue.hpp> 16 #include <boost/compute/container/vector.hpp> 17 #include <boost/compute/random/default_random_engine.hpp> 18 #include <boost/compute/random/bernoulli_distribution.hpp> 19 20 #include "context_setup.hpp" 21 BOOST_AUTO_TEST_CASE(bernoulli_distribution_doctest)22BOOST_AUTO_TEST_CASE(bernoulli_distribution_doctest) 23 { 24 boost::compute::vector<bool> vec(10, context); 25 26 //! [generate] 27 // initialize the default random engine 28 boost::compute::default_random_engine engine(queue); 29 30 // setup the bernoulli distribution to produce booleans 31 // with parameter p = 0.25 32 boost::compute::bernoulli_distribution<float> distribution(0.25f); 33 34 // generate the random values and store them to 'vec' 35 distribution.generate(vec.begin(), vec.end(), engine, queue); 36 //! [generate] 37 } 38 39 BOOST_AUTO_TEST_SUITE_END() 40