thrust
Public Types | Public Member Functions | Static Public Attributes | List of all members
thrust::random::subtract_with_carry_engine< UIntType, w, s, r > Class Template Reference

A subtract_with_carry_engine random number engine produces unsigned integer random numbers using the subtract with carry algorithm of Marsaglia & Zaman. More...

#include <thrust/random/subtract_with_carry_engine.h>

Public Types

typedef UIntType result_type
 The type of the unsigned integer produced by this subtract_with_carry_engine.
 

Public Member Functions

__host__ __device__ subtract_with_carry_engine (result_type value=default_seed)
 
__host__ __device__ void seed (result_type value=default_seed)
 
__host__ __device__ result_type operator() (void)
 
__host__ __device__ void discard (unsigned long long z)
 

Static Public Attributes

static const size_t word_size = w
 
static const size_t short_lag = s
 
static const size_t long_lag = r
 
static const result_type min = 0
 
static const result_type max = modulus - 1
 
static const result_type default_seed = 19780503u
 

Detailed Description

template<typename UIntType, size_t w, size_t s, size_t r>
class thrust::random::subtract_with_carry_engine< UIntType, w, s, r >

A subtract_with_carry_engine random number engine produces unsigned integer random numbers using the subtract with carry algorithm of Marsaglia & Zaman.

The generation algorithm is performed as follows:

  1. Let Y = X_{i-s}- X_{i-r} - c.
  2. Set X_i to y = T mod m. Set c to 1 if Y < 0, otherwise set c to 0.

This algorithm corresponds to a modular linear function of the form

TA(x_i) = (a * x_i) mod b, where b is of the form m^r - m^s + 1 and a = b - (b-1)/m.

Template Parameters
UIntTypeThe type of unsigned integer to produce.
wThe word size of the produced values ( w <= sizeof(UIntType)).
sThe short lag of the generation algorithm.
rThe long lag of the generation algorithm.
Note
Inexperienced users should not use this class template directly. Instead, use ranlux24_base or ranlux48_base, which are instances of subtract_with_carry_engine.
See also
thrust::random::ranlux24_base
thrust::random::ranlux48_base

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