OpenMPCD
Uniform0e1e.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the `OpenMPCD::CUDA::Random::Distributions::Uniform0e1e` class.
4  */
5 
6 #ifndef OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_UNIFORM0E1E_HPP
7 #define OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_UNIFORM0E1E_HPP
8 
11 
12 
13 namespace OpenMPCD
14 {
15 namespace CUDA
16 {
17 namespace Random
18 {
19 namespace Distributions
20 {
21 
22 /**
23  * The uniform distribution in the open interval \f$ (0, 1) \f$.
24  *
25  * Neither \f$ 0 \f$ nor \f$ 1 \f$ lie within the range of possible values.
26  *
27  * @tparam T The underlying data type, which must be `float` or `double`.
28  */
29 template<typename T>
31 {
32 public:
33  /**
34  * Generates a random value sampled from the distribution.
35  *
36  * @tparam RNG The random number generator type.
37  *
38  * @param[in] rng The random number generator instance.
39  */
40  template<typename RNG>
42  T operator()(RNG& rng) const
43  {
44  Uniform0e1i<T> dist;
45 
46  T value;
47 
48  do
49  {
50  value = dist(rng);
51  }
52  while(value == 1);
53 
54  return value;
55  }
56 }; //class Uniform0e1e
57 
58 } //namespace Distributions
59 } //namespace Random
60 } //namespace CUDA
61 } //namespace OpenMPCD
62 
63 
64 #endif //OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_UNIFORM0E1E_HPP
Uniform0e1i.hpp
OpenMPCD::CUDA::Random::Distributions::Uniform0e1e
The uniform distribution in the open interval .
Definition: Uniform0e1e.hpp:30
OPENMPCD_CUDA_DEVICE
#define OPENMPCD_CUDA_DEVICE
Denotes a function to be callable from a CUDA Device.
Definition: Macros.hpp:25
OpenMPCD::CUDA::Random::Distributions::Uniform0e1i
The uniform distribution in the left-open interval .
Definition: Uniform0e1i.hpp:36
OpenMPCD::RNG
boost::mt11213b RNG
The random number generator type.
Definition: Types.hpp:18
Macros.hpp
OpenMPCD::CUDA::Random::Distributions::Uniform0e1e::operator()
OPENMPCD_CUDA_DEVICE T operator()(RNG &rng) const
Generates a random value sampled from the distribution.
Definition: Uniform0e1e.hpp:42