Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper comparison of floating point values in equals method #1888

Closed
karlnapf opened this issue Feb 22, 2014 · 1 comment
Closed

Proper comparison of floating point values in equals method #1888

karlnapf opened this issue Feb 22, 2014 · 1 comment

Comments

@karlnapf
Copy link
Member

Shogun can compare any objects via CSGObject::equals. This goes through all the parameters and compares their content and is used for integration testing and other useful things.

We currently compare floating point numbers as
if (CMath::abs(a-b)<eps) ....

This is a very bad thing, as it does not handle NaN, inf, etc
See http://floating-point-gui.de/errors/comparison/

This task is to change the comparison to handle all cases of floating point numbers, for the types float32,float64,floatmax. It should be a very few lines only. You should add a correctly implemented (templated) comparison function for all sorts of floating point numbers in CMath and call this method from the TParameter::compare_ptype method.

This will also fix broken integration tests on OSX

@karlnapf karlnapf self-assigned this Feb 22, 2014
dhruv13J added a commit to dhruv13J/shogun that referenced this issue Mar 5, 2014
karlnapf added a commit that referenced this issue Mar 6, 2014
@karlnapf
Copy link
Member Author

karlnapf commented Mar 6, 2014

fixed in #1939

@karlnapf karlnapf closed this as completed Mar 6, 2014
cameo54321 pushed a commit to cameo54321/shogun that referenced this issue Mar 17, 2014
cameo54321 pushed a commit to cameo54321/shogun that referenced this issue Mar 17, 2014
cameo54321 pushed a commit to cameo54321/shogun that referenced this issue Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant