Exemplo n.º 1
0
        public void NaturalFitsAtSamplePoints()
        {
            var it = CubicSplineInterpolation.InterpolateNatural(_t, _y);

            for (int i = 0; i < _y.Length; i++)
            {
                Assert.AreEqual(_y[i], it.ValueAt(_t[i]), "A Exact Point " + i);
            }
        }
Exemplo n.º 2
0
 public void FewSamples()
 {
     Assert.AreEqual(CubicSplineInterpolation.InterpolateNatural(new[] { 1.0, 2.0 }, new[] { 2.0, 2.0 }).ValueAt(1.0),
                     2.0);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference.
        /// </summary>
        /// <param name="t">Sample point.</param>
        /// <param name="x">Sample value.</param>
        /// <param name="maxAbsoluteError">Maximum absolute error.</param>
        /// <remarks>
        /// Maple:
        /// with(CurveFitting);
        /// evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints='natural')),20);
        /// </remarks>
        public void NaturalFitsAtArbitraryPoints(double t, double x, double maxAbsoluteError)
        {
            var it = CubicSplineInterpolation.InterpolateNatural(_t, _y);

            Assert.AreEqual(x, it.ValueAt(t), maxAbsoluteError, "Interpolation at {0}", t);
        }