RFC - Mersenne Twister (SFMT)

Bill Baxter dnewsgroup at billbaxter.com
Sun Nov 18 01:06:13 PST 2007


Tyro[a.c.edwards] wrote:
> After reading Julienne Walker's article (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I wondered why the very best psudo-random generator available is not the standard. I looked at the std.random and was not happy to find out that it is slower than I rand() so I attempted to convert Mersenne Twister (again). I'm hoping to get some feedback on how to improve upon the attempt. The actual library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes with code for both 64-bit OSes and more.
> 
> D version: D v2.007
> OS: Windows XP - sp2
> 
> Thanks,
> Andrew

It looks nice.

Not sure what kind of feedback you were after, but I get the feeling 
that there are a lot of functions there for internal use only.  Those 
should probably be flagged private to help make it clearer what the 
actual user interface is.

Also it's nice to give it a module declaration with a doc comment before 
that that explains what the module is for and the basics of how to use it.

You might also want to provide a class version of the algorithm which 
encapsulates the state, to make thread safety easier.  But it's nice to 
retain the  global-state function-based version, since it's a little 
easier to work with when you don't actually need thread safety.

If that's not the kind of feedback you were after then my apologies.

--bb


More information about the Digitalmars-d-learn mailing list