示例#1
0
        public void TwoProductPre2Split_Random()
        {
            // Just checks that the result from 2-pre-split is same as 2xSplit + TwoProduct
            var rnd       = new RandomDouble(2); // Use a specific seed to ensure repeatability
            int testCount = 100000;

            for (int i = 0; i < testCount; i++)
            {
                double a = rnd.NextDoubleValidRange();
                double b = rnd.NextDoubleValidRange();

                double x; double y;
                TwoProduct_Checked(a, b, out x, out y);

                double ahi, alo;
                EA.Split(a, out ahi, out alo);
                double bhi, blo;
                EA.Split(b, out bhi, out blo);

                double xps, yps;
                EA.TwoProduct2Presplit(a, ahi, alo, b, bhi, blo, out xps, out yps);

                NUnit.Framework.Assert.AreEqual(x, xps);
                NUnit.Framework.Assert.AreEqual(y, yps);
            }

            Debug.Print("TwoProduct_Random Tested {0} tries", testCount);
        }
        public override void SetUp()
        {
            _canvas            = new Canvas();
            _canvas.Background = new SolidColorBrush(Colors.White);
            _labels            = new Label[LinesCount];

            _window            = new Window();
            _window.Width      = Width;
            _window.Height     = Height;
            _window.Content    = _canvas;
            _window.Background = new SolidColorBrush(Colors.Black);
            _window.Closed    += OnWindowClosed;
            _window.Show();

            for (int index = 0; index < _labels.Length; index++)
            {
                Color color = Color.FromArgb((byte)RandomInteger.NextInteger(255),
                                             (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255));

                _labels[index] = new Label();
                _canvas.Children.Add(_labels[index]);
                _labels[index].Content = RandomDouble.NextDouble(1.0).ToString();
                Canvas.SetLeft(_labels[index], RandomInteger.NextInteger(Width));
                Canvas.SetTop(_labels[index], RandomInteger.NextInteger(Height));
            }

            lastTick             = System.Environment.TickCount;
            _frameTimer          = new System.Windows.Threading.DispatcherTimer();
            _frameTimer.Tick    += OnFrame;
            _frameTimer.Interval = TimeSpan.FromSeconds(1.0 / 60.0);
            _frameTimer.Start();
        }
        public void GetRandom()
        {
            RandomDouble rd = new RandomDouble();
//            foreach (var i in Enumerable.Range(0, 10000))
            {
                double d = rd.NextDoubleFullRange();
            }
        }
示例#4
0
 public void TestRandomSin()
 {
     var rd = new RandomDouble(TwoPi);
     var s = Lifter.Apply(Math.Sin, rd);
     for (int i = 0; i < 5; i++)
     {
         Console.WriteLine(s.Value);
     }
 }
 private void AppendNewDataItems(int count)
 {
     for (int index = 0; index < count; index++)
     {
         _dataItems.Add(new DataItem()
         {
             Age          = RandomInteger.NextInteger(100),
             Name         = "Name #" + _dataItems.Count,
             RandomNumber = RandomDouble.NextDouble(1.0) * 1000
         });
     }
 }
示例#6
0
 public static BeaconV1 CreateBeacon()
 {
     return(new BeaconV1()
     {
         Id = RandomString.NextString(10, 20),
         SiteId = RandomString.NextString(10, 20),
         Type = RandomText.Word(),
         Udi = RandomString.NextString(10, 20),
         Label = RandomText.Word(),
         Center = new CenterObject(RandomText.Word(), new int[] { RandomInteger.NextInteger(1, 10), RandomInteger.NextInteger(1, 10) }),
         Radius = RandomDouble.NextDouble(100.0)
     });
 }
示例#7
0
        public void TwoProduct_Random()
        {
            var rnd       = new RandomDouble(3); // Use a specific seed to ensure repeatability
            int testCount = 100000;

            for (int i = 0; i < testCount; i++)
            {
                double a = rnd.NextDoubleValidRange();
                double b = rnd.NextDoubleValidRange();

                double x; double y;
                TwoProduct_Checked(a, b, out x, out y);
            }

            Debug.Print("TwoProduct_Random Tested {0} tries", testCount);
        }
        public void TwoSum_ResultsNonOverlappingNonAdjacent_Random()
        {
            var rnd       = new RandomDouble(1); // Use a specific seed to ensure repeatability
            int testCount = 1000000;

            for (int i = 0; i < testCount; i++)
            {
                double a = rnd.NextDoubleFullRange();
                double b = rnd.NextDoubleFullRange();
                double x; double y;

                EA.TwoSum(a, b, out x, out y);
                Assert.IsTrue(ExpansionExtensions.AreNonOverlapping(x, y));
                Assert.IsTrue(ExpansionExtensions.AreNonAdjacent(x, y));
            }
        }
示例#9
0
        public void Square_Random()
        {
            var rnd       = new RandomDouble(3); // Use a specific seed to ensure repeatability
            int testCount = 100000;

            for (int i = 0; i < testCount; i++)
            {
                double a = rnd.NextDoubleValidRange();

                double xp, yp;
                EA.TwoProduct(a, a, out xp, out yp);

                double xs, ys;
                EA.Square(a, out xs, out ys);

                NUnit.Framework.Assert.AreEqual(xp, xs);
                NUnit.Framework.Assert.AreEqual(yp, ys);
            }
        }
        private void OnFrame(object sender, EventArgs e)
        {
            currentTick = System.Environment.TickCount;
            elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            for (int index = 0; index < _labels.Length; index++)
            {
                _labels[index].Content = RandomDouble.NextDouble(1.0).ToString();
                Canvas.SetLeft(_labels[index], RandomInteger.NextInteger(Width));
                Canvas.SetTop(_labels[index], RandomInteger.NextInteger(Height));
            }
        }
        public void FastTwoSum_ResultsNonOverlappingNonAdjacent_Random()
        {
            var rnd            = new RandomDouble(1); // Use a specific seed to ensure repeatability
            int testCount      = 1000000;
            int testsPerformed = 0;

            for (int i = 0; i < testCount; i++)
            {
                double a = rnd.NextDoubleFullRange();
                double b = rnd.NextDoubleFullRange();
                double x; double y;

                if (System.Math.Abs(a) >= System.Math.Abs(b))
                {
                    testsPerformed++;
                    EA.FastTwoSum(a, b, out x, out y);
                    Assert.IsTrue(ExpansionExtensions.AreNonOverlapping(x, y));
                    Assert.IsTrue(ExpansionExtensions.AreNonAdjacent(x, y));
                }
            }

            Debug.Print("FastTwoSum_MaintainsNonOverlapping_Random Tested {0} out of {1} tries", testsPerformed, testCount);
        }
        private void OnFrame(object sender, EventArgs e)
        {
            this.currentTick = System.Environment.TickCount;
            this.elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            this.lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            if (GrowListOnly)
            {
                AppendNewDataItems(10);
                _window.ScrollTo(_dataItems.Count - 1);

                if (_dataItems.Count > ItemsCount)
                {
                    _dataItems.Clear();
                }
            }
            else
            {
                for (int index = 0; index < ItemsCount; index++)
                {
                    _dataItems[index].Age          = RandomInteger.NextInteger(100);
                    _dataItems[index].Name         = "Name #" + index + " - " + RandomInteger.NextInteger(1000);
                    _dataItems[index].RandomNumber = RandomDouble.NextDouble(1.0) * 1000;
                }
                _window.ScrollTo(RandomInteger.NextInteger(ItemsCount - 1));
            }
        }
示例#13
0
        public void GetRandom()
        {
            RandomDouble rd = new RandomDouble();
//            foreach (var i in Enumerable.Range(0, 10000))
            {
                double d = rd.NextDoubleFullRange();
            }
        }
 protected double GetRandomValue()
 {
     return(RandomDouble.NextDouble(0, 100));
 }
示例#15
0
 static HLRandomizer()
 {
     RandomString = new RandomString();
     RandomDouble = new RandomDouble();
 }
        private BenchmarkInstance ChooseBenchmarkProportionally()
        {
            double selector = RandomDouble.NextDouble(1.0);

            return(_activeBenchmarks.FirstOrDefault(benchmark => benchmark.WithinRange(selector)));
        }