define FLT_EPSILON; be descriptive about upper_right_triangle() method

This commit is contained in:
TSC21
2019-02-24 17:14:05 +00:00
committed by Nuno Marques
parent 7355a29a2a
commit ec436d5aee
11 changed files with 43 additions and 40 deletions
+4 -4
View File
@@ -66,8 +66,8 @@ public:
return res;
}
// get matrix upper right triangle
Vector<Type, M * (M + 1) / 2> urt() const
// get matrix upper right triangle in a row-major vector format
Vector<Type, M * (M + 1) / 2> upper_right_triangle() const
{
Vector<Type, M * (M + 1) / 2> res;
const SquareMatrix<Type, M> &self = *this;
@@ -149,7 +149,7 @@ bool inv(const SquareMatrix<Type, M> & A, SquareMatrix<Type, M> & inv)
for (size_t n = 0; n < M; n++) {
// if diagonal is zero, swap with row below
if (fabs(static_cast<float>(U(n, n))) < __FLT_EPSILON__) {
if (fabs(static_cast<float>(U(n, n))) < FLT_EPSILON) {
//printf("trying pivot for row %d\n",n);
for (size_t i = n + 1; i < M; i++) {
@@ -174,7 +174,7 @@ bool inv(const SquareMatrix<Type, M> & A, SquareMatrix<Type, M> & inv)
#endif
// failsafe, return zero matrix
if (fabs(static_cast<float>(U(n, n))) < __FLT_EPSILON__) {
if (fabs(static_cast<float>(U(n, n))) < FLT_EPSILON) {
return false;
}
+4
View File
@@ -15,6 +15,10 @@
namespace matrix {
#if !defined(FLT_EPSILON)
#define FLT_EPSILON __FLT_EPSILON__
#endif
#if defined(__PX4_NUTTX)
/*
* NuttX has no usable C++ math library, so we need to provide the needed definitions here manually.