The result for this simple program doesn't seem to be correct: #include <iostream> #include <eigen3/Eigen/Dense> using namespace std; int main(int argc, char* argv[]) { Eigen::MatrixXf m(2, 2); m << 91.61, 1, 1, 1; m = m.array().exp(); cout << m << endl; cout << m.sum() << endl; } 2.40614e+38 2.71828 2.71828 2.71828 2.40614e+38 The exp(91.61) should give an 'inf' result but it didn't. However, if I trim down the matrix to a smaller size, it works fine again: #include <iostream> #include <eigen3/Eigen/Dense> using namespace std; int main(int argc, char* argv[]) { Eigen::MatrixXf m(1, 2); m << 91.61, 1; m = m.array().exp(); cout << m << endl; cout << m.sum() << endl; } inf 2.71828 inf Can someone help debug why this is happening? I'd like to have 'inf' as a result when it's indeed overflowing, instead of getting some random (albeit large) number. Thanks!
Thank you for the report. This was due to vectorization. Fixed: https://bitbucket.org/eigen/eigen/changeset/dbd64aae2795/ changeset: dbd64aae2795 user: ggael date: 2012-06-14 10:38:39 summary: fix bug 475: .exp() now returns +inf when overflow occurs (SSE) https://bitbucket.org/eigen/eigen/changeset/7437d1687f7d/ changeset: 7437d1687f7d branch: 3.0 user: ggael date: 2012-06-14 10:38:39 summary: fix bug 475: .exp() now returns +inf when overflow occurs (SSE) (transplanted from dbd64aae279527f558021ce98c0950402443d460)
Thanks for the quick fix! Could you kindly let me know how I can get a diff/patch for this fix, if it's not too big? I'd like to use it before the next release is out. Thanks!
Never mind. I found it. Thanks and have a nice day!
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/475.