public void FitsAtSamplePoints()
        {
            IInterpolation interpolation = new NevillePolynomialInterpolation(_t, _x);

            for (int i = 0; i < _x.Length; i++)
            {
                Assert.AreEqual(_x[i], interpolation.Interpolate(_t[i]), "A Exact Point " + i);
            }
        }
        public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError)
        {
            IInterpolation interpolation = new NevillePolynomialInterpolation(_t, _x);

            Assert.AreEqual(x, interpolation.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t);
        }
 public void Constructor_SamplePointsNotUnique_Throws()
 {
     var x = new[] { -1.0, 0.0, 1.5, 1.5, 2.5, 4.0 };
     var y = new[] { 1.0, 0.3, -0.7, -0.6, -0.1, 0.4 };
     var interpolation = new NevillePolynomialInterpolation(x, y);
 }
        public void Interpolate_LogLogAttenuationData_InterpolationShouldNotYieldNaN(
            [Values(0.0025, 0.035, 0.45, 5.5, 18.5, 35.0)] double value)
        {
            var data = Data.ReadAllLines(@"Github-Cureos-1.csv")
                .Select(line =>
                {
                    var vals = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    return new Tuple<string, string>(vals[2], vals[3]);
                }).ToArray();
            var x = data.Select(tuple => Double.Parse(tuple.Item1, CultureInfo.InvariantCulture)).ToArray();
            var y = data.Select(tuple => Double.Parse(tuple.Item2, CultureInfo.InvariantCulture)).ToArray();
            IInterpolation interpolation = new NevillePolynomialInterpolation(x, y);

            var actual = interpolation.Interpolate(Math.Log(value));
            Assert.That(actual, Is.Not.NaN);
        }
 public void SupportsLinearCase(int samples)
 {
     double[] x, y, xtest, ytest;
     LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples);
     IInterpolation interpolation = new NevillePolynomialInterpolation(x, y);
     for (int i = 0; i < xtest.Length; i++)
     {
         Assert.AreEqual(ytest[i], interpolation.Interpolate(xtest[i]), 1e-12, "Linear with {0} samples, sample {1}", samples, i);
     }
 }