Exemplo n.º 1
0
        public void FitsAtSamplePoints()
        {
            IInterpolation it = CubicSpline.InterpolatePchip(_t, _y);

            for (int i = 0; i < _y.Length; i++)
            {
                Assert.AreEqual(_y[i], it.Interpolate(_t[i]), "A Exact Point " + i);
            }
        }
Exemplo n.º 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 = CubicSpline.InterpolatePchip(x, y);

            for (int i = 0; i < xtest.Length; i++)
            {
                Assert.AreEqual(ytest[i], it.Interpolate(xtest[i]), 1e-15, "Linear with {0} samples, sample {1}", samples, i);
            }
        }
Exemplo n.º 3
0
        public void InterpolateCurvePchip()
        {
            List <SensitivityPoint> smoothCurve = new List <SensitivityPoint>();

            double[]    timestamp   = sensCurve.Select(sensCurve => sensCurve.timeStamp).ToArray();
            double[]    randomsense = sensCurve.Select(sensCurve => sensCurve.sensitivity).ToArray();
            CubicSpline spline      = CubicSpline.InterpolatePchip(timestamp, randomsense);

            for (double timecode = 0; timecode < this.lenght; timecode += timestep)
            {
                SensitivityPoint sensPoint = new SensitivityPoint(timecode, spline.Interpolate(timecode));
                smoothCurve.Add(sensPoint);
            }
            sensCurve = smoothCurve;
        }
Exemplo n.º 4
0
        public void FitsAtNagExamplePoints(double t, double x, double maxAbsoluteError)
        {
            IInterpolation it = CubicSpline.InterpolatePchip(_tNag, _yNag);

            Assert.AreEqual(x, it.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t);
        }
Exemplo n.º 5
0
        public void FitsAtArbitraryPoints(double t, double x, double maxAbsoluteError)
        {
            IInterpolation it = CubicSpline.InterpolatePchip(_t, _y);

            Assert.AreEqual(x, it.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t);
        }
Exemplo n.º 6
0
 public void FewSamples()
 {
     Assert.That(() => CubicSpline.InterpolatePchip(new double[0], new double[0]), Throws.ArgumentException);
     Assert.That(() => CubicSpline.InterpolatePchip(new double[2], new double[2]), Throws.ArgumentException);
     Assert.That(CubicSpline.InterpolatePchip(new[] { 1.0, 2.0, 3.0 }, new[] { 2.0, 2.0, 2.0 }).Interpolate(1.0), Is.EqualTo(2.0));
 }