This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1528

Summary: Floating point underflow exception in tolerance computation
Product: Eigen Reporter: Anders Sundman <Anders.Sundman>
Component: CholeskyAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: Unknown CC: Anders.Sundman, chtz, gael.guennebaud
Priority: Normal    
Version: 3.4 (development)   
Hardware: x86 - 64-bit   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
patch
none
same patch with comment cleanup none

Description Anders Sundman 2018-03-14 12:57:14 UTC
In src/Cholesky/LDLT.h there is the line:

RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();

This causes a floating point underflow exception in the CPU. It is normally not handled by applications and is silently ignored. But we run with: 

feenableexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID | FE_UNDERFLOW); 

Using min() seems to work fine for us: 

RealScalar tolerance = std::numeric_limits<RealScalar>::min();
Comment 1 Christoph Hertzberg 2018-03-14 13:53:54 UTC
I think that change should be fine. std::numeric_limits::min is also used in the SVD module and the EigenSolver module at many places.
Comment 2 Anders Sundman 2018-03-15 13:13:17 UTC
Unfortunatly the tests fail for the min() change since the <cmath> include has a min() define that leaks in to this file when used in the tests. So some reordering and adding of includes in some test files is probably also required.
Comment 3 Christoph Hertzberg 2018-03-15 14:09:56 UTC
Try (std::numeric_limits<RealScalar>::min)()
Comment 4 Anders Sundman 2018-03-15 16:38:36 UTC
Created attachment 835 [details]
patch
Comment 5 Anders Sundman 2018-03-15 16:43:25 UTC
Top notch hackery ;) 

Seems to work. tests pass.
Comment 6 Anders Sundman 2018-03-15 16:44:36 UTC
Created attachment 836 [details]
same patch with comment cleanup

add comment about macro expansion 
remove comments about historic implementations
Comment 8 Nobody 2019-12-04 17:32:04 UTC
-- 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/1528.