From 3f2d3cf58ddcb3c0f349307a54d80b843ef316b9 Mon Sep 17 00:00:00 2001 From: Bart Slinger Date: Wed, 12 Sep 2018 20:49:48 +0200 Subject: [PATCH] fix a div/0 condition --- matrix/LeastSquaresSolver.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix/LeastSquaresSolver.hpp b/matrix/LeastSquaresSolver.hpp index 880a7c9481..266e2ebe40 100644 --- a/matrix/LeastSquaresSolver.hpp +++ b/matrix/LeastSquaresSolver.hpp @@ -51,7 +51,7 @@ public: // prevent divide by zero // also covers u1. normx is never negative if (normx < 1e-8f) { - return; + break; } float w[M] = {}; w[0] = 1.0f; @@ -128,6 +128,7 @@ public: for (size_t z = 0; z < N; z++) { x(z) = 0.0f; } + break; } x(i) = x(i) / _A(i,i); }