Example #1
0
        public void EnqueueDequeueKV()
        {
            var pq1 = new PriorityQueueDictionary <int, string>();
            var pq2 = new PriorityQueueDictionary <int, string>();

            for (int i = 10; i > 0; i--)
            {
                pq1.Enqueue(i, i.ToString());
                pq2.Enqueue(i, i.ToString());
            }
            var mt = MTRandom.Create();

            for (int i = -1; i < 20; i++)
            {
                EnqueueDequeue(i);
                EnqueueDequeue(mt.Next());
            }

            void EnqueueDequeue(int value)
            {
                pq2.Enqueue(value, value.ToString());
                pq1.EnqueueDequeue(value, value.ToString()).Should().Be(pq2.Dequeue());
                pq1.UnorderdKeys().ToArray().Should().BeEquivalentTo(pq2.UnorderdKeys().ToArray());
                pq1.UnorderdValues().ToArray().Should().BeEquivalentTo(pq2.UnorderdValues().ToArray());
            }
        }
        public void UtilReverseTest()
        {
            var mt = MTRandom.Create();

            for (int n = 0; n < 200; n++)
            {
                var arr = new int[n];
                for (int i = 0; i < n; i++)
                {
                    arr[i] = mt.Next();
                }
                var cpp = arr.ToArray();
                Array.Sort(arr);
                Array.Reverse(arr);
                Array.Sort(cpp, ComparerUtil.ReverseComparerInt);
                cpp.Should().Equal(cpp);
            }
            for (int n = 0; n < 200; n++)
            {
                var arr = new long[n];
                for (int i = 0; i < n; i++)
                {
                    arr[i] = mt.Next();
                }
                var cpp = arr.ToArray();
                Array.Sort(arr);
                Array.Reverse(arr);
                Array.Sort(cpp, ComparerUtil.ReverseComparerLong);
                cpp.Should().Equal(cpp);
            }
        }
Example #3
0
        public void EnqueueDequeue()
        {
            var pq1 = new PriorityQueue <int>();
            var pq2 = new PriorityQueue <int>();

            for (int i = 10; i > 0; i--)
            {
                pq1.Enqueue(i);
                pq2.Enqueue(i);
            }
            var mt = MTRandom.Create();

            for (int i = -1; i < 20; i++)
            {
                EnqueueDequeue(i);
                EnqueueDequeue(mt.Next());
            }

            void EnqueueDequeue(int value)
            {
                pq2.Enqueue(value);
                pq1.EnqueueDequeue(value).Should().Be(pq2.Dequeue());
                pq1.Unorderd().ToArray().Should().BeEquivalentTo(pq2.Unorderd().ToArray());
            }
        }
        public void DequeueEnqueueKV()
        {
            var pq1 = new PriorityQueueDictionary <int, string>();
            var pq2 = new PriorityQueueDictionary <int, string>();
            Func <int, string, (int, string)> func = (k, v) => (k * 2, (2 * k).ToString());

            for (int i = 10; i > 0; i--)
            {
                pq1.Enqueue(i, i.ToString());
                pq2.Enqueue(i, i.ToString());
            }
            var mt = MTRandom.Create();

            for (int i = -1; i < 20; i++)
            {
                EnqueueDequeue();
            }

            void EnqueueDequeue()
            {
                var(k, v)   = pq2.Dequeue();
                var(ek, ev) = func(k, v);
                pq2.Enqueue(KeyValuePair.Create(ek, ev));
                pq1.DequeueEnqueue(func);
                pq1.UnorderdKeys().ToArray().Should().BeEquivalentTo(pq2.UnorderdKeys().ToArray());
                pq1.UnorderdValues().ToArray().Should().BeEquivalentTo(pq2.UnorderdValues().ToArray());
            }
        }
        public void DequeueEnqueue()
        {
            var             pq1  = new PriorityQueue <int>();
            var             pq2  = new PriorityQueue <int>();
            Func <int, int> func = k => k * 2;

            for (int i = 10; i > 0; i--)
            {
                pq1.Enqueue(i);
                pq2.Enqueue(i);
            }
            var mt = MTRandom.Create();

            for (int i = -1; i < 20; i++)
            {
                EnqueueDequeue();
            }

            void EnqueueDequeue()
            {
                pq2.Enqueue(func(pq2.Dequeue()));
                pq1.DequeueEnqueue(func);
                pq1.Unorderd().ToArray().Should().BeEquivalentTo(pq2.Unorderd().ToArray());
            }
        }
        public void Sequence_MT()
        {
            var seed = Environment.TickCount;

            Test(MTRandom.Create(seed, MTEdition.Original_19937), MTRandom.Create(seed, MTEdition.Cok_19937));
            Test(MTRandom.Create(seed, MTEdition.Original_19937), MTRandom.Create(seed, MTEdition.CokOpt_19937));
        }
 /// <summary>
 /// Performs a simulation of the Ising system with given parameters.
 /// </summary>
 /// <param name="MagMean">Mean magnetization.</param>
 /// <param name="Susceptibility">Magnetic susceptibility of the system.</param>
 public void PerformSimulation(out double MagMean, out double Susceptibility)
 {
     Generator = MTRandom.Create(MTEdition.Original_19937);
     State     = new sbyte[ProblemSize];
     MagSamp   = new double[SamplingCount];
     for (int i = 0; i < ProblemSize; i++)
     {
         State[i] = 1;
     }
     for (int i = 0; i < WarmupFactor; i++)
     {
         UpdateStateN();
     }
     MagMean = 0;
     for (int i = 0; i < SamplingCount; i++)
     {
         for (int j = 0; j < SamplingTime; j++)
         {
             UpdateStateN();
         }
         MagSamp[i] = ComputeMagSample();
         MagMean   += MagSamp[i];
     }
     MagMean       /= SamplingCount;
     Susceptibility = 0;
     for (int i = 0; i < SamplingCount; i++)
     {
         Susceptibility += (MagSamp[i] - MagMean) * (MagSamp[i] - MagMean);
     }
     Susceptibility *= ((double)ProblemSize) / SamplingCount;
 }
        public void StressOK()
        {
            var mt = MTRandom.Create();

            for (int phase = 0; phase < 10000; phase++)
            {
                int n      = mt.Next(1, 21);
                int m      = mt.Next(1, 101);
                var expect = new bool[n];
                for (int i = 0; i < n; i++)
                {
                    expect[i] = mt.NextBool();
                }
                var ts    = new TwoSat(n);
                var xs    = new int[m];
                var ys    = new int[m];
                var types = new int[m];
                for (int i = 0; i < m; i++)
                {
                    int x    = mt.Next(0, n);
                    int y    = mt.Next(0, n);
                    int type = mt.Next(0, 3);
                    xs[i]    = x;
                    ys[i]    = y;
                    types[i] = type;
                    if (type == 0)
                    {
                        ts.AddClause(x, expect[x], y, expect[y]);
                    }
                    else if (type == 1)
                    {
                        ts.AddClause(x, !expect[x], y, expect[y]);
                    }
                    else
                    {
                        ts.AddClause(x, expect[x], y, !expect[y]);
                    }
                }
                ts.Satisfiable().Should().BeTrue();
                var actual = ts.Answer();
                for (int i = 0; i < m; i++)
                {
                    int x = xs[i], y = ys[i], type = types[i];
                    if (type == 0)
                    {
                        (actual[x] == expect[x] || actual[y] == expect[y]).Should().BeTrue();
                    }
                    else if (type == 1)
                    {
                        (actual[x] != expect[x] || actual[y] == expect[y]).Should().BeTrue();
                    }
                    else
                    {
                        (actual[x] == expect[x] || actual[y] != expect[y]).Should().BeTrue();
                    }
                }
            }
        }
Example #9
0
        public void SimpleKV()
        {
            var mt = MTRandom.Create();

            for (int n = 0; n < 200; n++)
            {
                var list = new List <int>();
                var pq   = new PriorityQueueDictionary <long, int>();
                for (int i = 0; i < n; i++)
                {
                    var x = mt.Next(0, int.MaxValue);
                    pq.Enqueue(x, -x);
                    list.Add(x);
                    pq.Count.Should().Be(list.Count).And.Be(i + 1);
                }
                pq.UnorderdKeys().ToArray().Should().HaveCount(n);
                pq.UnorderdValues().ToArray().Should().HaveCount(n);
                list.Sort();
                foreach (var lx in list)
                {
                    pq.Dequeue().Should().Be(KeyValuePair.Create((long)lx, -lx));
                }
                pq.Count.Should().Be(0);


                list.Reverse();
                foreach (var lx in list)
                {
                    pq.Enqueue(-lx, lx);
                }
                foreach (var lx in list)
                {
                    pq.TryDequeue(out var res).Should().BeTrue();
                    res.Should().Be(KeyValuePair.Create(-(long)lx, lx));
                }
                pq.TryDequeue(out _).Should().BeFalse();
                pq.Count.Should().Be(0);

                foreach (var lx in list)
                {
                    pq.Enqueue(-lx, lx);
                }
                foreach (var lx in list)
                {
                    pq.TryDequeue(out var key, out var val).Should().BeTrue();
                    key.Should().Be(-lx);
                    val.Should().Be(lx);
                }
                pq.TryDequeue(out _, out _).Should().BeFalse();
                pq.Count.Should().Be(0);
            }
        }
        public void Stress()
        {
            var mt = MTRandom.Create();

            for (int phase = 0; phase < 10000; phase++)
            {
                int n = mt.Next(2, 21);
                int m = mt.Next(1, 101);
                var(s, t) = mt.NextPair(0, n);
                if (mt.NextBool())
                {
                    (s, t) = (t, s);
                }

                var g = new MfGraphInt(n);
                for (int i = 0; i < m; i++)
                {
                    int u = mt.Next(0, n);
                    int v = mt.Next(0, n);
                    int c = mt.Next(0, 10001);
                    g.AddEdge(u, v, c);
                }
                int flow  = g.Flow(s, t);
                int dual  = 0;
                var cut   = g.MinCut(s);
                var vFlow = new int[n];
                foreach (var e in g.Edges())
                {
                    vFlow[e.From] -= e.Flow;
                    vFlow[e.To]   += e.Flow;
                    if (cut[e.From] && !cut[e.To])
                    {
                        dual += e.Cap;
                    }
                }
                dual.Should().Be(flow);
                vFlow[s].Should().Be(-flow);
                vFlow[t].Should().Be(flow);
                for (int i = 0; i < n; i++)
                {
                    if (i == s || i == t)
                    {
                        continue;
                    }
                    vFlow[i].Should().Be(0);
                }
            }
        }
        public void Mid()
        {
            var mt = MTRandom.Create();
            int n = 1234, m = 2345;
            var a = new StaticModInt <Mod998244353> [n];
            var b = new StaticModInt <Mod998244353> [m];

            for (int i = 0; i < n; i++)
            {
                a[i] = mt.NextUInt();
            }
            for (int i = 0; i < m; i++)
            {
                b[i] = mt.NextUInt();
            }
            MathLib.Convolution(a, b).Should().Equal(ConvNative(a, b));
        }
Example #12
0
        private static IEnumerable <Random> EnumRandoms()
        {
            var seed = Seed;

            System.Diagnostics.Trace.WriteLine("SEED: " + seed);
            yield return(new Random());

            yield return(MTRandom.Create(seed, MTEdition.Original_19937));

            yield return(MTRandom.Create(seed, MTEdition.Cok_19937));

            yield return(MTRandom.Create(seed, MTEdition.CokOpt_19937));

            yield return(MT64Random.Create(seed, MT64Edition.Original_19937));

            yield return(MT64Random.Create(seed, MT64Edition.Opt_19937));

            yield return(SfmtRandom.Create(seed, SfmtEdition.Original_19937));

            yield return(SfmtRandom.Create(seed, SfmtEdition.Opt_19937));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.Original_19937));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.Opt_19937));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_521));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_1279));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_2203));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_4253));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_11213));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_19937));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_44497));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_86243));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_132049));

            yield return(DsfmtRandom.Create(seed, DsfmtEdition.OptGen_216091));
        }
        public void Conv18433()
        {
            // 18433 = 2048 * 9 + 1
            var mt = MTRandom.Create();
            var a  = new long[1024];
            var b  = new long[1025];

            for (int i = 0; i < 1024; i++)
            {
                a[i] = mt.Next(0, (int)default(Mod18433).Mod);
            }
            for (int i = 0; i < 1025; i++)
            {
                b[i] = mt.Next(0, (int)default(Mod18433).Mod);
            }

            MathLib.Convolution <Mod18433>(a, b).Should().Equal(ConvNative <Mod18433>(a, b));
        }
Example #14
0
        public void MemoryStatic()
        {
            var mt = MTRandom.Create();

            for (int n = 0; n < 100; n++)
            {
                var arr      = new StaticModInt <MemoryID> [n];
                var expected = new uint[n];
                for (int i = 0; i < n; i++)
                {
                    var v = mt.NextUInt();
                    arr[i]      = v;
                    expected[i] = v % 101;
                }
                MemoryMarshal.Cast <StaticModInt <MemoryID>, uint>(arr).ToArray()
                .Should().Equal(expected);
            }
        }
        public void Conv641()
        {
            // 641 = 128 * 5 + 1
            var mt = MTRandom.Create();
            var a  = new long[64];
            var b  = new long[65];

            for (int i = 0; i < 64; i++)
            {
                a[i] = mt.Next(0, (int)default(Mod641).Mod);
            }
            for (int i = 0; i < 65; i++)
            {
                b[i] = mt.Next(0, (int)default(Mod641).Mod);
            }

            MathLib.Convolution <Mod641>(a, b).Should().Equal(ConvNative <Mod641>(a, b));
        }
        public void SimpleSMod()
        {
            var mt = MTRandom.Create();

            for (int n = 1; n < 20; n++)
            {
                for (int m = 1; m < 20; m++)
                {
                    var a = new StaticModInt <Mod998244353> [n];
                    var b = new StaticModInt <Mod998244353> [m];

                    for (int i = 0; i < n; i++)
                    {
                        a[i] = mt.NextUInt();
                    }
                    for (int i = 0; i < m; i++)
                    {
                        b[i] = mt.NextUInt();
                    }
                    MathLib.Convolution(a, b).Should().Equal(ConvNative(a, b));
                }
            }
            for (int n = 1; n < 20; n++)
            {
                for (int m = 1; m < 20; m++)
                {
                    var a = new StaticModInt <Mod924844033> [n];
                    var b = new StaticModInt <Mod924844033> [m];

                    for (int i = 0; i < n; i++)
                    {
                        a[i] = mt.NextUInt();
                    }
                    for (int i = 0; i < m; i++)
                    {
                        b[i] = mt.NextUInt();
                    }
                    MathLib.Convolution(a, b).Should().Equal(ConvNative(a, b));
                }
            }
        }
        public void SimpleULong()
        {
            var mt = MTRandom.Create();

            for (int n = 1; n < 20; n++)
            {
                for (int m = 1; m < 20; m++)
                {
                    var a = new ulong[n];
                    var b = new ulong[m];

                    for (int i = 0; i < n; i++)
                    {
                        a[i] = mt.NextUInt() % default(Mod998244353).Mod;
                    }
                    for (int i = 0; i < m; i++)
                    {
                        b[i] = mt.NextUInt() % default(Mod998244353).Mod;
                    }
                    MathLib.Convolution <Mod998244353>(a, b).Should().Equal(ConvNative <Mod998244353>(a, b));
                }
            }
            for (int n = 1; n < 20; n++)
            {
                for (int m = 1; m < 20; m++)
                {
                    var a = new ulong[n];
                    var b = new ulong[m];

                    for (int i = 0; i < n; i++)
                    {
                        a[i] = mt.NextUInt() % default(Mod924844033).Mod;
                    }
                    for (int i = 0; i < m; i++)
                    {
                        b[i] = mt.NextUInt() % default(Mod924844033).Mod;
                    }
                    MathLib.Convolution <Mod924844033>(a, b).Should().Equal(ConvNative <Mod924844033>(a, b));
                }
            }
        }
        public void ConvLong()
        {
            var mt = MTRandom.Create();

            for (int n = 1; n < 20; n++)
            {
                for (int m = 1; m < 20; m++)
                {
                    var a = new long[n];
                    var b = new long[m];
                    for (int i = 0; i < n; i++)
                    {
                        a[i] = (long)(mt.NextUInt() % 1_000_000) - 500_000;
                    }
                    for (int i = 0; i < m; i++)
                    {
                        b[i] = (long)(mt.NextUInt() % 1_000_000) - 500_000;
                    }
                    MathLib.ConvolutionLong(a, b).Should().Equal(ConvLongNative(a, b));
                }
            }
        }
Example #19
0
        public void Simple()
        {
            var mt = MTRandom.Create();

            for (int n = 0; n < 200; n++)
            {
                var list = new List <int>();
                var pq   = new PriorityQueue <int>();
                for (int i = 0; i < n; i++)
                {
                    var x = mt.Next();
                    pq.Enqueue(x);
                    list.Add(x);
                    pq.Count.Should().Be(list.Count).And.Be(i + 1);
                }
                pq.Unorderd().ToArray().Should().HaveCount(n);
                list.Sort();
                foreach (var lx in list)
                {
                    pq.Dequeue().Should().Be(lx);
                }
                pq.Count.Should().Be(0);

                list.Reverse();
                foreach (var lx in list)
                {
                    pq.Enqueue(-lx);
                }
                foreach (var lx in list)
                {
                    pq.TryDequeue(out var res).Should().BeTrue();
                    res.Should().Be(-lx);
                }
                pq.TryDequeue(out _).Should().BeFalse();
                pq.Count.Should().Be(0);
            }
        }
Example #20
0
        static void Main(string[] args)
        {
            if (Debugger.IsAttached)
            {
                Console.WriteLine("***************************");
                Console.WriteLine("  Run without a debugger!");
                Console.WriteLine("***************************");
                Console.WriteLine();
            }
            //
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            Console.WriteLine("Wait for getting calm 3 seconds...");
            Thread.Sleep(3000);
            //
            var fmt = "   {0,23}: {1,6:f3} s (mean = {2:f10} * int.MaxValue)";
            Func <Random, long> proci = Next <Random>;
            var    seed1 = Environment.TickCount;
            var    N     = 300000000;
            double mean;

            Console.WriteLine();
            Console.WriteLine("Random.Next: N = {0:#,0}", N);
            //
            var t_null = Measure(NullRandom.Defalut, N, proci, out mean);

            Console.WriteLine(fmt, "Null", t_null, mean);
            var t_rand = Measure(new Random(), N, proci, out mean);

            Console.WriteLine(fmt, "Random", t_rand, mean);
            var t_mt32_org = Measure(MTRandom.Create(seed1, MTEdition.Original_19937), N, proci, out mean);

            Console.WriteLine(fmt, "MT19937", t_mt32_org, mean);
            var t_mt32_cok = Measure(MTRandom.Create(seed1, MTEdition.Cok_19937), N, proci, out mean);

            Console.WriteLine(fmt, "MT19937-c*k", t_mt32_cok, mean);
            var t_mt32_opt = Measure(MTRandom.Create(seed1, MTEdition.CokOpt_19937), N, proci, out mean);

            Console.WriteLine(fmt, "MT19937-c*k-opt", t_mt32_opt, mean);
            var t_mt64_org = Measure(MT64Random.Create(seed1, MT64Edition.Original_19937), N, proci, out mean);

            Console.WriteLine(fmt, "MT64-19937", t_mt64_org, mean);
            var t_mt64_opt = Measure(MT64Random.Create(seed1, MT64Edition.Opt_19937), N, proci, out mean);

            Console.WriteLine(fmt, "MT64-19937-opt", t_mt64_opt, mean);
            var t_sfmt_ptr = Measure(new SfmtRandom <unsafe_sfmt_t>(seed1), N, proci, out mean);

            Console.WriteLine(fmt, "SFMT-19937-ptr", t_sfmt_ptr, mean);
            var t_sfmt_org = Measure(SfmtRandom.Create(seed1, SfmtEdition.Original_19937), N, proci, out mean);

            Console.WriteLine(fmt, "SFMT-19937", t_sfmt_org, mean);
            var t_sfmt_opt = Measure(SfmtRandom.Create(seed1, SfmtEdition.Opt_19937), N, proci, out mean);

            Console.WriteLine(fmt, "SFMT-opt-19937", t_sfmt_opt, mean);
            var t_dsfmt_ptr = Measure(new DsfmtRandom <unsafe_dsfmt_t>(seed1), N, proci, out mean);

            Console.WriteLine(fmt, "dSFMT-19937-ptr", t_dsfmt_ptr, mean);
            var t_dsfmt_org = Measure(DsfmtRandom.Create(seed1, DsfmtEdition.Original_19937), N, proci, out mean);

            Console.WriteLine(fmt, "dSFMT-19937", t_dsfmt_org, mean);
            var t_dsfmt_opt = Measure(DsfmtRandom.Create(seed1, DsfmtEdition.Opt_19937), N, proci, out mean);

            Console.WriteLine(fmt, "dSFMT-opt-19937", t_dsfmt_opt, mean);
            var t_dsfmt_gen = Measure(DsfmtRandom.Create(seed1, DsfmtEdition.OptGen_19937), N, proci, out mean);

            Console.WriteLine(fmt, "dSFMT-opt-gen-19937", t_dsfmt_gen, mean);
            var t_accurate = Measure(new AccurateRandom(DsfmtRandom.Create(seed1, DsfmtEdition.Opt_19937)), N, proci, out mean);

            Console.WriteLine(fmt, "accurate+dSFMT-opt-19937", t_accurate, mean);
            t_dsfmt_gen = Measure(DsfmtRandom.Create(seed1, DsfmtEdition.OptGen_521), N, proci, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-gen-521", t_dsfmt_gen, mean);
            t_dsfmt_gen = Measure(DsfmtRandom.Create(seed1, DsfmtEdition.OptGen_216091), N, proci, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-gen-216091", t_dsfmt_gen, mean);
            //
            var buf     = new byte[sizeof(int) * 10];
            var t_cprng = Measure(new System.Security.Cryptography.RNGCryptoServiceProvider(), N, rng => {
                rng.GetBytes(buf);
                var x = 0L;
                x    += ToUInt32(buf, 0) >> 1;
                x    += ToUInt32(buf, 4) >> 1;
                x    += ToUInt32(buf, 8) >> 1;
                x    += ToUInt32(buf, 12) >> 1;
                x    += ToUInt32(buf, 16) >> 1;
                x    += ToUInt32(buf, 20) >> 1;
                x    += ToUInt32(buf, 24) >> 1;
                x    += ToUInt32(buf, 28) >> 1;
                x    += ToUInt32(buf, 32) >> 1;
                x    += ToUInt32(buf, 36) >> 1;
                return(x);
            }, out mean);

            Console.WriteLine(fmt, "RNGCrypt", t_cprng, mean);
            //
            fmt = "   {0,23}: {1,6:f3} s (mean = {2:f10})";
            Func <Random, double> procd = NextDouble <Random>;
            var seed2 = new uint[] { (uint)Environment.TickCount, (uint)Environment.WorkingSet };

            N = 200000000;
            Console.WriteLine();
            Console.WriteLine("Random.NextDouble: N = {0:#,0}", N);
            //
            t_null = Measure(NullRandom.Defalut, N, procd, out mean);
            Console.WriteLine(fmt, "Null", t_null, mean);
            t_rand = Measure(new Random(), N, procd, out mean);
            Console.WriteLine(fmt, "Random", t_rand, mean);
            t_mt32_org = Measure(MTRandom.Create(seed2, MTEdition.Original_19937), N, procd, out mean);
            Console.WriteLine(fmt, "MT19937", t_mt32_org, mean);
            t_mt32_cok = Measure(MTRandom.Create(seed2, MTEdition.Cok_19937), N, procd, out mean);
            Console.WriteLine(fmt, "MT19937-c*k", t_mt32_cok, mean);
            t_mt32_opt = Measure(MTRandom.Create(seed2, MTEdition.CokOpt_19937), N, procd, out mean);
            Console.WriteLine(fmt, "MT19937-c*k-opt", t_mt32_opt, mean);
            t_mt64_org = Measure(MT64Random.Create(seed1, MT64Edition.Original_19937), N, procd, out mean);
            Console.WriteLine(fmt, "MT64-19937", t_mt64_org, mean);
            t_mt64_opt = Measure(MT64Random.Create(seed1, MT64Edition.Opt_19937), N, procd, out mean);
            Console.WriteLine(fmt, "MT64-19937-opt", t_mt64_opt, mean);
            t_sfmt_ptr = Measure(new SfmtRandom <unsafe_sfmt_t>(seed2), N, procd, out mean);
            Console.WriteLine(fmt, "SFMT-19937-ptr", t_sfmt_org, mean);
            t_sfmt_org = Measure(SfmtRandom.Create(seed2, SfmtEdition.Original_19937), N, procd, out mean);
            Console.WriteLine(fmt, "SFMT-19937", t_sfmt_org, mean);
            t_sfmt_opt = Measure(SfmtRandom.Create(seed2, SfmtEdition.Opt_19937), N, procd, out mean);
            Console.WriteLine(fmt, "SFMT-opt-19937", t_sfmt_opt, mean);
            t_dsfmt_ptr = Measure(new DsfmtRandom <unsafe_dsfmt_t>(seed2), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-19937-ptr", t_dsfmt_ptr, mean);
            t_dsfmt_org = Measure(DsfmtRandom.Create(seed2, DsfmtEdition.Original_19937), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-19937", t_dsfmt_org, mean);
            t_dsfmt_opt = Measure(DsfmtRandom.Create(seed2, DsfmtEdition.Opt_19937), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-19937", t_dsfmt_opt, mean);
            t_dsfmt_gen = Measure(DsfmtRandom.Create(seed2, DsfmtEdition.OptGen_19937), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-gen-19937", t_dsfmt_gen, mean);
            t_accurate = Measure(new AccurateRandom(DsfmtRandom.Create(seed2, DsfmtEdition.Opt_19937)), N, procd, out mean);
            Console.WriteLine(fmt, "accurate+dSFMT-opt-19937", t_accurate, mean);
            t_dsfmt_gen = Measure(DsfmtRandom.Create(seed2, DsfmtEdition.OptGen_521), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-gen-521", t_dsfmt_gen, mean);
            t_dsfmt_gen = Measure(DsfmtRandom.Create(seed2, DsfmtEdition.OptGen_216091), N, procd, out mean);
            Console.WriteLine(fmt, "dSFMT-opt-gen-216091", t_dsfmt_gen, mean);
            //
            buf     = new byte[sizeof(ulong) * 10];
            t_cprng = Measure(new System.Security.Cryptography.RNGCryptoServiceProvider(), N, rng => {
                rng.GetBytes(buf);
                var x = 0d;
                x    += ToDouble(buf, 0);
                x    += ToDouble(buf, 8);
                x    += ToDouble(buf, 16);
                x    += ToDouble(buf, 24);
                x    += ToDouble(buf, 32);
                x    += ToDouble(buf, 40);
                x    += ToDouble(buf, 48);
                x    += ToDouble(buf, 56);
                x    += ToDouble(buf, 64);
                x    += ToDouble(buf, 72);
                return(x);
            }, out mean);
            Console.WriteLine(fmt, "RNGCrypt", t_cprng, mean);
        }
 public void Random_MT()
 {
     Test(MTRandom.Create(MTEdition.Original_19937));
     Test(MTRandom.Create(MTEdition.Cok_19937));
     Test(MTRandom.Create(MTEdition.CokOpt_19937));
 }