18 #ifndef __itkMersenneTwisterRandomVariateGenerator_h
19 #define __itkMersenneTwisterRandomVariateGenerator_h
25 #include "vnl/vnl_math.h"
149 double GetVariateWithClosedRange();
152 double GetVariateWithClosedRange(
const double & n);
155 double GetVariateWithOpenUpperRange();
158 double GetVariateWithOpenUpperRange(
const double & n);
161 double GetVariateWithOpenRange();
164 double GetVariateWithOpenRange(
const double & n);
174 double Get53BitVariate();
178 double GetNormalVariate(
const double & mean = 0.0,
179 const double & variance = 1.0);
183 double GetUniformVariate(
const double & a,
const double & b);
190 virtual double GetVariate() ITK_OVERRIDE;
197 inline
void SetSeed();
212 virtual void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
215 itkStaticConstMacro (M,
unsigned int, 397);
231 return hiBit(u) | loBits(v);
236 return m ^ ( mixBits(s0, s1) >> 1 ) ^ ( -static_cast<int32_t>(loBit(s1)) & 0x9908b0df );
239 static IntegerType hash(time_t t, clock_t c);
244 static Pointer CreateInstance();
267 *s++ = seed & 0xffffffffUL;
270 *s++ = ( 1812433253UL * ( *r ^ ( *r >> 30 ) ) + i ) & 0xffffffffUL;
283 int index =
static_cast< int >(
291 *p =
twist(p[
M], p[0], p[1]);
293 for ( i =
M; --i; ++p )
295 *p =
twist(p[index], p[0], p[1]);
333 s1 ^= ( s1 << 7 ) & 0x9d2c5680;
334 s1 ^= ( s1 << 15 ) & 0xefc60000;
335 return ( s1 ^ ( s1 >> 18 ) );
414 return ( a * 67108864.0 + b ) * ( 1.0 / 9007199254740992.0 );
422 const double & mean,
const double & variance)
430 return mean + r *std::cos(phi);
437 const double & a,
const double & b)
441 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
virtual double GetVariate() ITK_OVERRIDE
IntegerType GetIntegerVariate()
IntegerType loBits(const IntegerType &u) const
IntegerType mixBits(const IntegerType &u, const IntegerType &v) const
static Pointer m_StaticInstance
double GetUniformVariate(const double &a, const double &b)
RandomVariateGeneratorBase Superclass
virtual ~MersenneTwisterRandomVariateGenerator()
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
typedef::itksysFundamentalType_UInt32 uint32_t
double GetNormalVariate(const double &mean=0.0, const double &variance=1.0)
static const unsigned int M
Control indentation during Print() invocation.
IntegerType hiBit(const IntegerType &u) const
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