aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/functors
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-01-08 22:21:37 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-01-08 22:21:37 +0000
commit4217a9f09018b1eb3ce800919a69c7c3df47f9cb (patch)
tree08b92abcbc788ddb98d70f77ca3bbccce298bea8 /Eigen/src/Core/functors
parent9623c0c4b9f40e74ba6ba551f86831616bdd488c (diff)
The upper limits for where to use the rational approximation to the logistic function were not set carefully enough in the original commit, and some arguments would cause the function to return values greater than 1. This change set the versions found by scanning all floating point numbers (using std::nextafterf()).
Diffstat (limited to 'Eigen/src/Core/functors')
-rw-r--r--Eigen/src/Core/functors/UnaryFunctors.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h
index 6d1b6ba51..410cc6f58 100644
--- a/Eigen/src/Core/functors/UnaryFunctors.h
+++ b/Eigen/src/Core/functors/UnaryFunctors.h
@@ -942,9 +942,9 @@ struct scalar_logistic_op<float> {
// The upper cut-off is the smallest x for which the rational approximation evaluates to 1.
// Choosing this value saves us a few instructions clamping the results at the end.
#ifdef EIGEN_VECTORIZE_FMA
- const float cutoff_upper = 16.285715103149414062f;
+ const float cutoff_upper = 15.7243833541870117f;
#else
- const float cutoff_upper = 16.619047164916992188f;
+ const float cutoff_upper = 15.6437711715698242f;
#endif
const float cutoff_lower = -9.f;
if (x > cutoff_upper) return 1.0f;
@@ -960,9 +960,9 @@ struct scalar_logistic_op<float> {
// Clamp the input to be at most 'cutoff_upper'.
#ifdef EIGEN_VECTORIZE_FMA
- const Packet cutoff_upper = pset1<Packet>(16.285715103149414062f);
+ const Packet cutoff_upper = pset1<Packet>(15.7243833541870117f);
#else
- const Packet cutoff_upper = pset1<Packet>(16.619047164916992188f);
+ const Packet cutoff_upper = pset1<Packet>(15.6437711715698242f);
#endif
const Packet x = pmin(_x, cutoff_upper);