From 41bc867a4dc7f4297b62cc83781864af90f22595 Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Fri, 14 Oct 2016 12:54:59 +0200 Subject: [PATCH] optimization - poly_min_extrap fixed for a specific case (#291) If temp is nonzero but a subnormal then temp2 matrix may contain infinities which may cause temp assignment in line 225 to be a NaN (as a difference of two positive infinities). --- dlib/optimization/optimization_line_search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlib/optimization/optimization_line_search.h b/dlib/optimization/optimization_line_search.h index b25d7d1e2..a91e3df84 100644 --- a/dlib/optimization/optimization_line_search.h +++ b/dlib/optimization/optimization_line_search.h @@ -212,7 +212,7 @@ namespace dlib double temp = aa2*aa1*(x1-x2); // just take a guess if this happens - if (temp == 0) + if (temp == 0 || std::fpclassify(temp) == FP_SUBNORMAL) { return x1/2.0; }