mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 12:03:34 +08:00
lib: matrix: SquareMatrix: Deal with the special case of M=1
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
committed by
Beat Küng
parent
724f5a97a9
commit
39e04d9712
@@ -322,6 +322,19 @@ SquareMatrix<Type, M> expm(const Matrix<Type, M, M> &A, size_t order = 5)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deal with the special case where the square matrix is 1
|
||||||
|
*/
|
||||||
|
template<typename Type>
|
||||||
|
bool inv(const SquareMatrix<Type, 1> &A, SquareMatrix<Type, 1> &inv, size_t rank = 1)
|
||||||
|
{
|
||||||
|
if (std::fabs(A(0, 0)) < Type(FLT_EPSILON)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inv(0, 0) = Type(1) / A(0, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inverse based on LU factorization with partial pivotting
|
* inverse based on LU factorization with partial pivotting
|
||||||
|
|||||||
Reference in New Issue
Block a user