File indexing completed on 2025-01-30 09:46:06
0001
0002
0003
0004
0005
0006 #include <cmath>
0007 #include <limits>
0008 #include <boost/math/special_functions/fpclassify.hpp>
0009 #include <boost/math/constants/constants.hpp>
0010
0011 namespace boost { namespace math {
0012
0013
0014 template <typename Real>
0015 Real logaddexp(Real x1, Real x2) noexcept
0016 {
0017 using std::log1p;
0018 using std::exp;
0019 using std::abs;
0020
0021
0022 if (!(boost::math::isfinite)(x1))
0023 {
0024 return x1;
0025 }
0026 else if (!(boost::math::isfinite)(x2))
0027 {
0028 return x2;
0029 }
0030
0031 const Real temp = x1 - x2;
0032
0033 if (temp > 0)
0034 {
0035 return x1 + log1p(exp(-temp));
0036 }
0037
0038 return x2 + log1p(exp(temp));
0039 }
0040
0041 }}