33#include <NDEVR/BaseValues.h>
54 template<
class t_type>
57 static thread_local std::mt19937 rng(std::random_device{}());
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>
131 : m_idum(didum > 0 ? -didum : didum)
151 fltp08 ntiv = (1 + (im - 1) / ntab);
157 if (idum <= 0 || !iy)
163 for (j = ntab + 7; j >= 0; j--)
166 idum = ia * (idum - k * iq) - ir * k;
175 idum = ia * (idum - k * iq) - ir * k;
181 if ((temp = am * iy) > 1 - m_eps)
193 double fac, rsq, v1, v2;
199 v1 = 2.0 *
ran1(idum) - 1.0;
200 v2 = 2.0 *
ran1(idum) - 1.0;
201 rsq = v1*v1 + v2 * v2;
203 while (rsq >= 1.0 || rsq == 0.0);
205 fac =
sqrt(-2.0 * log(rsq) / rsq);
Used to generate a random number over a Gaussian distribution with templated setup parameters for ver...
fltp08 get()
Generates the next Gaussian-distributed random number.
GaussianRN(sint08 didum)
Constructs a Gaussian random number generator with the given seed.
fltp08 gasdev(sint08 &idum)
Generates a Gaussian-distributed random number using the Box-Muller transform.
fltp08 ran1(sint08 &idum)
Generates a uniform random number in the range [0, 1) using a Park-Miller minimal standard generator.
Dummy class for including random number generator functions.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
t_type MakeRandom(t_type max)
Returns a pseudo-random number between 0 and the associated max value.
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
t_type sqrt(const t_type &value)
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.