Skip to content
Snippets Groups Projects
Commit 750b8dc1 authored by wenqing's avatar wenqing
Browse files

[Curve] Use std::adjacent_find to check data

parent 4a4cfa9c
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
#include <limits> #include <limits>
#include <utility> #include <utility>
#include "BaseLib/Error.h"
#include "BaseLib/quicksort.h" #include "BaseLib/quicksort.h"
#include "PiecewiseLinearInterpolation.h" #include "PiecewiseLinearInterpolation.h"
namespace MathLib namespace MathLib
...@@ -33,15 +35,14 @@ PiecewiseLinearInterpolation::PiecewiseLinearInterpolation( ...@@ -33,15 +35,14 @@ PiecewiseLinearInterpolation::PiecewiseLinearInterpolation(
_supp_pnts, static_cast<std::size_t>(0), _supp_pnts.size(), _supp_pnts, static_cast<std::size_t>(0), _supp_pnts.size(),
_values_at_supp_pnts); _values_at_supp_pnts);
} }
for (std::size_t i=0; i<_supp_pnts.size()-1; i++)
const auto it = std::adjacent_find(_supp_pnts.begin(), _supp_pnts.end());
if (it != _supp_pnts.end())
{ {
if (std::fabs(_supp_pnts[i+1] - _supp_pnts[i]) const std::size_t i = std::distance(_supp_pnts.begin(), it);
< std::numeric_limits<double>::epsilon()) OGS_FATAL("Variable %d and variable %d are the same. "
{ "Piecewise linear interpolation is not possible\n",
OGS_FATAL("Variable %d and variable %d are the same. " i, i+1);
"Piecewise linear interpolation is not possible\n",
i, i+1);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment