thrust::random::uniform_int_distribution
Defined in thrust/random/uniform_int_distribution.h
- 
template<typename IntType = int>
 class uniform_int_distribution
- A - uniform_int_distributionrandom number distribution produces signed or unsigned integer uniform random numbers from a given range.- The following code snippet demonstrates examples of using a - uniform_int_distributionwith a random number engine to produce random integers drawn from a given range:- #include <thrust/random/linear_congruential_engine.h> #include <thrust/random/uniform_int_distribution.h> int main() { // create a minstd_rand object to act as our source of randomness thrust::minstd_rand rng; // create a uniform_int_distribution to produce ints from [-7,13] thrust::uniform_int_distribution<int> dist(-7,13); // write a random number from the range [-7,13] to standard output std::cout << dist(rng) << std::endl; // write the range of the distribution, just in case we forgot std::cout << dist.min() << std::endl; // -7 is printed std::cout << dist.max() << std::endl; // 13 is printed // write the parameters of the distribution (which happen to be the bounds) to standard output std::cout << dist.a() << std::endl; // -7 is printed std::cout << dist.b() << std::endl; // 13 is printed return 0; } - Template Parameters
- IntType – The type of integer to produce. 
 - Public Types - 
typedef IntType result_type
- The type of the integer produced by this - uniform_int_distribution.
 - Public Functions - 
explicit uniform_int_distribution(IntType a = 0, IntType b = ::cuda::std::numeric_limits<IntType>::max())
- This constructor creates a new - uniform_int_distributionfrom two values defining the range of the distribution.- Parameters
- a – The smallest integer to potentially produce. Defaults to - 0.
- b – The largest integer to potentially produce. Defaults to the largest representable integer in the platform. 
 
 
 - 
explicit uniform_int_distribution(const param_type &parm)
- This constructor creates a new - uniform_int_distributionfrom a- param_typeobject encapsulating the range of the distribution.- Parameters
- parm – A - param_typeobject encapsulating the parameters (i.e., the range) of the distribution.
 
 - 
void reset()
- This does nothing. It is included to conform to the requirements of the RandomDistribution concept. 
 - 
template<typename UniformRandomNumberGenerator>
 result_type operator()(UniformRandomNumberGenerator &urng)
- This method produces a new uniform random integer drawn from this - uniform_int_distribution'srange using a- UniformRandomNumberGeneratoras a source of randomness.- Parameters
- urng – The - UniformRandomNumberGeneratorto use as a source of randomness.
 
 - 
template<typename UniformRandomNumberGenerator>
 result_type operator()(UniformRandomNumberGenerator &urng, const param_type &parm)
- This method produces a new uniform random integer as if by creating a new - uniform_int_distributionfrom the given- param_typeobject, and calling its- operator()method with the given- UniformRandomNumberGeneratoras a source of randomness.- Parameters
- urng – The - UniformRandomNumberGeneratorto use as a source of randomness.
- parm – A - param_typeobject encapsulating the parameters of the- uniform_int_distributionto draw from.
 
 
 - 
result_type a() const
- This method returns the value of the parameter with which this - uniform_int_distributionwas constructed.- Returns
- The lower bound of this - uniform_int_distribution'srange.
 
 - 
result_type b() const
- This method returns the value of the parameter with which this - uniform_int_distributionwas constructed.- Returns
- The upper bound of this - uniform_int_distribution'srange.
 
 - 
param_type param() const
- This method returns a - param_typeobject encapsulating the parameters with which this- uniform_int_distributionwas constructed.- Returns
- A - param_typeobject enapsulating the range of this- uniform_int_distribution.
 
 - 
void param(const param_type &parm)
- This method changes the parameters of this - uniform_int_distributionusing the values encapsulated in a given- param_typeobject.- Parameters
- parm – A - param_typeobject encapsulating the new range of this- uniform_int_distribution.
 
 - 
result_type min() const
- This method returns the smallest integer this - uniform_int_distributioncan potentially produce.- Returns
- The lower bound of this - uniform_int_distribution'srange.
 
 - 
result_type max() const
- This method returns the largest integer this - uniform_int_distributioncan potentially produce.- Returns
- The upper bound of this - uniform_int_distribution'srange.