Implement slice as copy loop

This commit is contained in:
Oskar Weigl
2019-03-08 19:17:40 +00:00
committed by Nuno Marques
parent 93375fbd3c
commit eea6b59973
+7 -1
View File
@@ -355,7 +355,13 @@ public:
template<size_t P, size_t Q>
Matrix<Type, P, Q> slice(size_t x0, size_t y0) const
{
Matrix<Type, P, Q> res(&(_data[x0][y0]));
Matrix<Type, M, N> &self = *this;
Matrix<Type, P, Q> 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;
}