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

A uniform_real_distribution random number distribution produces floating point uniform random numbers from a half-open interval. More...

#include <thrust/random/uniform_real_distribution.h>

Public Types

typedef RealType result_type
 The type of the floating point number produced by this uniform_real_distribution.
 
typedef thrust::pair< RealType, RealType > param_type
 The type of the object encapsulating this uniform_real_distribution's parameters.
 

Public Member Functions

__host__ __device__ uniform_real_distribution (RealType a=0.0, RealType b=1.0)
 
__host__ __device__ uniform_real_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 RealType = double>
class thrust::random::uniform_real_distribution< RealType >

A uniform_real_distribution random number distribution produces floating point uniform random numbers from a half-open interval.

Template Parameters
RealTypeThe type of floating point number to produce.

The following code snippet demonstrates examples of using a uniform_real_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_real_distribution to produce floats 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.0 is printed
std::cout << dist.max() << std::endl;
// 13.0 is printed
// write the parameters of the distribution (which happen to be the bounds) to standard output
std::cout << dist.a() << std::endl;
// -7.0 is printed
std::cout << dist.b() << std::endl;
// 13.0 is printed
return 0;
}

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