Example #1
0
        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 (Math.Abs(a) >= 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);
        }
        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);

                Assert.AreEqual(xp, xs);
                Assert.AreEqual(yp, ys);
            }
        }
        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);

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

            Debug.Print("TwoProduct_Random Tested {0} tries", testCount);
        }
        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);
        }
Example #5
0
        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));
            }

        }