include/vinecopulib/misc/tools_stl.hpp
// safer version of log1p that avoids rounding errors if x ~ -1
safer version of log1p that avoids rounding errors if x ~ -1
safer version of log1p that avoids rounding errors if x ~ - 1
inline double
log1p(const double& x)
{
  if (x < -0.5) {
    return std::log(1.0 + x);
  } else {
    return std::log1p(x);
  }
}
inline double log1p ( const double & x ) { if ( x < -0.5 ) { return std :: log ( 1.0 + x ) ; } else { return std :: log1p ( x ) ; } }
safer version of log1p that avoids rounding errors if x ~ -1
safer version of log1p that avoids rounding errors if x ~ - 1