Esempio n. 1
0
        public void CanInterpolateMonotone()
        {
            var interp = new CubicHermiteSplineInterpolator(
                new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 },
                new double[] { 3.0, 2.9, 2.5, 1.0, 0.9, 0.8, 0.7, 0.3, 0.1 },
                true);

            var lastI = interp.Interpolate(0);

            for (var i = 1; i < 100; i++)
            {
                var thisI = interp.Interpolate(i / 100.0);
                Assert.True(thisI <= lastI);
                lastI = thisI;
            }
        }
Esempio n. 2
0
        public void CanClone()
        {
            var interp = new CubicHermiteSplineInterpolator(new double[] { 0, 10, 20 }, new double[] { 10, 15, 40 });

            var i2 = interp.UpdateY(2, 50);

            Assert.Equal(10.0, interp.Interpolate(0));
            Assert.Equal(15.0, interp.Interpolate(10));
            Assert.Equal(40.0, interp.Interpolate(20));

            Assert.Equal(10.0, i2.Interpolate(0));
            Assert.Equal(15.0, i2.Interpolate(10));
            Assert.Equal(50.0, i2.Interpolate(20));

            var i3 = interp.Bump(2, 10);

            Assert.Equal(10.0, i3.Interpolate(0));
            Assert.Equal(15.0, i3.Interpolate(10));
            Assert.Equal(50.0, i3.Interpolate(20));
        }
Esempio n. 3
0
        public void CanInterpolate()
        {
            var interp = new CubicHermiteSplineInterpolator(new double[] { 0, 10, 20 }, new double[] { 10, 15, 40 });

            Assert.Equal(10.0, interp.Interpolate(0));
            Assert.Equal(15.0, interp.Interpolate(10));
            Assert.Equal(40.0, interp.Interpolate(20));

            Assert.True(interp.Interpolate(5) > 10 && interp.Interpolate(5) < 15);

            interp = new CubicHermiteSplineInterpolator();
            interp = new CubicHermiteSplineInterpolator(new double[] { 0 }, new double[] { 10 });
            Assert.Equal(10.0, interp.Interpolate(20));
            Assert.Equal(200.0, interp.DefiniteIntegral(0, 20));

            interp = new CubicHermiteSplineInterpolator(new double[] { 0, 10, 20 }, new double[] { 10, 10, 40 });
            Assert.Equal(10.0, interp.Interpolate(0));
            Assert.Equal(10.0, interp.Interpolate(10));
            Assert.Equal(40.0, interp.Interpolate(20));

            Assert.Throws <NotImplementedException>(() => interp.Sensitivity(0));
        }