Browse Source

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

master
Lorenz Meier 8 years ago
parent
commit
2283e6946a
  1. 6
      matrix/SquareMatrix.hpp

6
matrix/SquareMatrix.hpp

@ -142,12 +142,12 @@ bool inv(const SquareMatrix<Type, M> & A, SquareMatrix<Type, M> & inv) @@ -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) @@ -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;
}

Loading…
Cancel
Save