![]() |
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 59 of file Utility.h. Constructor & Destructor Documentation
Member Function Documentation
Definition at line 1142 of file Utility.cpp. References m_tmp, m_value, MAGIC_TWIST, TWIST, TWIST_IA, TWIST_IB, and TWIST_LEN. Referenced by Utility::Rnd(). 01143 { 01144 unsigned long val = m_tmp[m_value]; 01145 ++m_value; 01146 if (m_value == TWIST_LEN) 01147 { 01148 for (int i = 0; i < TWIST_IB; ++i) 01149 { 01150 unsigned long s = TWIST(m_tmp, i, i + 1); 01151 m_tmp[i] = m_tmp[i + TWIST_IA] ^ (s >> 1) ^ MAGIC_TWIST(s); 01152 } 01153 { 01154 for (int i = 0; i < TWIST_LEN - 1; ++i) 01155 { 01156 unsigned long s = TWIST(m_tmp, i, i + 1); 01157 m_tmp[i] = m_tmp[i - TWIST_IB] ^ (s >> 1) ^ MAGIC_TWIST(s); 01158 } 01159 } 01160 unsigned long s = TWIST(m_tmp, TWIST_LEN - 1, 0); 01161 m_tmp[TWIST_LEN - 1] = m_tmp[TWIST_IA - 1] ^ (s >> 1) ^ MAGIC_TWIST(s); 01162 01163 m_value = 0; 01164 } 01165 return val; 01166 }
Member Data Documentation
The documentation for this class was generated from the following files: |