mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 05:30:36 +08:00
Don't lose array sizes in copyTo
This commit is contained in:
+2
-2
@@ -90,9 +90,9 @@ public:
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void copyTo(Type (&dst)[M*N]) const
|
||||
void copyTo(Type dst [M*N]) const
|
||||
{
|
||||
memcpy(dst, _data, sizeof(dst));
|
||||
memcpy(dst, _data, sizeof(Type)*M*N);
|
||||
}
|
||||
|
||||
void copyToColumnMajor(Type (&dst)[M*N]) const
|
||||
|
||||
+8
-1
@@ -3,6 +3,13 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
namespace {
|
||||
void doTheCopy(const Matrix<float, 2, 3>& A, float array_A[6])
|
||||
{
|
||||
A.copyTo(array_A);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
float eps = 1e-6f;
|
||||
@@ -32,7 +39,7 @@ int main()
|
||||
A(1,1) = 5;
|
||||
A(1,2) = 6;
|
||||
float array_A[6] = {};
|
||||
A.copyTo(array_A);
|
||||
doTheCopy(A, array_A);
|
||||
float array_row[6] = {1, 2, 3, 4, 5, 6};
|
||||
for (size_t i = 0; i < 6; i++) {
|
||||
TEST(fabs(array_A[i] - array_row[i]) < eps);
|
||||
|
||||
Reference in New Issue
Block a user