test_bernoulli_distribution.cpp 1.3 KB

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