mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Add and fix additional test case
This commit is contained in:
@@ -23,11 +23,11 @@ RealType logistic_sigmoid(RealType x, const Policy&)
|
||||
|
||||
if(-x >= tools::log_max_value<RealType>())
|
||||
{
|
||||
return RealType{0};
|
||||
return static_cast<RealType>(0);
|
||||
}
|
||||
if(-x <= -tools::log_max_value<RealType>())
|
||||
{
|
||||
return RealType{1};
|
||||
return static_cast<RealType>(1);
|
||||
}
|
||||
|
||||
const auto res {static_cast<RealType>(1 / (1 + exp(static_cast<promoted_real_type>(-x))))};
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <boost/math/special_functions/logistic_sigmoid.hpp>
|
||||
#include <boost/multiprecision/cpp_bin_float.hpp>
|
||||
#include <boost/multiprecision/cpp_dec_float.hpp>
|
||||
#include "math_unit_test.hpp"
|
||||
#include <array>
|
||||
#include <cfloat>
|
||||
@@ -24,11 +25,11 @@ void test()
|
||||
0.75
|
||||
};
|
||||
const std::array<RealType, 5> y_values = {
|
||||
RealType{1} / 2,
|
||||
RealType{0.73105857863000487925115924182183627436514464016505651927636590791904045307},
|
||||
RealType{1},
|
||||
RealType{0.62245933120185456463890056574550847875327936530891016305943716265854500},
|
||||
RealType{0.6791786991753929731596801157765790212342212482195760219829517436805}
|
||||
static_cast<RealType>(1) / 2,
|
||||
static_cast<RealType>(0.73105857863000487925115924182183627436514464016505651927636590791904045307),
|
||||
static_cast<RealType>(1),
|
||||
static_cast<RealType>(0.62245933120185456463890056574550847875327936530891016305943716265854500),
|
||||
static_cast<RealType>(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<RealType>(1e-15));
|
||||
}
|
||||
|
||||
bool fe {false};
|
||||
@@ -83,5 +85,7 @@ int main()
|
||||
std::feclearexcept(FE_ALL_EXCEPT);
|
||||
test<boost::multiprecision::cpp_bin_float_quad>();
|
||||
|
||||
test<boost::multiprecision::cpp_dec_float_50>();
|
||||
|
||||
return boost::math::test::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user