diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index d5a3db04232e465a852816b066bb9b8195b86072..5f5e4a7bdbceba3ea0d1b32a2a4f0b8c052e1800 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -68,7 +68,7 @@ double PiecewiseLinearInterpolation::getValue(double pnt_to_interpolate) const _values_at_supp_pnts[interval_idx]; } -double PiecewiseLinearInterpolation::GetDerivative( +double PiecewiseLinearInterpolation::getDerivative( double const pnt_to_interpolate) const { if (pnt_to_interpolate < _supp_pnts.front() || @@ -84,18 +84,18 @@ double PiecewiseLinearInterpolation::GetDerivative( // interval_idx = interval_max - 1 - interval_idx; if (interval_idx > 1 && interval_idx < _supp_pnts.size() - 2) { - double const slope_right = + double const tangent_right = (_values_at_supp_pnts[interval_idx] - _values_at_supp_pnts[interval_idx + 2]) / (_supp_pnts[interval_idx] - _supp_pnts[interval_idx + 2]); - double const slope_left = + double const tangent_left = (_values_at_supp_pnts[interval_idx - 1] - _values_at_supp_pnts[interval_idx + 1]) / (_supp_pnts[interval_idx - 1] - _supp_pnts[interval_idx + 1]); double const w = (pnt_to_interpolate - _supp_pnts[interval_idx + 1]) / (_supp_pnts[interval_idx] - _supp_pnts[interval_idx + 1]); - return (1. - w) * slope_right + w * slope_left; + return (1. - w) * tangent_right + w * tangent_left; } else { diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h index 5338582b1d17e4b7178c307649ecb1eded48aa76..0f96ad1811e84acf4a7f8df2c51445e97ae8cd76 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h @@ -70,13 +70,13 @@ public: * \f$x_{\max} = \max_{1 \le j \le n} x_j\f$. when points are located * outside of this interval * the derivative is set to 0 - * \attention if the points is located between the first and second points + * \attention if the points are located between the first and second points * (or last and second to last point), the derivative is calculated by * simple linear interpolation * otherwise, it is calculated by second order of interpolation with central * difference */ - double GetDerivative(double pnt_to_interpolate) const; + double getDerivative(double const pnt_to_interpolate) const; private: std::vector<double> _supp_pnts; diff --git a/Tests/MathLib/TestPiecewiseLinearInterpolation.cpp b/Tests/MathLib/TestPiecewiseLinearInterpolation.cpp index 26438d514c2d67c855c47c6ed1d274a4ad5d7c47..e29fc0e0fc720aa106ace9f2b6da64f69ee87e0b 100644 --- a/Tests/MathLib/TestPiecewiseLinearInterpolation.cpp +++ b/Tests/MathLib/TestPiecewiseLinearInterpolation.cpp @@ -139,14 +139,14 @@ TEST(MathLibInterpolationAlgorithms, PiecewiseLinearInterpolationDerivative) // Interpolation for (std::size_t k(0); k < size - 1; ++k) { - ASSERT_NEAR(1 + 2 * k, interpolation.GetDerivative(k + 0.5), + ASSERT_NEAR(1 + 2 * k, interpolation.getDerivative(k + 0.5), std::numeric_limits<double>::epsilon()); } // Extrapolation - ASSERT_NEAR(0, interpolation.GetDerivative(-1), + ASSERT_NEAR(0, interpolation.getDerivative(-1), std::numeric_limits<double>::epsilon()); // Extrapolation - ASSERT_NEAR(0, interpolation.GetDerivative(1001), + ASSERT_NEAR(0, interpolation.getDerivative(1001), std::numeric_limits<double>::epsilon()); }