示例#1
0
        public void TestAlmostEquals_ComplexMatrix()
        {
            ComplexMatrix a1 = ComplexMatrix.Random(3, 2, new ContinuousUniformDistribution());
            ComplexMatrix a2 = a1.Clone();
            ComplexMatrix b  = -a1;
            ComplexMatrix c  = a1 * (1.0 + (1e+10 * Number.PositiveEpsilonOf(1.0)));
            ComplexMatrix d  = a1 * (1.0 + (2 * Number.PositiveEpsilonOf(1.0)));

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

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

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

            // transpose
            Assert.That(a1.Transpose(), Is.Not.EqualTo(a1));
            Assert.That(Number.AlmostEqual(a1, a1.Transpose()), Is.False);
            Assert.That(Number.AlmostEqual(a1, a1.Transpose(), 1e-10), Is.False);

            // hermitian transpose
            Assert.That(a1.HermitianTranspose(), Is.Not.EqualTo(a1));
            Assert.That(Number.AlmostEqual(a1, a1.HermitianTranspose()), Is.False);
            Assert.That(Number.AlmostEqual(a1, a1.HermitianTranspose(), 1e-10), Is.False);
        }
示例#2
0
        public void TestSerializeComplexMatrix()
        {
            ComplexMatrix before = ComplexMatrix.Random(3, 5, _random);
            ComplexMatrix 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");
        }