33#include <NDEVR/BaseValues.h>
58 template<
class t_type>
61 static std::mt19937 rng(rand());
62 std::uniform_int_distribution<t_type> gen(0, max);
122 template<
class t_type>
125 lib_assert(min <= max,
"Random generation min value must be less than or equal to max");
129 template<s
int04 ia = 16807, s
int04 im = 2147483647, s
int04 iq = 127773, s
int04 ir = 2836, s
int04 ntab = 32>
145 fltp08 ntiv = (1 + (im - 1) / ntab);
152 if (idum <= 0 || !iy)
158 for (j = ntab + 7; j >= 0; j--)
161 idum = ia * (idum - k * iq) - ir * k;
170 idum = ia * (idum - k * iq) - ir * k;
176 if ((temp = am * iy) > 1 - eps)
185 double fac, rsq, v1, v2;
191 v1 = 2.0 *
ran1(idum) - 1.0;
192 v2 = 2.0 *
ran1(idum) - 1.0;
193 rsq = v1*v1 + v2 * v2;
195 while (rsq >= 1.0 || rsq == 0.0);
197 fac =
sqrt(-2.0 * log(rsq) / rsq);
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
fltp08 gasdev()
Definition Random.h:137
fltp08 ran1(sint08 &idum)
Definition Random.h:142
fltp08 gasdev(sint08 &idum)
Definition Random.h:181
GaussianRN(sint08 didum)
Definition Random.h:133
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:86
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
t_type getRandom(t_type max)
Returns a pseudo-random number between 0 and the associated max value.
Definition Random.h:59
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1309
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition BaseValues.hpp:272