thrust
Public Types | Public Member Functions | List of all members
thrust::random::uniform_int_distribution< IntType > Class Template Reference

A uniform_int_distribution random number distribution produces signed or unsigned integer uniform random numbers from a given range. More...

#include <thrust/random/uniform_int_distribution.h>

Public Types

typedef IntType result_type
 The type of the integer produced by this uniform_int_distribution.
 
typedef thrust::pair< IntType, IntType > param_type
 The type of the object encapsulating this uniform_int_distribution's parameters.
 

Public Member Functions

__host__ __device__ uniform_int_distribution (IntType a=0, IntType b=thrust::detail::integer_traits< IntType >::const_max)
 
__host__ __device__ uniform_int_distribution (const param_type &parm)
 
__host__ __device__ void reset (void)
 
template<typename UniformRandomNumberGenerator >
__host__ __device__ result_type operator() (UniformRandomNumberGenerator &urng)
 
template<typename UniformRandomNumberGenerator >
__host__ __device__ result_type operator() (UniformRandomNumberGenerator &urng, const param_type &parm)
 
__host__ __device__ result_type a (void) const
 
__host__ __device__ result_type b (void) const
 
__host__ __device__ param_type param (void) const
 
__host__ __device__ void param (const param_type &parm)
 
__host__ __device__ result_type min THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
 
__host__ __device__ result_type max THRUST_PREVENT_MACRO_SUBSTITUTION (void) const
 

Detailed Description

template<typename IntType = int>
class thrust::random::uniform_int_distribution< IntType >

A uniform_int_distribution random number distribution produces signed or unsigned integer uniform random numbers from a given range.

Template Parameters
IntTypeThe type of integer to produce.

The following code snippet demonstrates examples of using a uniform_int_distribution with a random number engine to produce random integers drawn from a given range:

int main(void)
{
// create a minstd_rand object to act as our source of randomness
// create a uniform_int_distribution to produce ints from [-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;
}

The documentation for this class was generated from the following file: