Beispiel #1
0
        public static void Main(string[] args)
        {
            var mt = new MT19937();

            mt.Seed(new ulong[] { 0x12345UL, 0x23456UL, 0x34567UL, 0x45678UL });

            var i = 0;

            foreach (ulong want in expectedInt)
            {
                var have = mt.UInt64();
                if (have != want)
                {
                    Console.WriteLine("wrong output {0}: {1} != {2}", i, have, want);
                    return;
                }
                i++;
            }

            i = 0;
            foreach (string want in expectedReal)
            {
                var have = mt.Real2().ToString("0.00000000");
                if (have != want)
                {
                    Console.WriteLine("wrong output {0}: {1} != {2}", i, have, want);
                    return;
                }
                i++;
            }

            Console.WriteLine("done");
        }
Beispiel #2
0
 /* generates a random number on (0,1)-real-interval */
 static public double Real3()
 {
     return(((double)(MT19937.UInt64() >> 12) + 0.5) * (1.0 / 4503599627370496.0));
 }
Beispiel #3
0
 /* generates a random number on [0,1)-real-interval */
 static public double Real2()
 {
     return((double)(MT19937.UInt64() >> 11) * (1.0 / 9007199254740992.0));
 }
Beispiel #4
0
 /* generates a random number on [0,1]-real-interval */
 static public double Real1(bool isLog = false, int logLevel = 0)
 {
     return((MT19937.UInt64(isLog, logLevel) >> 11) * (1.0 / 9007199254740991.0));
 }
Beispiel #5
0
 /* generates a random number on [0, 2^63-1]-interval */
 static public long Int63()
 {
     return((long)(MT19937.UInt64() >> 1));
 }