18#ifndef itkMersenneTwisterRandomVariateGenerator_h
19#define itkMersenneTwisterRandomVariateGenerator_h
125struct MersenneTwisterGlobals;
181 GetVariateWithClosedRange();
185 GetVariateWithClosedRange(
const double n);
189 GetVariateWithOpenUpperRange();
193 GetVariateWithOpenUpperRange(
const double n);
197 GetVariateWithOpenRange();
201 GetVariateWithOpenRange(
const double n);
219 GetNormalVariate(
const double mean = 0.0,
const double variance = 1.0);
224 GetUniformVariate(
const double a,
const double b);
232 GetVariate()
override;
276 static constexpr unsigned int M = 397;
285 return u & 0x80000000;
290 return u & 0x00000001;
295 return u & 0x7fffffff;
300 return hiBit(u) | loBits(v);
306 return m ^ (mixBits(s0, s1) >> 1) ^ (-
static_cast<int32_t
>(loBit(s1)) & 0x9908b0df);
322 std::atomic<IntegerType> m_Seed{};
333 std::mutex m_InstanceMutex{};
356 *s++ = seed & 0xffffffffUL;
359 *s++ = (1812433253UL * (*r ^ (*r >> 30)) + i) & 0xffffffffUL;
380 *p =
twist(p[
M], p[0], p[1]);
382 for (i =
M; --i; ++p)
384 *p =
twist(p[index], p[0], p[1]);
432 s1 ^= (s1 << 7) & 0x9d2c5680;
433 s1 ^= (s1 << 15) & 0xefc60000;
434 return (s1 ^ (s1 >> 18));
507 return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
522 return mean + r * std::cos(phi);
532 return ((1.0 - u) * a + u * b);
Control indentation during Print() invocation.
Light weight base class for most itk classes.
MersenneTwisterRandom random variate generator.
IntegerType state[StateVectorLength]
std::atomic< IntegerType > m_Seed
IntegerType loBits(const IntegerType &u) const
double GetUniformVariate(const double a, const double b)
IntegerType GetIntegerVariate()
IntegerType mixBits(const IntegerType &u, const IntegerType &v) const
static Pointer New()
Method for creation through the object factory.
static Pointer GetInstance()
static constexpr unsigned int M
void PrintSelf(std::ostream &os, Indent indent) const override
IntegerType twist(const IntegerType &m, const IntegerType &s0, const IntegerType &s1) const
double GetVariateWithOpenRange()
IntegerType loBit(const IntegerType &u) const
static IntegerType GetNextSeed()
static IntegerType hash(time_t t, clock_t c)
IntegerType GetSeed() const
~MersenneTwisterRandomVariateGenerator() override
static void ResetNextSeed()
itkGetGlobalDeclarationMacro(MersenneTwisterGlobals, PimplGlobals)
double GetVariateWithClosedRange()
double GetVariateWithOpenUpperRange()
static Pointer CreateInstance()
static MersenneTwisterGlobals * m_PimplGlobals
IntegerType hiBit(const IntegerType &u) const
double GetVariate() override
double GetNormalVariate(const double mean=0.0, const double variance=1.0)
MersenneTwisterRandomVariateGenerator()
static constexpr IntegerType StateVectorLength
std::mutex m_InstanceMutex
Defines common interfaces for random variate generators.
static constexpr double pi
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....