log(1 + ...) -> log1p(...)

This commit is contained in:
Kenneth Heafield 2015-04-08 10:08:05 -04:00
parent 2682cc0f9b
commit 0698da8b0f

View File

@ -502,13 +502,11 @@ inline std::string GetFirstString(const std::string& str, int& first_pos, const
template<class T>
T log_sum (T log_a, T log_b)
{
T v;
if (log_a < log_b) {
v = log_b+log ( 1 + exp ( log_a-log_b ));
return log_b + log1p(exp(log_a - log_b));
} else {
v = log_a+log ( 1 + exp ( log_b-log_a ));
return log_a + log1p(exp(log_b - log_a));
}
return ( v );
}
/**