Commit 0eff2b5e authored by Lukas Riedel's avatar Lukas Riedel

Replace 'transform' with for-loops in lin interpolator

This increases readability.
parent 8e01e9de
......@@ -207,10 +207,9 @@ private:
const
{
Domain pos_diff;
std::transform(pos_unit.begin(), pos_unit.end(),
begin(indices),
pos_diff.begin(),
std::minus<DF>());
for (size_t i = 0; i < pos_unit.size(); ++i) {
pos_diff[i] = pos_unit[i] - indices[i];
}
return pos_diff;
}
......@@ -222,20 +221,13 @@ private:
const Domain& pos_unit
) const
{
MultiIdx idx_lower;
std::transform(pos_unit.begin(), pos_unit.end(),
begin(idx_lower),
[](const auto value){
return std::max(std::floor(value), 0.0);
});
MultiIdx idx_upper;
std::transform(pos_unit.begin(), pos_unit.end(),
begin(this->_shape),
begin(idx_upper),
[](const auto value, const auto max){
return std::min<double>(std::ceil(value), max-1);
});
// round mesh unit positions up and down
MultiIdx idx_lower, idx_upper;
for (size_t i = 0; i < idx_lower.size(); ++i) {
idx_lower[i] = std::max(std::floor(pos_unit[i]), 0.0);
idx_upper[i] = std::min<size_t>(std::ceil(pos_unit[i]),
this->_shape[i]-1);
}
return std::make_pair(idx_lower, idx_upper);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment