VoronoiGrowthSimulator
Based on Site Saturated Nucleation and Isotropic Growth
|
A class that represents a random number generator engine. More...
#include <MTEngine.hpp>
Public Member Functions | |
MTEngine () | |
Constructs an instance of the MTEngine class. | |
MTEngine (long long myseed) | |
Constructs an instance of the MTEngine class with the specified seed. | |
void | reseed () |
void | randomseed () |
void | setseed (long long myseed) |
double | rand () |
double | randn () |
double | randn (double mean, double var) |
double | choice (double a, double b) |
double | choice (double a, double b, double c) |
template<typename T , typename... Args> | |
T | Choice (T Start, Args... args) |
template<typename T > | |
T | choice (T A, T B) |
double | choice (std::vector< double > A, std::vector< double > PDF) |
std::vector< double > | rand (int m) |
std::vector< double > | randn (int m) |
std::vector< std::vector< double > > | rand (int m, int n) |
std::vector< std::vector< double > > | randn (int m, int n) |
std::vector< double > | rand (double a, double b, int p) |
double | rand (double a, double b) |
int | randint (int a, int b) |
std::vector< int > | randint (int a, int b, int p, bool repeatation=false) |
std::vector< std::vector< int > > | randint (int xmin, int xmax, int ymin, int ymax, int p, bool repeatation=false) |
std::vector< std::array< double, 3 > > | randint (int xmin, int xmax, int ymin, int ymax, int zmin, int zmax, int p, bool repeatation=false) |
std::vector< int > | sequence (int a, int b) |
std::vector< int > | ones (int n) |
template<class T > | |
void | Shuffle (std::vector< T > &X) |
Public Attributes | |
long long | wasseededwith |
A class that represents a random number generator engine.
The MTEngine class provides various methods for generating random numbers and sequences. It is based on the Mersenne Twister algorithm (mt19937_64).
Definition at line 21 of file MTEngine.hpp.
MTEngine::MTEngine | ( | ) |
Constructs an instance of the MTEngine class.
This constructor initializes the random number generator (RNG) of the MTEngine object. It uses the current time as the seed for the RNG.
Definition at line 32 of file MTEngine.cpp.
MTEngine::MTEngine | ( | long long | myseed | ) |
Constructs an instance of the MTEngine class with the specified seed.
This constructor initializes the random number generator (RNG) with the given seed. The seed is used to determine the initial state of the RNG, which affects the sequence of random numbers generated by the engine.
myseed | The seed value to initialize the RNG. |
Definition at line 15 of file MTEngine.cpp.
double MTEngine::choice | ( | double | a, |
double | b ) |
Returns a random choice between two given values.
a | The first value. |
b | The second value. |
a
and b
. Definition at line 97 of file MTEngine.cpp.
double MTEngine::choice | ( | double | a, |
double | b, | ||
double | c ) |
Returns one of the three input values randomly based on a uniform distribution.
a | The first input value. |
b | The second input value. |
c | The third input value. |
Definition at line 119 of file MTEngine.cpp.
double MTEngine::choice | ( | std::vector< double > | A, |
std::vector< double > | PDF ) |
Returns a random choice from the given set of options based on the provided probability distribution.
A | The set of options to choose from. |
The probability distribution corresponding to each option. |
Definition at line 148 of file MTEngine.cpp.
|
inline |
Makes a random choice between two values.
A | The first value to choose from. |
B | The second value to choose from. |
Definition at line 82 of file MTEngine.hpp.
|
inline |
Returns a randomly chosen element from a list of arguments.
Start | The first element in the list. |
args | The remaining elements in the list. |
std::runtime_error | if no match is found. |
Definition at line 100 of file MTEngine.hpp.
vector< int > MTEngine::ones | ( | int | n | ) |
Returns a vector of size n with all elements set to 1.
n | The size of the vector. |
Definition at line 520 of file MTEngine.cpp.
double MTEngine::rand | ( | ) |
Generates a random double value between 0 and 1 using the Mersenne Twister engine.
Definition at line 84 of file MTEngine.cpp.
double MTEngine::rand | ( | double | a, |
double | b ) |
Generates a random number between the given range [a, b].
a | The lower bound of the range. |
b | The upper bound of the range. |
Definition at line 320 of file MTEngine.cpp.
vector< double > MTEngine::rand | ( | double | a, |
double | b, | ||
int | p ) |
Generates a vector of random double values within the specified range.
a | The lower bound of the range. |
b | The upper bound of the range. |
p | The number of random values to generate. |
Definition at line 294 of file MTEngine.cpp.
vector< double > MTEngine::rand | ( | int | m | ) |
Generates a vector of random numbers between 0 and 1 using a uniform distribution.
m | The number of random numbers to generate. |
Definition at line 210 of file MTEngine.cpp.
vector< vector< double > > MTEngine::rand | ( | int | m, |
int | n ) |
Generates a random matrix of size m x n.
m | The number of rows in the matrix. |
n | The number of columns in the matrix. |
Definition at line 247 of file MTEngine.cpp.
int MTEngine::randint | ( | int | a, |
int | b ) |
Generates a random integer between the specified range [a, b].
a | The lower bound of the range. |
b | The upper bound of the range. |
Definition at line 334 of file MTEngine.cpp.
vector< int > MTEngine::randint | ( | int | a, |
int | b, | ||
int | p, | ||
bool | repeatation = false ) |
Generates a vector of random integers within a specified range.
a | The lower bound of the range (inclusive). |
b | The upper bound of the range (inclusive). |
p | The number of random integers to generate. |
repeatation | Determines whether repeated values are allowed in the generated vector. If set to true, repeated values are allowed; otherwise, each value in the vector will be unique. |
Definition at line 351 of file MTEngine.cpp.
vector< vector< int > > MTEngine::randint | ( | int | xmin, |
int | xmax, | ||
int | ymin, | ||
int | ymax, | ||
int | p, | ||
bool | repeatation = false ) |
Generates a 2D vector of random integers within specified ranges.
xmin | The minimum value for the x-coordinate. |
xmax | The maximum value for the x-coordinate. |
ymin | The minimum value for the y-coordinate. |
ymax | The maximum value for the y-coordinate. |
p | The number of points to generate. |
repeatation | Determines whether repeated points are allowed or not. |
Definition at line 393 of file MTEngine.cpp.
vector< std::array< double, 3 > > MTEngine::randint | ( | int | xmin, |
int | xmax, | ||
int | ymin, | ||
int | ymax, | ||
int | zmin, | ||
int | zmax, | ||
int | p, | ||
bool | repeatation = false ) |
Generates a vector of random points within specified ranges.
xmin | The minimum value for the x-coordinate. |
xmax | The maximum value for the x-coordinate. |
ymin | The minimum value for the y-coordinate. |
ymax | The maximum value for the y-coordinate. |
zmin | The minimum value for the z-coordinate. |
zmax | The maximum value for the z-coordinate. |
p | The number of points to generate. |
repeatation | Determines whether repeated points are allowed. |
Definition at line 448 of file MTEngine.cpp.
double MTEngine::randn | ( | ) |
Generates a random number from a normal distribution with mean 0 and standard deviation 1.
Definition at line 186 of file MTEngine.cpp.
double MTEngine::randn | ( | double | mean, |
double | var ) |
Generates a random number from a normal distribution with the specified mean and variance.
mean | The mean of the normal distribution. |
var | The variance of the normal distribution. |
Definition at line 199 of file MTEngine.cpp.
vector< double > MTEngine::randn | ( | int | m | ) |
Generates a vector of random numbers from a standard normal distribution.
m | The number of random numbers to generate. |
Definition at line 228 of file MTEngine.cpp.
vector< vector< double > > MTEngine::randn | ( | int | m, |
int | n ) |
Generates a matrix of random numbers from a standard normal distribution.
m | The number of rows in the matrix. |
n | The number of columns in the matrix. |
Definition at line 270 of file MTEngine.cpp.
void MTEngine::randomseed | ( | ) |
Seeds the random number generator with a random value based on the current time. This function uses the high-resolution clock to generate a seed value. The generated seed is then used to seed the random number generator. The seed value is also stored in the wasseededwith
member variable.
Definition at line 59 of file MTEngine.cpp.
void MTEngine::reseed | ( | ) |
Reseeds the random number generator with the specified seed value.
None |
Definition at line 48 of file MTEngine.cpp.
vector< int > MTEngine::sequence | ( | int | a, |
int | b ) |
Generates a sequence of integers between 'a' and 'b'.
a | The starting value of the sequence. |
b | The ending value of the sequence. |
Definition at line 501 of file MTEngine.cpp.
void MTEngine::setseed | ( | long long | myseed | ) |
Sets the seed for the random number generator used by the MTEngine.
myseed | The seed value to set for the random number generator. |
Definition at line 73 of file MTEngine.cpp.
|
inline |
Shuffles the elements in the given vector using the random number generator.
X | The vector to be shuffled. |
Definition at line 67 of file MTEngine.hpp.
long long MTEngine::wasseededwith |
Definition at line 29 of file MTEngine.hpp.