Vital
Loading...
Searching...
No Matches
vital::utils::RandomGenerator Class Reference

A basic random number generator for producing uniform distributions of floats. More...

#include <utils.h>

Public Member Functions

 RandomGenerator (mono_float min, mono_float max)
 Constructs a RandomGenerator with specified min and max values.
 
 RandomGenerator (const RandomGenerator &other)
 Copy constructor, but it re-seeds the engine for uniqueness.
 
force_inline mono_float next ()
 Returns the next random float in [min, max].
 
force_inline poly_float polyNext ()
 Produces a poly_float with random values in each lane.
 
force_inline poly_float polyVoiceNext ()
 Produces a poly_float with random values assigned in pairs (every 2 lanes share the same random value).
 
force_inline poly_float polyNext (poly_mask mask)
 Produces a poly_float of random values, only generated for lanes set in mask.
 
force_inline void seed (int new_seed)
 Reseeds the internal random engine with new_seed.
 

Static Public Attributes

static int next_seed_ = 0
 Static seed counter used to automatically assign seeds if none specified.
 

Detailed Description

A basic random number generator for producing uniform distributions of floats.

It uses an internal Mersenne Twister (std::mt19937) and a uniform distribution between given min and max values.

Constructor & Destructor Documentation

◆ RandomGenerator() [1/2]

vital::utils::RandomGenerator::RandomGenerator ( mono_float min,
mono_float max )
inline

Constructs a RandomGenerator with specified min and max values.

Parameters
minThe minimum floating-point value (inclusive).
maxThe maximum floating-point value (inclusive).

◆ RandomGenerator() [2/2]

vital::utils::RandomGenerator::RandomGenerator ( const RandomGenerator & other)
inline

Copy constructor, but it re-seeds the engine for uniqueness.

Parameters
otherAnother RandomGenerator to copy min/max from.

Member Function Documentation

◆ next()

force_inline mono_float vital::utils::RandomGenerator::next ( )
inline

Returns the next random float in [min, max].

◆ polyNext() [1/2]

force_inline poly_float vital::utils::RandomGenerator::polyNext ( )
inline

Produces a poly_float with random values in each lane.

Returns
A poly_float of random values (one random value per lane).

◆ polyNext() [2/2]

force_inline poly_float vital::utils::RandomGenerator::polyNext ( poly_mask mask)
inline

Produces a poly_float of random values, only generated for lanes set in mask.

Parameters
maskA poly_mask indicating which lanes need new random values.
Returns
A poly_float with random values in masked lanes, zero in others.

◆ polyVoiceNext()

force_inline poly_float vital::utils::RandomGenerator::polyVoiceNext ( )
inline

Produces a poly_float with random values assigned in pairs (every 2 lanes share the same random value).

Returns
A poly_float of random values in pairs.

◆ seed()

force_inline void vital::utils::RandomGenerator::seed ( int new_seed)
inline

Reseeds the internal random engine with new_seed.

Parameters
new_seedThe new seed to use.

Member Data Documentation

◆ next_seed_

int vital::utils::RandomGenerator::next_seed_ = 0
static

Static seed counter used to automatically assign seeds if none specified.

Initializes the static seed counter for RandomGenerator.


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