67 #define __STDC_LIMIT_MACROS 70 #include <visp3/core/vpUniRand.h> 73 m_maxInvDbl(1.0 / UINT32_MAX), m_maxInvFlt(1.0f / UINT32_MAX), m_rng()
86 m_maxInvDbl(1.0 / UINT32_MAX), m_maxInvFlt(1.0f / UINT32_MAX), m_rng()
112 uint32_t vpUniRand::boundedRand(uint32_t bound)
128 uint32_t threshold = -bound % bound;
139 if (r >= threshold) {
151 uint64_t oldstate = m_rng.state;
152 m_rng.state = oldstate * 6364136223846793005ULL + m_rng.inc;
153 uint32_t xorshifted =
static_cast<uint32_t
>(((oldstate >> 18u) ^ oldstate) >> 27u);
154 uint32_t rot = oldstate >> 59u;
155 return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
168 return boundedRand(b - a) + a;
178 return next()*m_maxInvFlt*(b - a) + a;
188 return next()*m_maxInvDbl*(b - a) + a;
215 m_rng.inc = (initseq << 1u) | 1u;
217 m_rng.state += initstate;
void setSeed(uint64_t initstate, uint64_t initseq)
int uniform(int a, int b)