From 3ac0b8e24efac4b333a1957f99356895fdb32261 Mon Sep 17 00:00:00 2001 From: Yonghui <huangyh56@gmail.com> Date: Sun, 9 Oct 2016 00:02:31 +0200 Subject: [PATCH] fix typo --- .../PiecewiseLinearInterpolation.cpp | 8 ++++---- .../PiecewiseLinearInterpolation.h | 4 ++-- Tests/MathLib/TestPiecewiseLinearInterpolation.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index d5a3db04232..5f5e4a7bdbc 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 5338582b1d1..0f96ad1811e 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 26438d514c2..e29fc0e0fc7 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()); } -- GitLab