diff --git a/include/omath/linear_algebra/mat.hpp b/include/omath/linear_algebra/mat.hpp index 0c732a4..20501d4 100644 --- a/include/omath/linear_algebra/mat.hpp +++ b/include/omath/linear_algebra/mat.hpp @@ -377,12 +377,12 @@ namespace omath cache_friendly_multiply_row_major(const Mat& other) const { Mat result; - for (std::size_t i = 0; i < Rows; ++i) - for (std::size_t k = 0; k < Columns; ++k) + for (std::size_t row_index = 0; row_index < Rows; ++row_index) + for (std::size_t column_index = 0; column_index < Columns; ++column_index) { - const Type aik = at(i, k); - for (std::size_t j = 0; j < OtherColumns; ++j) - result.at(i, j) += aik * other.at(k, j); + const Type current_number = at(row_index, column_index); + for (std::size_t other_column = 0; other_column < OtherColumns; ++other_column) + result.at(row_index, other_column) += current_number * other.at(column_index, other_column); } return result; } @@ -392,12 +392,12 @@ namespace omath const Mat& other) const { Mat result; - for (std::size_t j = 0; j < OtherColumns; ++j) - for (std::size_t k = 0; k < Columns; ++k) + for (std::size_t other_column = 0; other_column < OtherColumns; ++other_column) + for (std::size_t column_index = 0; column_index < Columns; ++column_index) { - const Type bkj = other.at(k, j); - for (std::size_t i = 0; i < Rows; ++i) - result.at(i, j) += at(i, k) * bkj; + const Type current_number = other.at(column_index, other_column); + for (std::size_t row_index = 0; row_index < Rows; ++row_index) + result.at(row_index, other_column) += at(row_index, column_index) * current_number; } return result; }