diff --git a/include/cenet/math/ops.hpp b/include/cenet/math/ops.hpp index 199ac3e..a61e9a0 100644 --- a/include/cenet/math/ops.hpp +++ b/include/cenet/math/ops.hpp @@ -195,8 +195,9 @@ struct transpose { template constexpr auto operator()(std::size_t index, const E& expr) const { + const std::size_t rows = expr.shape().template get<0>(); const std::size_t cols = expr.shape().template get<1>(); - return expr.coeff(((index % cols) * cols) + (index / cols)); + return expr.coeff(((index % rows) * cols) + (index / rows)); } };