diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 7cbc5ea753..70bcea5ef7 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -355,7 +355,13 @@ public: template Matrix slice(size_t x0, size_t y0) const { - Matrix res(&(_data[x0][y0])); + Matrix &self = *this; + Matrix res; //default constructed + for (size_t i = 0; i < P; i++) { + for (size_t j = 0; j < Q; j++) { + res(i, j) = self(i + x0, j + y0); + } + } return res; }