Exp of negative infinity is incorrect for arrays of size larger than 1 (result is non-zero)
Summary
Calling .exp() on an array that contains -inf entries does not result in zero values for those entries, unless the array is size 1.
Environment
- Operating System : Linux
- Architecture : x86_64
- Eigen Version : 3.4.0
- Compiler Version : Gcc 10.3.0
Minimal Example
Eigen::ArrayXd a(1);
a << -std::numeric_limits<double>::infinity();
Eigen::ArrayXd exp_a = a.exp();
// Printing exp_a will show a zero value, as expected.
Eigen::ArrayXd b(2);
b << -std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity();
Eigen::ArrayXd exp_b = b.exp();
// Printing exp_b will show non-zero values (e.g., 5.55553e-309).
Steps to reproduce
- Create an Eigen array with more than one entry.
- Fill the array with -inf values.
- Call .exp() on the array.
- See the non-zero results.
What is the current bug behavior?
Exp of negative infinity is non-zero for arrays of size larger than 1.
What is the expected correct behavior?
Exp of negative infinity should always be exactly zero. Non-zero results cause unnecessary numerical issues.