18 #ifndef itkMersenneTwisterRandomVariateGenerator_h
19 #define itkMersenneTwisterRandomVariateGenerator_h
160 double GetVariateWithClosedRange();
163 double GetVariateWithClosedRange(
const double & n);
166 double GetVariateWithOpenUpperRange();
169 double GetVariateWithOpenUpperRange(
const double & n);
172 double GetVariateWithOpenRange();
175 double GetVariateWithOpenRange(
const double & n);
185 double Get53BitVariate();
189 double GetNormalVariate(
const double & mean = 0.0,
190 const double & variance = 1.0);
194 double GetUniformVariate(
const double & a,
const double & b);
201 virtual double GetVariate() ITK_OVERRIDE;
211 inline
void SetSeed();
235 virtual ~MersenneTwisterRandomVariateGenerator();
236 virtual
void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
239 itkStaticConstMacro(M,
unsigned int, 397);
249 return hiBit(u) | loBits(v);
254 return m ^ ( mixBits(s0, s1) >> 1 ) ^ ( -static_cast<int32_t>(loBit(s1)) & 0x9908b0df );
257 static IntegerType hash(time_t t, clock_t c);
274 static Pointer CreateInstance();
301 *s++ = seed & 0xffffffffUL;
304 *s++ = ( 1812433253UL * ( *r ^ ( *r >> 30 ) ) + i ) & 0xffffffffUL;
318 int index =
static_cast< int >(
326 *p =
twist(p[
M], p[0], p[1]);
328 for ( i =
M; --i; ++p )
330 *p =
twist(p[index], p[0], p[1]);
377 s1 ^= ( s1 << 7 ) & 0x9d2c5680;
378 s1 ^= ( s1 << 15 ) & 0xefc60000;
379 return ( s1 ^ ( s1 >> 18 ) );
457 return ( a * 67108864.0 + b ) * ( 1.0 / 9007199254740992.0 );
465 const double & mean,
const double & variance)
474 return mean + r *std::cos(phi);
481 const double & a,
const double & b)
485 return ( ( 1.0 - u ) * a + u * b );
double GetVariateWithOpenRange()
Critical section locking class that can be allocated on the stack.
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< Self > Pointer
virtual void Initialize()
MersenneTwisterRandom random variate generator.
static SimpleFastMutexLock m_StaticInstanceLock
A container to store a Mutex. This holder class for ensuring that locks are released in the event of ...
IntegerType GetIntegerVariate()
static ITK_CONSTEXPR_VAR double pi
IntegerType loBits(const IntegerType &u) const
KWIML_INT_uint32_t uint32_t
IntegerType mixBits(const IntegerType &u, const IntegerType &v) const
static Pointer m_StaticInstance
SimpleFastMutexLock m_InstanceLock
double GetUniformVariate(const double &a, const double &b)
RandomVariateGeneratorBase Superclass
double GetVariateWithClosedRange()
Defines common interfaces for random variate generators.
static const IntegerType StateVectorLength
IntegerType state[StateVectorLength]
IntegerType twist(const IntegerType &m, const IntegerType &s0, const IntegerType &s1) const
double GetNormalVariate(const double &mean=0.0, const double &variance=1.0)
virtual double GetVariate() override
static const unsigned int M
Control indentation during Print() invocation.
double GetVariateWithOpenUpperRange()
SmartPointer< const Self > ConstPointer
MersenneTwisterRandomVariateGenerator Self
static IntegerType m_StaticDiffer
static IntegerType hash(time_t t, clock_t c)
IntegerType loBit(const IntegerType &u) const