Exemple #1
0
        public void TestAlmostEquals_Polynomial()
        {
            Polynomial a1 = new Polynomial(Vector.Random(5, new ContinuousUniformDistribution()));
            Polynomial a2 = a1.Clone();
            Polynomial b  = -a1;
            Polynomial c  = a1 * (1.0 + (1e+10 * Number.PositiveEpsilonOf(1.0)));
            Polynomial d  = a1 * (1.0 + (2 * Number.PositiveEpsilonOf(1.0)));

            Helper_TestAlmostEqualityForGenericType(a1, a2, b, c, d);

            // Wrapper
            Assert.That(Polynomial.AlmostEqual(a1, c), Is.False);
            Assert.That(Polynomial.AlmostEqual(a1, c, 1e-10), Is.False);
            Assert.That(Polynomial.AlmostEqual(a1, c, 1e-2), Is.True);

            // reference type -> no boxing
            Assert.That(a1, Is.SameAs(a1));
        }