-
Notifications
You must be signed in to change notification settings - Fork 135
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
Implement numerically stable sum of floats #3
Comments
I see, this is from I'm not sure about using an intermediate object like that. Can it just be an associated function? trait Float {
...
fn stable_sum<I: IntoIterator<Item = Self>(iter: I) -> Self { ... }
} |
From @vks on June 29, 2017 7:52 It could be an associated function, but then it would be less general: On Thu, Jun 29, 2017, 03:30 Josh Stone notifications@github.com wrote:
|
I believe the proposed implementation will give incorrectly-rounded results on some inputs. The function fn sum(&self) -> f64 {
self.partials.iter().fold(0., |p, q| p + *q)
} sums the partials naively. Why this is a problem is explained here: https://code.activestate.com/recipes/393090/#c16 I've found a testcase that shows the difference: the vector I'm not familiar enough with Rust to suggest a fix with confidence, but Python's |
A note about the |
From @vks on June 27, 2017 12:29
Here is an implementation based on the (hidden) one in the standard library:
I'm not sure how the interface should ideally look like.
Copied from original issue: rust-num/num#309
The text was updated successfully, but these errors were encountered: