|
class | blaze::Random< Type > |
| Random number generator.The Random class encapsulates the initialization of the given random number generator with a pseudo-random seed obtained by the std::time() function. Currently, the mersenne-twister mt19937 as provided by the C++ standard library is used per default. For more information see the for instance the following documentation of the random number functionality of the C++11 standard library: More...
|
|
class | blaze::Rand< T > |
| Default implementation of the Rand class for integral data types.This default implementation of the Rand class creates random, integral numbers in the range , where max is the maximal value of the given data type T. More...
|
|
The random number module provides the functionality to generate pseudo-random numbers within the Blaze library. In order to create series of random numbers, the following functions are are provided:
The templated rand() function is capable of generating random numbers for built-in integer and floating point data types as well as complex values. The rand() function can be given up to five parameters that depending on the type of the random number may have different meaning. The following example demonstrates the random number generation:
int i = rand<int>();
double d = rand<double>( 2.0, 4.0 );
- Note
- In order to reproduce certain series of random numbers, the seed of the random number generator has to be set explicitly via the setSeed() function. Otherwise a random seed is used for the random number generation.
uint32_t blaze::defaultSeed |
( |
| ) |
|
|
inline |
Returns the default random seed.
- Returns
- The default random seed.
uint32_t blaze::getSeed |
( |
| ) |
|
|
inline |
Returns the current seed of the random number generator.
- Returns
- The current seed of the random number generator.
template<typename T , typename... Args>
T blaze::rand |
( |
Args &&... |
args | ) |
|
|
inline |
Random number function.
- Parameters
-
args | The arguments for the random number generation. |
- Returns
- The generated random number.
This rand() function creates a random number based on the given arguments args.
template<typename T >
void blaze::randomize |
( |
T & |
value | ) |
|
|
inline |
template<typename T , typename... Args>
void blaze::randomize |
( |
T & |
value, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Randomization of a given variable.
- Parameters
-
value | The value to be randomized. |
args | The arguments for the random number generation. |
- Returns
- void
This randomize() function randomizes the given variable based on the given arguments args.
Setting the seed of the random number generator.
- Parameters
-
seed | The new seed for the random number generator. |
- Returns
- void
This function can be used to set the seed for the random number generation in order to create a reproducible series of random numbers.