diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index e799591da..3e4da4b59 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -38,7 +38,6 @@ See @ref matrix-vector for brief introduction. @configurationvalueref{Magnum::Math::Matrix} @todo @c PERFORMANCE - loop unrolling for Matrix<3, T> and Matrix<4, T> -@todo first col, then row (cache adjacency) */ template class Matrix: public RectangularMatrix { public: @@ -104,8 +103,8 @@ template class Matrix: public RectangularMatrix { Matrix ij(size_t skipCol, size_t skipRow) const { Matrix out(Matrix::Zero); - for(size_t row = 0; row != size-1; ++row) - for(size_t col = 0; col != size-1; ++col) + for(size_t col = 0; col != size-1; ++col) + for(size_t row = 0; row != size-1; ++row) out(col, row) = (*this)(col + (col >= skipCol), row + (row >= skipRow)); @@ -137,8 +136,8 @@ template class Matrix: public RectangularMatrix { T _determinant = determinant(); - for(size_t row = 0; row != size; ++row) - for(size_t col = 0; col != size; ++col) + for(size_t col = 0; col != size; ++col) + for(size_t row = 0; row != size; ++row) out(col, row) = (((row+col) & 1) ? -1 : 1)*ij(row, col).determinant()/_determinant; return out; diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h index 770862565..ef195df05 100644 --- a/src/Math/RectangularMatrix.h +++ b/src/Math/RectangularMatrix.h @@ -281,8 +281,8 @@ template class RectangularMatrix { template RectangularMatrix operator*(const RectangularMatrix& other) const { RectangularMatrix out; - for(size_t row = 0; row != rows; ++row) - for(size_t col = 0; col != size; ++col) /** @todo swap */ + for(size_t col = 0; col != size; ++col) + for(size_t row = 0; row != rows; ++row) for(size_t pos = 0; pos != cols; ++pos) out(col, row) += (*this)(pos, row)*other(col, pos);