/// <summary>
        /// The read file.
        /// </summary>
        /// <param name="fileLocation">
        /// The file location.
        /// </param>
        /// <returns>
        /// The <see cref="IInterpolation"/>.
        /// </returns>
        public static IInterpolation ReadFile(string fileLocation)
        {
            FileInfo fileInfo = new FileInfo(fileLocation);

            List<double> xValues = new List<double>();
            List<double> yValues = new List<double>();

            using (TextReader reader = new StreamReader(fileInfo.FullName))
            {
                string line;
                while((line = reader.ReadLine()) != null)
                {
                    string[] splitLine = line.Split(',');

                    double xValue = double.Parse(splitLine[0]);
                    double yValue = double.Parse(splitLine[1]);

                    xValues.Add(xValue);
                    yValues.Add(yValue);
                }
            }

            IInterpolation interpolation = new StepInterpolation(xValues.ToArray(), yValues.ToArray());

            return interpolation;
        }
 public void FitsAtSamplePoints()
 {
     IInterpolation ip = new StepInterpolation(_t, _y);
     for (int i = 0; i < _y.Length; i++)
     {
         Assert.AreEqual(_y[i], ip.Interpolate(_t[i]), "A Exact Point " + i);
     }
 }
 public void FirstDerivative()
 {
     IInterpolation ip = new StepInterpolation(_t, _y);
     Assert.That(ip.Differentiate(-3.0), Is.EqualTo(0.0));
     Assert.That(ip.Differentiate(-2.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(-1.5), Is.EqualTo(0.0));
     Assert.That(ip.Differentiate(-1.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(-0.5), Is.EqualTo(0.0));
     Assert.That(ip.Differentiate(0.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(0.5), Is.EqualTo(0.0));
     Assert.That(ip.Differentiate(1.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(2.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(3.0), Is.EqualTo(double.NaN));
     Assert.That(ip.Differentiate(4.0), Is.EqualTo(0.0));
 }
 public void DefiniteIntegral()
 {
     IInterpolation ip = new StepInterpolation(_t, _y);
     Assert.That(ip.Integrate(-3.0, -2.0), Is.EqualTo(0.0));
     Assert.That(ip.Integrate(-2.0, -1.0), Is.EqualTo(1.0));
     Assert.That(ip.Integrate(-1.0, 0.0), Is.EqualTo(2.0));
     Assert.That(ip.Integrate(0.0, 1.0), Is.EqualTo(-1.0));
     Assert.That(ip.Integrate(1.0, 2.0), Is.EqualTo(0.0));
     Assert.That(ip.Integrate(2.0, 3.0), Is.EqualTo(1.0));
     Assert.That(ip.Integrate(3.0, 4.0), Is.EqualTo(0.0));
     Assert.That(ip.Integrate(0.0, 4.0), Is.EqualTo(0.0));
     Assert.That(ip.Integrate(-3.0, -1.0), Is.EqualTo(1.0));
     Assert.That(ip.Integrate(-3.0, 4.0), Is.EqualTo(3.0));
     Assert.That(ip.Integrate(0.5, 1.5), Is.EqualTo(-0.5));
     Assert.That(ip.Integrate(-1.5, -0.5), Is.EqualTo(1.5));
     Assert.That(ip.Integrate(3.0, 4.0), Is.EqualTo(0.0));
 }