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); } }
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); } }
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; }
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); }
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); }
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)); }