Rand48 Class Reference

A pseudo random number generator using the linear congruential algorithm with the following parameters: More...

Public Types

typedef uint32_t result_type
 The type of the generated random value. More...
 

Public Member Functions

 Rand48 (uint32_t val=default_seed)
 Construct with specified or default seed. More...
 
void seed (uint32_t val=default_seed)
 Reseed the generator. More...
 
void discard (unsigned long long z)
 Advance the state of the generator by z notches. More...
 
uint64_t raw ()
 
uint32_t operator() ()
 Get the next random number in the sequence. More...
 

Static Public Member Functions

static constexpr uint32_t min ()
 The smallest value that the generator can produce. More...
 
static constexpr uint32_t max ()
 The largest value that the generator can produce. More...
 

Static Public Attributes

static constexpr result_type default_seed = 1u
 The default seed. More...
 

Detailed Description

A pseudo random number generator using the linear congruential algorithm with the following parameters:

    Xn+1 = (aXn + c) mod m, where n >= 0

    a = 0x5DEECE66D,
    c = 0xB
    m = 2**48

It delivers results identical to the lrand48() function that is available on some systems.

Definition at line 59 of file Rand48.H.

Member Typedef Documentation

◆ result_type

typedef uint32_t result_type

The type of the generated random value.

Definition at line 88 of file Rand48.H.

Constructor & Destructor Documentation

◆ Rand48()

Rand48 ( uint32_t  val = default_seed)
inlineexplicit

Construct with specified or default seed.

Definition at line 97 of file Rand48.H.

Member Function Documentation

◆ min()

static constexpr uint32_t min ( )
inlinestaticconstexpr

The smallest value that the generator can produce.

Definition at line 106 of file Rand48.H.

◆ max()

static constexpr uint32_t max ( )
inlinestaticconstexpr

The largest value that the generator can produce.

Definition at line 109 of file Rand48.H.

◆ seed()

void seed ( uint32_t  val = default_seed)
inline

Reseed the generator.

Definition at line 112 of file Rand48.H.

Referenced by Random::Random().

Here is the caller graph for this function:

◆ discard()

void discard ( unsigned long long  z)
inline

Advance the state of the generator by z notches.

Definition at line 118 of file Rand48.H.

◆ raw()

uint64_t raw ( )
inline

Get the next random number in the sequence and return its raw 48-bit value

Definition at line 125 of file Rand48.H.

◆ operator()()

uint32_t operator() ( )
inline

Get the next random number in the sequence.

Definition at line 134 of file Rand48.H.

Member Data Documentation

◆ default_seed

constexpr result_type default_seed = 1u
staticconstexpr

The default seed.

Definition at line 91 of file Rand48.H.


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