6 #ifndef TURI_LOGIT_MATH_H_ 7 #define TURI_LOGIT_MATH_H_ 10 #include <core/util/code_optimization.hpp> 11 #include <core/logging/assertions.hpp> 32 double m_abs_x = std::copysign(x, -1.0);
33 double exp_neg = std::exp(m_abs_x);
34 bool is_negative = std::signbit(x);
35 double numerator = is_negative ? exp_neg : 1.0;
37 return numerator / (1.0 + exp_neg);
44 return __builtin_expect((x > 48), 0) ? x : std::log1p(exp(x));
51 return __builtin_expect((x < -48), 0) ? -x : std::log1p(exp(-x));
59 return __builtin_expect((x < -48), 0) ? 0 : std::log1p(-exp(x));
67 return __builtin_expect((x > 48), 0) ? 0 : std::log1p(-exp(-x));
74 return __builtin_expect((x > 48), 0) ? x : std::log(std::expm1(x));
90 double m_abs_x = std::copysign(x, -1.0);
91 double exp_neg = std::exp(m_abs_x);
92 bool is_negative = std::signbit(x);
93 double numerator = is_negative ? 1.0 : exp_neg;
95 return -numerator / (1.0 + exp_neg);
98 template <
typename T>
static inline T sq(
const T& t) {
return t*t; }
static GL_HOT_INLINE_FLATTEN double log1pe(double x)
static GL_HOT_INLINE_FLATTEN double log1pe_deriviative(double x)
static GL_HOT_INLINE_FLATTEN double logem1(double x)
static GL_HOT_INLINE_FLATTEN double log1pen_deriviative(double x)
static GL_HOT_INLINE_FLATTEN double sigmoid(double x)
static GL_HOT_INLINE_FLATTEN double log1me(double x)
static GL_HOT_INLINE_FLATTEN double log1pen(double x)
#define GL_HOT_INLINE_FLATTEN
static GL_HOT_INLINE_FLATTEN double log1men(double x)