RNG.h

00001 #include <iostream>
00002 
00003 using namespace std;
00004 
00005 class RNG {
00006 private:
00007         /* Period parameters */  
00008         static const long N = 624;
00009         static const long _M = 397;
00010         static const unsigned long _MATRIX_A = 0x9908b0dfUL;   /* constant vector a */
00011         static const unsigned long _UPPER_MASK = 0x80000000UL; /* most significant w-r bits */
00012         static const unsigned long _LOWER_MASK = 0x7fffffffUL; /* least significant r bits */
00013 
00014 private:
00015         unsigned long mt[N]; /* the array for the state vector  */
00016         int mti;
00017 
00018 public:
00019         RNG(unsigned long seed=5489UL);
00020         RNG(unsigned long *init_key, int key_length);
00021 
00022         void seed(unsigned long seed);
00023 
00024                 /* generates a random number on [0,0xffffffff]-interval */
00025         unsigned long getInt32();
00026                 /* generates a random number on [0,0x7fffffff]-interval */
00027         long getInt31();
00028                 /* generates a random number on [0,1]-real-interval */
00029         double getDoubleLR();
00030         float getFloatLR();
00031                 /* generates a random number on [0,1)-real-interval */
00032         double getDoubleL();
00033         float getFloatL();
00034                 /* generates a random number on (0,1)-real-interval */
00035         double getDouble();
00036         float getFloat();
00037 };

Generated on Wed Oct 25 03:19:42 2006 for Lumos by  doxygen 1.4.6