diff --git a/include/math/mat.tpp b/include/math/mat.tpp index c7a7342..40a4eaf 100644 --- a/include/math/mat.tpp +++ b/include/math/mat.tpp @@ -281,10 +281,10 @@ namespace math{ using res_t = decltype(std::declval() * std::declval()); matrix res(zero_initialize); size_t index = 0; - for(size_t i = 0; i < left.rows(); ++i){ - for(size_t j = 0; j < right.columns(); ++j){ - for(size_t k = 0; k < right.rows(); ++k){ - res.get(index) += left[i][k] * right[k][j]; + for(size_t i = 0; i < right.rows(); ++i){ + for(size_t j = 0; j < left.columns(); ++j){ + for(size_t k = 0; k < left.rows(); ++k){ + res.get(index) += right.get(i, k) * left.get(k, j); } ++index; }