mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 05:37:35 +08:00
matrix: add method to check all values are nan (#82)
This commit is contained in:
committed by
Julian Kent
parent
84b3da227c
commit
cc084e0791
@@ -507,6 +507,17 @@ public:
|
||||
return min_val;
|
||||
}
|
||||
|
||||
bool isAllNan() const {
|
||||
const Matrix<float, M, N> &self = *this;
|
||||
bool result = true;
|
||||
for (size_t i = 0; i < M; i++) {
|
||||
for (size_t j = 0; j < N; j++) {
|
||||
result = result && isnan(self(i, j));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename Type, size_t M, size_t N>
|
||||
|
||||
@@ -30,6 +30,7 @@ int main()
|
||||
for(int i=0; i<9; i++) {
|
||||
TEST(isnan(m_nan.data()[i]));
|
||||
}
|
||||
TEST(m_nan.isAllNan());
|
||||
|
||||
float data2d[3][3] = {
|
||||
{1, 2, 3},
|
||||
@@ -40,6 +41,7 @@ int main()
|
||||
for(int i=0; i<9; i++) {
|
||||
TEST(fabs(data[i] - m2.data()[i]) < FLT_EPSILON);
|
||||
}
|
||||
TEST(!m2.isAllNan());
|
||||
|
||||
float data_times_2[9] = {2, 4, 6, 8, 10, 12, 14, 16, 18};
|
||||
Matrix3f m3(data_times_2);
|
||||
|
||||
Reference in New Issue
Block a user