File indexing completed on 2026-08-17 08:48:56
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_MATH_SF_EXPIT_HPP
0008 #define BOOST_MATH_SF_EXPIT_HPP
0009
0010 #include <boost/math/policies/policy.hpp>
0011 #include <boost/math/tools/precision.hpp>
0012 #include <cmath>
0013
0014 namespace boost {
0015 namespace math {
0016
0017 template <typename RealType, typename Policy>
0018 RealType logistic_sigmoid(RealType x, const Policy&)
0019 {
0020 BOOST_MATH_STD_USING
0021
0022 using promoted_real_type = typename policies::evaluation<RealType, Policy>::type;
0023
0024 if(-x >= tools::log_max_value<RealType>())
0025 {
0026 return static_cast<RealType>(0);
0027 }
0028 if(-x <= -tools::log_max_value<RealType>())
0029 {
0030 return static_cast<RealType>(1);
0031 }
0032
0033 const auto res {static_cast<RealType>(1 / (1 + exp(static_cast<promoted_real_type>(-x))))};
0034 return res;
0035 }
0036
0037 template <typename RealType>
0038 RealType logistic_sigmoid(RealType x)
0039 {
0040 return logistic_sigmoid(x, policies::policy<>());
0041 }
0042
0043 }
0044 }
0045
0046 #endif