thrust::random::subtract_with_carry_engine#
-
template<typename UIntType, size_t w, size_t s, size_t r>
class subtract_with_carry_engine# A
subtract_with_carry_enginerandom number engine produces unsigned integer random numbers using the subtract with carry algorithm of Marsaglia & Zaman.The generation algorithm is performed as follows:
Let
Y = X_{i-s}- X_{i-r} - c.Set
X_itoy = T mod m. Setcto1ifY < 0, otherwise setcto0.
This algorithm corresponds to a modular linear function of the form
TA(x_i) = (a * x_i) mod b, wherebis of the formm^r - m^s + 1anda = b - (b-1)/m.See also
See also
Note
Inexperienced users should not use this class template directly. Instead, use
ranlux24_baseorranlux48_base, which are instances ofsubtract_with_carry_engine.- Template Parameters:
UIntType – The type of unsigned integer to produce.
w – The word size of the produced values (
w <= sizeof(UIntType)).s – The short lag of the generation algorithm.
r – The long lag of the generation algorithm.
Public Types
-
typedef UIntType result_type#
The type of the unsigned integer produced by this
subtract_with_carry_engine.
Public Functions
-
explicit subtract_with_carry_engine(result_type value = default_seed)#
This constructor, which optionally accepts a seed, initializes a new
subtract_with_carry_engine.- Parameters:
value – The seed used to initialize this
subtract_with_carry_engine'sstate.
-
void seed(result_type value = default_seed)#
This method initializes this
subtract_with_carry_engine'sstate, and optionally accepts a seed value.- Parameters:
value – The seed used to initializes this
subtract_with_carry_engine'sstate.
-
result_type operator()(void)#
This member function produces a new random value and updates this
subtract_with_carry_engine'sstate.- Returns:
A new random number.
-
void discard(unsigned long long z)#
This member function advances this
subtract_with_carry_engine'sstate a given number of times and discards the results.Note
This function is provided because an implementation may be able to accelerate it.
- Parameters:
z – The number of random values to discard.
Public Static Attributes
-
static const result_type min = 0#
The smallest value this
subtract_with_carry_enginemay potentially produce.
-
static const result_type max = modulus - 1#
The largest value this
subtract_with_carry_enginemay potentially produce.
-
static const result_type default_seed = 19780503u#
The default seed of this
subtract_with_carry_engine.