diff --git a/include/boost/math/special_functions/logistic_sigmoid.hpp b/include/boost/math/special_functions/logistic_sigmoid.hpp index 8404beb78..925b576ca 100644 --- a/include/boost/math/special_functions/logistic_sigmoid.hpp +++ b/include/boost/math/special_functions/logistic_sigmoid.hpp @@ -23,11 +23,11 @@ RealType logistic_sigmoid(RealType x, const Policy&) if(-x >= tools::log_max_value()) { - return RealType{0}; + return static_cast(0); } if(-x <= -tools::log_max_value()) { - return RealType{1}; + return static_cast(1); } const auto res {static_cast(1 / (1 + exp(static_cast(-x))))}; diff --git a/test/math_unit_test.hpp b/test/math_unit_test.hpp index 648f7de9c..bd85caa86 100644 --- a/test/math_unit_test.hpp +++ b/test/math_unit_test.hpp @@ -58,7 +58,7 @@ bool check_mollified_close(Real expected, Real computed, Real tol, std::string c } using std::max; using std::abs; - Real denom = (max)(abs(expected), Real(1)); + Real denom = (max)(Real(abs(expected)), Real(1)); Real mollified_relative_error = abs(expected - computed)/denom; if (mollified_relative_error > tol) { diff --git a/test/test_logistic_sigmoid.cpp b/test/test_logistic_sigmoid.cpp index e3b056070..c0c8a0492 100644 --- a/test/test_logistic_sigmoid.cpp +++ b/test/test_logistic_sigmoid.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "math_unit_test.hpp" #include #include @@ -24,11 +25,11 @@ void test() 0.75 }; const std::array y_values = { - RealType{1} / 2, - RealType{0.73105857863000487925115924182183627436514464016505651927636590791904045307}, - RealType{1}, - RealType{0.62245933120185456463890056574550847875327936530891016305943716265854500}, - RealType{0.6791786991753929731596801157765790212342212482195760219829517436805} + static_cast(1) / 2, + static_cast(0.73105857863000487925115924182183627436514464016505651927636590791904045307), + static_cast(1), + static_cast(0.62245933120185456463890056574550847875327936530891016305943716265854500), + static_cast(0.6791786991753929731596801157765790212342212482195760219829517436805) }; for (std::size_t i = 0; i < x_values.size(); ++i) @@ -40,7 +41,8 @@ void test() } else { - CHECK_MOLLIFIED_CLOSE(test_value, y_values[i], 1e-15); + RealType comparison_value = y_values[i]; + CHECK_MOLLIFIED_CLOSE(test_value, comparison_value, static_cast(1e-15)); } bool fe {false}; @@ -83,5 +85,7 @@ int main() std::feclearexcept(FE_ALL_EXCEPT); test(); + test(); + return boost::math::test::report_errors(); }