mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 18:53:34 +08:00
More testing.
This commit is contained in:
@@ -194,6 +194,11 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
inline Matrix<Type, M, N> operator-(Type scalar) const
|
||||
{
|
||||
return (*this) + (-1*scalar);
|
||||
}
|
||||
|
||||
void operator*=(Type scalar)
|
||||
{
|
||||
Matrix<Type, M, N> &self = *this;
|
||||
@@ -211,6 +216,17 @@ public:
|
||||
self = self * (1.0f / scalar);
|
||||
}
|
||||
|
||||
inline void operator+=(Type scalar)
|
||||
{
|
||||
*this = (*this) + scalar;
|
||||
}
|
||||
|
||||
inline void operator-=(Type scalar)
|
||||
{
|
||||
*this = (*this) - scalar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Misc. Functions
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,30 @@ int main()
|
||||
Matrix3f m2(data);
|
||||
m2.print();
|
||||
|
||||
for(int i=0; i<9; i++) {
|
||||
assert(fabs(data[i] - m2.data()[i]) < 1e-6f);
|
||||
}
|
||||
|
||||
float data_times_2[9] = {2, 4, 6, 8, 10, 12, 14, 16, 18};
|
||||
Matrix3f m3(data_times_2);
|
||||
|
||||
assert(m == m2);
|
||||
assert(!(m == m3));
|
||||
|
||||
m2 *= 2;
|
||||
assert(m2 == m3);
|
||||
|
||||
m2 /= 2;
|
||||
m2 -= 1;
|
||||
float data_minus_1[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
assert(Matrix3f(data_minus_1) == m2);
|
||||
|
||||
m2 += 1;
|
||||
assert(Matrix3f(data) == m2);
|
||||
|
||||
m3 -= m2;
|
||||
|
||||
assert(m3 == m2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user