matrix: more readable temps for matrix mul

This commit is contained in:
Danny Robson 2014-12-15 13:43:22 +11:00
parent 253be704cb
commit 82f318c8ad

View File

@ -309,12 +309,15 @@ template <typename T>
matrix<T> matrix<T>
matrix<T>::operator* (const matrix<T> &rhs) const { matrix<T>::operator* (const matrix<T> &rhs) const {
matrix<T> m; matrix<T> m;
memset (m.values, 0, sizeof (m.values));
for (unsigned i = 0; i < 4; ++i) for (unsigned row = 0; row < 4; ++row) {
for (unsigned j = 0; j < 4; ++j) for (unsigned col = 0; col < 4; ++col) {
for (unsigned k = 0; k < 4; ++k) m.values[row][col] = T {0};
m.values[i][j] += values[i][k] * rhs.values[k][j];
for (unsigned inner = 0; inner < 4; ++inner)
m.values[row][col] += values[row][inner] * rhs.values[inner][col];
}
}
return m; return m;
} }