ANIMA  4.0
animaLogarithmFunctions.hxx
Go to the documentation of this file.
1 #pragma once
2 #include <cmath>
3 
4 namespace anima
5 {
6 
7  template <class ScalarType> double safe_log(const ScalarType x)
8  {
9  ScalarType digits = std::numeric_limits<ScalarType>::digits10;
10 
11  ScalarType precision = pow(10.0, -digits);
12 
13  if (x < precision)
14  return std::log(precision);
15 
16  return std::log(x);
17  }
18 
19 } // end of namespace anima
double safe_log(const ScalarType x)