<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Psudo-number Generator Using Mersenne Twister Algorithm Implemented in C/C++</title>
	<atom:link href="http://www.dbuggr.com/leothenerd/psudo-number-generator-mersenne-twister-algorithm-implemented/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbuggr.com/leothenerd/psudo-number-generator-mersenne-twister-algorithm-implemented/</link>
	<description>Share Knowledge &#38; Be Rewarded</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:13:48 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: leothenerd</title>
		<link>http://www.dbuggr.com/leothenerd/psudo-number-generator-mersenne-twister-algorithm-implemented/comment-page-1/#comment-465</link>
		<dc:creator>leothenerd</dc:creator>
		<pubDate>Sun, 06 Dec 2009 21:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.dbuggr.com/leothenerd/psudo-number-generator-mersenne-twister-algorithm-implemented/#comment-465</guid>
		<description>&lt;code&gt;#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL  
#define UPPER_MASK 0x80000000UL
#define LOWER_MASK 0x7fffffffUL

static unsigned long mt[N];  
static int mti=N+1;          
static unsigned long mag01[2] = {0x0UL, MATRIX_A};

void MersenneTwister::init_genrand(unsigned long seed) {
	mt[0]= seed &amp; 0xffffffffUL;
	for (mti = 1; mti = N) 
       { 

		if (mti == (N + 1))
			init_genrand(4537);
		int kk;
		for (kk = 0; kk &gt; 1) ^ mag01[y &amp; 0x1UL];
		}
		
		for (; kk&gt; 1) ^ mag01[y &amp; 0x1UL];
		}
		y = (mt[N-1] &amp; UPPER_MASK) &#124; (mt[0] &amp; LOWER_MASK);
		mt[N-1] = mt[M-1] ^ (int)(y &gt;&gt; 1) ^ mag01[y &amp; 0x1UL];
		mti = 0;
	}

	y = mt[mti++];

	y ^= (y &gt;&gt; 11);
	y ^= (y &lt;&lt; 7) &amp; 0x9d2c5680UL;
	y ^= (y &lt;&gt; 18);

	if (max == 0)
		return 0;
	else
		return (int)(y / 32) % max;
}

int main() {
       // Usage sample
	MersenneTwister *mt = new MersenneTwister(3);
	printf(&quot;%lu &quot;, mt-&gt;genrandUInt32(125463));
	
	return 0;
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><pre><code>#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL&nbsp;&nbsp;
#define UPPER_MASK 0x80000000UL
#define LOWER_MASK 0x7fffffffUL

static unsigned long mt[N];&nbsp;&nbsp;
static int mti=N+1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
static unsigned long mag01[2] = {0x0UL, MATRIX_A};

void MersenneTwister::init_genrand(unsigned long seed) {
&nbsp;&nbsp;mt[0]= seed &amp; 0xffffffffUL;
&nbsp;&nbsp;for (mti = 1; mti = N) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 

&nbsp;&nbsp;&nbsp;&nbsp;if (mti == (N + 1))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init_genrand(4537);
&nbsp;&nbsp;&nbsp;&nbsp;int kk;
&nbsp;&nbsp;&nbsp;&nbsp;for (kk = 0; kk &gt; 1) ^ mag01[y &amp; 0x1UL];
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;for (; kk&gt; 1) ^ mag01[y &amp; 0x1UL];
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;y = (mt[N-1] &amp; UPPER_MASK) | (mt[0] &amp; LOWER_MASK);
&nbsp;&nbsp;&nbsp;&nbsp;mt[N-1] = mt[M-1] ^ (int)(y &gt;&gt; 1) ^ mag01[y &amp; 0x1UL];
&nbsp;&nbsp;&nbsp;&nbsp;mti = 0;
&nbsp;&nbsp;}

&nbsp;&nbsp;y = mt[mti++];

&nbsp;&nbsp;y ^= (y &gt;&gt; 11);
&nbsp;&nbsp;y ^= (y &lt;&lt; 7) &amp; 0x9d2c5680UL;
&nbsp;&nbsp;y ^= (y &lt;&gt; 18);

&nbsp;&nbsp;if (max == 0)
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;return (int)(y / 32) % max;
}

int main() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Usage sample
&nbsp;&nbsp;MersenneTwister *mt = new MersenneTwister(3);
&nbsp;&nbsp;printf(&quot;%lu &quot;, mt-&gt;genrandUInt32(125463));
&nbsp;&nbsp;
&nbsp;&nbsp;return 0;
}</code></pre></p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
