18 #ifndef itkMersenneTwisterRandomVariateGenerator_h
19 #define itkMersenneTwisterRandomVariateGenerator_h
168 double GetVariateWithClosedRange();
171 double GetVariateWithClosedRange(
const double & n);
174 double GetVariateWithOpenUpperRange();
177 double GetVariateWithOpenUpperRange(
const double & n);
180 double GetVariateWithOpenRange();
183 double GetVariateWithOpenRange(
const double & n);
193 double Get53BitVariate();
197 double GetNormalVariate(
const double & mean = 0.0,
198 const double & variance = 1.0);
202 double GetUniformVariate(
const double & a,
const double & b);
209 virtual double GetVariate() ITK_OVERRIDE;
219 inline
void SetSeed();
243 virtual ~MersenneTwisterRandomVariateGenerator() ITK_OVERRIDE;
244 virtual
void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
247 itkStaticConstMacro(M,
unsigned int, 397);
257 return hiBit(u) | loBits(v);
262 return m ^ ( mixBits(s0, s1) >> 1 ) ^ ( -static_cast<int32_t>(loBit(s1)) & 0x9908b0df );
265 static IntegerType hash(time_t t, clock_t c);
282 static Pointer CreateInstance();
309 *s++ = seed & 0xffffffffUL;
312 *s++ = ( 1812433253UL * ( *r ^ ( *r >> 30 ) ) + i ) & 0xffffffffUL;
326 int index =
static_cast< int >(
334 *p =
twist(p[
M], p[0], p[1]);
336 for ( i =
M; --i; ++p )
338 *p =
twist(p[index], p[0], p[1]);
385 s1 ^= ( s1 << 7 ) & 0x9d2c5680;
386 s1 ^= ( s1 << 15 ) & 0xefc60000;
387 return ( s1 ^ ( s1 >> 18 ) );
465 return ( a * 67108864.0 + b ) * ( 1.0 / 9007199254740992.0 );
473 const double & mean,
const double & variance)
482 return mean + r *std::cos(phi);
489 const double & a,
const double & b)
493 return ( ( 1.0 - u ) * a + u * b );
double GetVariateWithOpenRange()
Critical section locking class that can be allocated on the stack.
SmartPointer< Self > Pointer
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