33#include <NDEVR/BaseValues.h>
54 template<
class t_type>
57 static std::mt19937 rng(rand());
58 std::uniform_int_distribution<t_type> gen(0, max);
112 template<
class t_type>
115 lib_assert(min <= max,
"Random generation min value must be less than or equal to max");
122 template<s
int04 ia = 16807, s
int04 im = 2147483647, s
int04 iq = 127773, s
int04 ir = 2836, s
int04 ntab = 32>
138 fltp08 ntiv = (1 + (im - 1) / ntab);
145 if (idum <= 0 || !iy)
151 for (j = ntab + 7; j >= 0; j--)
154 idum = ia * (idum - k * iq) - ir * k;
163 idum = ia * (idum - k * iq) - ir * k;
169 if ((temp = am * iy) > 1 - eps)
178 double fac, rsq, v1, v2;
184 v1 = 2.0 *
ran1(idum) - 1.0;
185 v2 = 2.0 *
ran1(idum) - 1.0;
186 rsq = v1*v1 + v2 * v2;
188 while (rsq >= 1.0 || rsq == 0.0);
190 fac =
sqrt(-2.0 * log(rsq) / rsq);
#define lib_assert(expression, message)
Definition LibAssert.h:61
Used to generate a random number over a Gaussian distribution with templated setup parameters for ver...
Definition Random.h:124
fltp08 gasdev()
Definition Random.h:130
fltp08 ran1(sint08 &idum)
Definition Random.h:135
fltp08 gasdev(sint08 &idum)
Definition Random.h:174
GaussianRN(sint08 didum)
Definition Random.h:126
Dummy class for including random number generator functions.
Definition Random.h:41
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:71
t_type MakeRandom(t_type max)
Returns a pseudo-random number between 0 and the associated max value.
Definition Random.h:55
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1225
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233