Loading...
Searching...
No Matches
Rand48 Class Reference

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

#include <Rand48.H>

Public Types

typedef uint32_t result_type
 The type of the generated random value.

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static constexpr result_type default_seed = 1u
 The default seed.

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 53 of file Rand48.H.

Member Typedef Documentation

◆ result_type

typedef uint32_t result_type

The type of the generated random value.

Definition at line 90 of file Rand48.H.

Constructor & Destructor Documentation

◆ Rand48()

Rand48 ( uint32_t val = default_seed)
inlineexplicit

Construct with specified or default seed.

Definition at line 103 of file Rand48.H.

References default_seed.

Member Function Documentation

◆ min()

constexpr uint32_t min ( )
inlinestaticconstexpr

The smallest value that the generator can produce.

Definition at line 114 of file Rand48.H.

◆ max()

constexpr uint32_t max ( )
inlinestaticconstexpr

The largest value that the generator can produce.

Definition at line 119 of file Rand48.H.

◆ seed()

void seed ( uint32_t val = default_seed)
inline

Reseed the generator.

Definition at line 124 of file Rand48.H.

References default_seed.

◆ discard()

void discard ( unsigned long long z)
inline

Advance the state of the generator by z notches.

Definition at line 132 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 141 of file Rand48.H.

◆ operator()()

uint32_t operator() ( )
inline

Get the next random number in the sequence.

Definition at line 152 of file Rand48.H.

Member Data Documentation

◆ default_seed

result_type default_seed = 1u
staticconstexpr

The default seed.

Definition at line 95 of file Rand48.H.

Referenced by Rand48(), and seed().


The documentation for this class was generated from the following file:
  • src/OpenFOAM/primitives/random/Random/Rand48.H