diff --git a/src/Numerics/Interpolation/Algorithms/BarycentricInterpolation.cs b/src/Numerics/Interpolation/Algorithms/BarycentricInterpolation.cs index 981760f1..3a588545 100644 --- a/src/Numerics/Interpolation/Algorithms/BarycentricInterpolation.cs +++ b/src/Numerics/Interpolation/Algorithms/BarycentricInterpolation.cs @@ -166,8 +166,9 @@ namespace MathNet.Numerics.Interpolation.Algorithms } // trivial case: on a known sample point? - if (offset.AlmostZero()) + if (offset == 0.0) { + // NOTE (cdrnet, 200908) not offset.AlmostZero() by design return _values[closestPoint]; } diff --git a/src/UnitTests/InterpolationTests/InterpolationFunctionalContract.cs b/src/UnitTests/InterpolationTests/InterpolationFunctionalContract.cs index 8f5a4e66..26f1ecbc 100644 --- a/src/UnitTests/InterpolationTests/InterpolationFunctionalContract.cs +++ b/src/UnitTests/InterpolationTests/InterpolationFunctionalContract.cs @@ -69,8 +69,8 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests "InterpolationMatchesNodePoints", () => { - var points = new List { 1, 2, 2.3, 3, 8 }; - var values = new List { 50, 20, 30, 10, -20 }; + var points = new List { -0.2, 0, 1, 2, 2.3, 3, 8 }; + var values = new List { -10, 5, 50, 20, 30, 10, -20 }; var interpolation = Factory(points, values); for (int i = 0; i < points.Count; i++) @@ -79,6 +79,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests values[i], interpolation.Interpolate(points[i]), 1e-12); + + Assert.AreApproximatelyEqual( + values[i], + interpolation.Interpolate(points[i].Increment(50)), + 1e-8); } }); }