Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
Namespaces | Functions
mc::rng Namespace Reference

Namespaces

namespace  detail
 

Functions

std::mt19937 make_engine (std::uint64_t stream_id=0)
 Create a deterministic RNG engine for a specific stream.
 
std::mt19937 make_thread_engine (std::uint64_t stream_id=0)
 Create a deterministic RNG engine for the current thread (OpenMP if available)
 
std::mt19937 make_engine_with_seed (std::optional< std::uint32_t > base_seed, std::uint64_t stream_id)
 Create a deterministic RNG engine with explicit seed override (optional)
 
bool set_global_seed (std::uint32_t s)
 Set the global seed used by all library RNG components.
 
std::uint32_t get_global_seed ()
 Get the current global seed.
 
bool is_global_seed_initialized ()
 Check whether the global seed has been explicitly initialized.
 

Function Documentation

◆ get_global_seed()

std::uint32_t mc::rng::get_global_seed ( )

Get the current global seed.

Returns
The current global seed value.

Thread-safe.

Definition at line 32 of file rng_global.cpp.

◆ is_global_seed_initialized()

bool mc::rng::is_global_seed_initialized ( )

Check whether the global seed has been explicitly initialized.

Returns
true if set_global_seed() was successfully called.

Definition at line 36 of file rng_global.cpp.

◆ make_engine()

std::mt19937 mc::rng::make_engine ( std::uint64_t  stream_id = 0)

Create a deterministic RNG engine for a specific stream.

Parameters
stream_idUnique identifier for this RNG stream (default: 0)
Returns
std::mt19937 engine seeded deterministically

Definition at line 70 of file rng_factory.cpp.

Here is the call graph for this function:

◆ make_engine_with_seed()

std::mt19937 mc::rng::make_engine_with_seed ( std::optional< std::uint32_t >  base_seed,
std::uint64_t  stream_id 
)

Create a deterministic RNG engine with explicit seed override (optional)

Parameters
base_seedIf provided, used instead of global seed; otherwise global seed is used
stream_idUnique identifier for this RNG stream
Returns
std::mt19937 engine seeded deterministically

This avoids the anti-pattern "seed==0 means fallback", since 0 is a valid seed.

Definition at line 88 of file rng_factory.cpp.

Here is the call graph for this function:

◆ make_thread_engine()

std::mt19937 mc::rng::make_thread_engine ( std::uint64_t  stream_id = 0)

Create a deterministic RNG engine for the current thread (OpenMP if available)

Parameters
stream_idAdditional stream identifier (default: 0)
Returns
std::mt19937 engine seeded deterministically based on thread and stream

If OpenMP is not enabled, falls back to thread_id = 0.

Definition at line 76 of file rng_factory.cpp.

Here is the call graph for this function:

◆ set_global_seed()

bool mc::rng::set_global_seed ( std::uint32_t  s)

Set the global seed used by all library RNG components.

This function can be called ONLY ONCE.

Parameters
sThe seed value to use.
Returns
true if the seed was successfully set, false if the seed was already initialized.

Thread-safe. If the seed has already been set, the call has no effect.

Definition at line 16 of file rng_global.cpp.