Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`[1e20, 1.0, -1e20].sum()` returns `0.0`. This happens because during the summation, `1.0` is too small relative to `1e20`, making it negligible. I have tried Kahan summation but it hasn't fixed the problem. Therefore, I've used Python's `fsum()` implementation with some help from Jason Fager and Huon Wilson. For more details, read: www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps Moreover, benchmark and unit tests were added. Note: `Status.sum` is still not fully fixed. It doesn't handle NaNs, infinities and overflow correctly. See issue 11059: #11059
- Loading branch information
Showing
1 changed file
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
05395cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from huonw
at g3xzh@05395cb
05395cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging g3xzh/rust/sum_bugfix = 05395cb into auto
05395cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g3xzh/rust/sum_bugfix = 05395cb merged ok, testing candidate = b4ed6f9
05395cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/3068
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/911
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/913
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/3074
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2176
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2177
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/3085
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2174
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2179
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/3087
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2175
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2178
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/2254
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/3073
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/2175
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/2179
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/2849
05395cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = b4ed6f9