mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 22:18:53 +08:00
add braces around statements and cleanup formatting (#107)
This commit is contained in:
+16
-8
@@ -587,9 +587,13 @@ Type min(const Type x, const Type y) {
|
|||||||
bool x_is_nan = isnan(x);
|
bool x_is_nan = isnan(x);
|
||||||
bool y_is_nan = isnan(y);
|
bool y_is_nan = isnan(y);
|
||||||
// z > nan for z != nan is required by C the standard
|
// z > nan for z != nan is required by C the standard
|
||||||
if(x_is_nan || y_is_nan) {
|
if (x_is_nan || y_is_nan) {
|
||||||
if(x_is_nan && !y_is_nan) return y;
|
if (x_is_nan && !y_is_nan) {
|
||||||
if(!x_is_nan && y_is_nan) return x;
|
return y;
|
||||||
|
}
|
||||||
|
if (!x_is_nan && y_is_nan) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
return (x < y) ? x : y;
|
return (x < y) ? x : y;
|
||||||
@@ -599,16 +603,20 @@ Type max(const Type x, const Type y) {
|
|||||||
bool x_is_nan = isnan(x);
|
bool x_is_nan = isnan(x);
|
||||||
bool y_is_nan = isnan(y);
|
bool y_is_nan = isnan(y);
|
||||||
// z > nan for z != nan is required by C the standard
|
// z > nan for z != nan is required by C the standard
|
||||||
if(x_is_nan || y_is_nan) {
|
if (x_is_nan || y_is_nan) {
|
||||||
if(x_is_nan && !y_is_nan) return y;
|
if (x_is_nan && !y_is_nan) {
|
||||||
if(!x_is_nan && y_is_nan) return x;
|
return y;
|
||||||
|
}
|
||||||
|
if (!x_is_nan && y_is_nan) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
return (x > y) ? x : y;
|
return (x > y) ? x : y;
|
||||||
}
|
}
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
Type constrain(const Type x, const Type lower_bound, const Type upper_bound) {
|
Type constrain(const Type x, const Type lower_bound, const Type upper_bound) {
|
||||||
if(lower_bound > upper_bound) {
|
if (lower_bound > upper_bound) {
|
||||||
return NAN;
|
return NAN;
|
||||||
} else if(isnan(x)) {
|
} else if(isnan(x)) {
|
||||||
return NAN;
|
return NAN;
|
||||||
@@ -677,7 +685,7 @@ Matrix<Type, M, N> constrain(const Matrix<Type, M, N> &x,
|
|||||||
const Type scalar_lower_bound,
|
const Type scalar_lower_bound,
|
||||||
const Type scalar_upper_bound) {
|
const Type scalar_upper_bound) {
|
||||||
Matrix<Type,M,N> m;
|
Matrix<Type,M,N> m;
|
||||||
if(scalar_lower_bound > scalar_upper_bound) {
|
if (scalar_lower_bound > scalar_upper_bound) {
|
||||||
m.setNaN();
|
m.setNaN();
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < M; i++) {
|
for (size_t i = 0; i < M; i++) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
inline SquareMatrix<Type, M> I() const
|
inline SquareMatrix<Type, M> I() const
|
||||||
{
|
{
|
||||||
SquareMatrix<Type, M> i;
|
SquareMatrix<Type, M> i;
|
||||||
if(inv(*this, i)) {
|
if (inv(*this, i)) {
|
||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
i.setZero();
|
i.setZero();
|
||||||
@@ -289,7 +289,7 @@ template<typename Type, size_t M>
|
|||||||
SquareMatrix<Type, M> inv(const SquareMatrix<Type, M> & A)
|
SquareMatrix<Type, M> inv(const SquareMatrix<Type, M> & A)
|
||||||
{
|
{
|
||||||
SquareMatrix<Type, M> i;
|
SquareMatrix<Type, M> i;
|
||||||
if(inv(A, i)) {
|
if (inv(A, i)) {
|
||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
i.setZero();
|
i.setZero();
|
||||||
|
|||||||
Reference in New Issue
Block a user