示例#1
0
        public void TestSerializeComplexVector()
        {
            ComplexVector before = ComplexVector.Random(10, _random);
            ComplexVector after  = SerializeDeserialize(before);

            Assert.That(after, Is.Not.Null, "Not Null");
            Assert.That(after, Is.EqualTo(before), "Equal");
            Assert.That(after, NumericIs.AlmostEqualTo(before), "Almost Equal");
        }
示例#2
0
        public void TestAlmostEquals_ComplexPolynomial()
        {
            ComplexPolynomial a1 = new ComplexPolynomial(ComplexVector.Random(5, new ContinuousUniformDistribution()));
            ComplexPolynomial a2 = a1.Clone();
            ComplexPolynomial b  = -a1;
            ComplexPolynomial c  = a1 * (1.0 + (1e+10 * Number.PositiveEpsilonOf(1.0)));
            ComplexPolynomial d  = a1 * (1.0 + (2 * Number.PositiveEpsilonOf(1.0)));

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

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

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