Last active
January 6, 2020 19:28
-
-
Save JohanMabille/86149df73602d64642cf57db730e9301 to your computer and use it in GitHub Desktop.
xtensor_8_N_14.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <layout_type L> | |
struct stepper_tools | |
{ | |
template <class S, class IT, class ST> | |
static void increment_stepper(S& stepper, | |
IT& index, | |
const ST& shape); | |
}; | |
template <> | |
template <class S, class IT, class ST> | |
void stepper_tools<layout_type::row_major>::increment_stepper(S& stepper, | |
IT& index, | |
const ST& shape) | |
{ | |
using size_type = typename S::size_type; | |
size_type i = index.size(); | |
while (i != 0) | |
{ | |
--i; | |
if (index[i] != shape[i] - 1) | |
{ | |
++index[i]; | |
stepper.step(i); | |
return; | |
} | |
else | |
{ | |
index[i] = 0; | |
if (i != 0) | |
{ | |
stepper.reset(i); | |
} | |
} | |
} | |
if (i == 0) | |
{ | |
std::copy(shape.cbegin(), shape.cend(), index.begin()); | |
stepper.to_end(layout_type::row_major); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment