Matrix inversion: Ensure that null check is done against the same type

This commit is contained in:
Lorenz Meier
2017-02-04 10:42:10 +01:00
parent 843be9418b
commit 2283e6946a
+3 -3
View File
@@ -142,12 +142,12 @@ 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 (fabsf(U(n, n)) < 1e-8f) {
if (fabsf(static_cast<float>(U(n, n))) < 1e-8f) {
//printf("trying pivot for row %d\n",n);
for (size_t i = n + 1; i < M; i++) {
//printf("\ttrying row %d\n",i);
if (fabsf(U(i, n)) > 1e-8f) {
if (fabsf(static_cast<float>(U(i, n))) > 1e-8f) {
//printf("swapped %d\n",i);
U.swapRows(i, n);
P.swapRows(i, n);
@@ -167,7 +167,7 @@ bool inv(const SquareMatrix<Type, M> & A, SquareMatrix<Type, M> & inv)
#endif
// failsafe, return zero matrix
if (fabsf(U(n, n)) < 1e-8f) {
if (fabsf(static_cast<float>(U(n, n))) < 1e-8f) {
return false;
}