示例#1
0
        public void PolyomnialFitsAtSamplePoints()
        {
            IInterpolation it = Barycentric.InterpolateRationalFloaterHormann(_t, _y);

            for (int i = 0; i < _y.Length; i++)
            {
                Assert.AreEqual(_y[i], it.Interpolate(_t[i]), "A Exact Point " + i);
            }
        }
示例#2
0
        public void SupportsLinearCase(int samples)
        {
            double[] x, y, xtest, ytest;
            LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples);
            IInterpolation it = Barycentric.InterpolateRationalFloaterHormann(x, y);

            for (int i = 0; i < xtest.Length; i++)
            {
                Assert.AreEqual(ytest[i], it.Interpolate(xtest[i]), 1e-14, "Linear with {0} samples, sample {1}", samples, i);
            }
        }
示例#3
0
        public void RationalFitsAtSamplePoints()
        {
            var t = new double[40];
            var x = new double[40];

            const double Step = 10.0 / 39.0;

            for (int i = 0; i < t.Length; i++)
            {
                double tt = -5 + (i * Step);
                t[i] = tt;
                x[i] = 1.0 / (1.0 + (tt * tt));
            }

            IInterpolation it = Barycentric.InterpolateRationalFloaterHormann(t, x);

            for (int i = 0; i < x.Length; i++)
            {
                Assert.AreEqual(x[i], it.Interpolate(t[i]), "A Exact Point " + i);
            }
        }
示例#4
0
        public void PolynomialFitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError)
        {
            IInterpolation it = Barycentric.InterpolateRationalFloaterHormann(_t, _y);

            Assert.AreEqual(x, it.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t);
        }
示例#5
0
 public void FewSamples()
 {
     Assert.That(() => Barycentric.InterpolateRationalFloaterHormann(new double[0], new double[0]), Throws.ArgumentException);
     Assert.That(Barycentric.InterpolateRationalFloaterHormann(new[] { 1.0 }, new[] { 2.0 }).Interpolate(1.0), Is.EqualTo(2.0));
 }
示例#6
0
 /// <summary>
 /// Create a Floater-Hormann rational pole-free interpolation based on arbitrary points.
 /// </summary>
 /// <param name="points">The sample points t.</param>
 /// <param name="values">The sample point values x(t).</param>
 /// <returns>
 /// An interpolation scheme optimized for the given sample points and values,
 /// which can then be used to compute interpolations and extrapolations
 /// on arbitrary points.
 /// </returns>
 /// <remarks>
 /// if your data is already sorted in arrays, consider to use
 /// MathNet.Numerics.Interpolation.Barycentric.InterpolateRationalFloaterHormannSorted
 /// instead, which is more efficient.
 /// </remarks>
 public static IInterpolation RationalWithoutPoles(IEnumerable <double> points, IEnumerable <double> values)
 {
     return(Barycentric.InterpolateRationalFloaterHormann(points, values));
 }