Utility::Rng Class ReferenceThe Mersenne Twister http://www.math.keio.ac.jp/~matumoto/emt.html. More...
Detailed DescriptionThe Mersenne Twister http://www.math.keio.ac.jp/~matumoto/emt.html.Definition at line 57 of file Utility.h. Constructor & Destructor Documentation
Member Function Documentation
Definition at line 1079 of file Utility.cpp. References m_tmp, m_value, MAGIC_TWIST, TWIST, TWIST_IA, TWIST_IB, and TWIST_LEN. Referenced by Utility::Rnd(). 01080 { 01081 unsigned long val = m_tmp[m_value]; 01082 ++m_value; 01083 if (m_value == TWIST_LEN) 01084 { 01085 for (int i = 0; i < TWIST_IB; ++i) 01086 { 01087 unsigned long s = TWIST(m_tmp, i, i + 1); 01088 m_tmp[i] = m_tmp[i + TWIST_IA] ^ (s >> 1) ^ MAGIC_TWIST(s); 01089 } 01090 { 01091 for (int i = 0; i < TWIST_LEN - 1; ++i) 01092 { 01093 unsigned long s = TWIST(m_tmp, i, i + 1); 01094 m_tmp[i] = m_tmp[i - TWIST_IB] ^ (s >> 1) ^ MAGIC_TWIST(s); 01095 } 01096 } 01097 unsigned long s = TWIST(m_tmp, TWIST_LEN - 1, 0); 01098 m_tmp[TWIST_LEN - 1] = m_tmp[TWIST_IA - 1] ^ (s >> 1) ^ MAGIC_TWIST(s); 01099 01100 m_value = 0; 01101 } 01102 return val; 01103 }
Member Data Documentation
The documentation for this class was generated from the following files: | |||||||||||||||||||||||||||
1.4.4