diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2019-08-28 12:20:21 -0700 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2019-08-28 12:20:21 -0700 |
commit | 1187bb65ad196161a07f4e0125e478d022ea1b08 (patch) | |
tree | 86fa97b5b8f1f7377d51cdd202f30a4293b6b9ae /Eigen/src/Core/MathFunctions.h | |
parent | 6e77f9bef35012f160b307bdeae73194fde91e51 (diff) |
Add more tests for corner cases of log1p and expm1. Add handling of infinite arguments to log1p such that log1p(inf) = inf.
Diffstat (limited to 'Eigen/src/Core/MathFunctions.h')
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index fcf62011e..fbec39d83 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -551,7 +551,8 @@ namespace std_fallback { Scalar x1p = RealScalar(1) + x; Scalar log_1p = log(x1p); const bool is_small = numext::equal_strict(x1p, Scalar(1)); - return is_small ? x : x * (log_1p / (x1p - RealScalar(1))); + const bool is_inf = numext::equal_strict(x1p, log_1p); + return (is_small || is_inf) ? x : x * (log_1p / (x1p - RealScalar(1))); } } |