mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 07:53:34 +08:00
helper: consider matrices with the same NANs and INFINITYs equal
to simplify bulk checks when these values are expected
This commit is contained in:
committed by
Julian Kent
parent
bbaa93880b
commit
c34e8dc98f
@@ -23,8 +23,8 @@ bool is_finite(Type x) {
|
||||
/**
|
||||
* Compare if two floating point numbers are equal
|
||||
*
|
||||
* Note: Smaller or EQUAL than is important to correctly
|
||||
* handle the comparison to infinite or nan.
|
||||
* NAN is considered equal to NAN and -NAN
|
||||
* INFINITY is considered equal INFINITY but not -INFINITY
|
||||
*
|
||||
* @param x right side of equality check
|
||||
* @param y left side of equality check
|
||||
@@ -36,7 +36,7 @@ bool isEqualF(const Type x, const Type y, const Type eps = 1e-4f)
|
||||
{
|
||||
return (matrix::fabs(x - y) <= eps)
|
||||
|| (isnan(x) && isnan(y))
|
||||
|| (isinf(x) && isinf(y));
|
||||
|| (isinf(x) && isinf(y) && isnan(x - y));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user