Пример #1
0
        public void FunctionTest()
        {
            Laplacian dense = new Laplacian(3.6);
            SparseLaplacian target = new SparseLaplacian(3.6);

            double[] sx = { 1, -0.555556, 2, +0.250000, 3, -0.864407, 4, -0.916667 };
            double[] sy = { 1, -0.666667, 2, -0.166667, 3, -0.864407, 4, -0.916667 };
            double[] sz = { 1, -0.944444, 3, -0.898305, 4, -0.916667 };

            double[] dx = { -0.555556, +0.250000, -0.864407, -0.916667 };
            double[] dy = { -0.666667, -0.166667, -0.864407, -0.916667 };
            double[] dz = { -0.944444, +0.000000, -0.898305, -0.916667 };

            double expected, actual;

            expected = dense.Function(dx, dy);
            actual = target.Function(sx, sy);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.AreEqual(0.88711080792421337, actual);
            Assert.IsFalse(double.IsNaN(actual));

            expected = dense.Function(dx, dz);
            actual = target.Function(sx, sz);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.AreEqual(0.87918038010432886, actual, 1e-10);
            Assert.IsFalse(double.IsNaN(actual));

            expected = dense.Function(dy, dz);
            actual = target.Function(sy, sz);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.AreEqual(0.91349716289496652, actual);
            Assert.IsFalse(double.IsNaN(actual));
        }
Пример #2
0
        public void FunctionTest()
        {
            double sigma = 2.1;
            Laplacian target = new Laplacian(sigma);

            double[] x = { 1, 3 };
            double[] y = { -1, 2 };

            double expected = 0.34479878120059682;
            double actual = target.Function(x, y);
            Assert.AreEqual(expected, actual);

            // For the same input, product should be 1
            Assert.AreEqual(1.0, target.Function(x, x));
        }