示例#1
0
        public void FitsAtSamplePoints()
        {
            IInterpolation it = Barycentric.InterpolatePolynomialEquidistant(Tmin, Tmax, _y);

            for (int i = 0; i < _y.Length; i++)
            {
                Assert.AreEqual(_y[i], it.Interpolate(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.InterpolatePolynomialEquidistant(x, y);

            for (int i = 0; i < xtest.Length; i++)
            {
                Assert.AreEqual(ytest[i], it.Interpolate(xtest[i]), 1e-12, "Linear with {0} samples, sample {1}", samples, i);
            }
        }
示例#3
0
 /// <summary>
 /// Create a barycentric polynomial interpolation where the given sample points are equidistant.
 /// </summary>
 /// <param name="points">The sample points t, must be equidistant.</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.InterpolatePolynomialEquidistantSorted
 /// instead, which is more efficient.
 /// </remarks>
 public static IInterpolation PolynomialEquidistant(IEnumerable <double> points, IEnumerable <double> values)
 {
     return(Barycentric.InterpolatePolynomialEquidistant(points, values));
 }
示例#4
0
        public void FitsAtArbitraryPoints(double t, double x, double maxAbsoluteError)
        {
            IInterpolation it = Barycentric.InterpolatePolynomialEquidistant(Tmin, Tmax, _y);

            Assert.AreEqual(x, it.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t);
        }
示例#5
0
 public void FewSamples()
 {
     Assert.That(() => Barycentric.InterpolatePolynomialEquidistant(new double[0], new double[0]), Throws.ArgumentException);
     Assert.That(Barycentric.InterpolatePolynomialEquidistant(new[] { 1.0 }, new[] { 2.0 }).Interpolate(1.0), Is.EqualTo(2.0));
 }