mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 17:48:53 +08:00
Implement slice as copy loop
This commit is contained in:
committed by
Nuno Marques
parent
93375fbd3c
commit
eea6b59973
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user