GNOME Bugzilla – Bug 131588
SUM algorithm properties
Last modified: 2011-11-23 20:57:41 UTC
attachment to follow type a name or word in C10 and result appears in H10 eg typing 'George W Bush' will return 'Human Shield' bob == hypnotist monkey == mad scientist bill clinton == dodgem driver Jody Goldberg == Teaching Pensioners to Drive I always wondered if these stupid junkmail spreadsheets would work properly in Gnumeric becuase they typically use things in very unusual ways so I really hope that it is of some use for testing purposes.
Created attachment 23394 [details] Excel Spreadsheet toy - Job predictor
yummy a compiler issue. Compile the attachment with gcc x86 -O0 an get different answers than with -O2. We'll play with a simple patch to see if it has any unwanted effects.
Created attachment 23564 [details] Compile with gcc -O0 vs -O2 and watch the answers change
Our current summation technique has some pretty bad properties, for example, that we end up with non-integer sum of integers due to rounding issues. Do we have good examples where the two-pass method improves matters?
The obvious candidate is a sum of 3 numbers x, y, -x where y is very close to 0 and x is very large, but it thee numbers are very different in size, I don't think it will improve the calculation a lot. Sorting the numbers by absolute value would help much more.
This is kludged in 1.2.6 to use long double Do we want to just drop the whole idea ? Sorting isn't really feasible. That is just too expensive for large sets.
I'm inclined to just go with the trivial implementation -- that will give us 80-bit intermediate results on i86. If we want to get fancy, we could detect that we have a problematic data set and use a sorting-based method when that happens. For example: 1. Sort positives and negatives in different buckets in order of increasing magnitude. 2. Set running sum to 0. 3. While we have both positives and negatives: 3a. Add a positive number if running sum <= 0. 3b. Add a negative number if running sum > 0. 4. Add whatever is left. That leaves the question of how to determine whether to use the fancy stuff. I'd say... 1. |Plain sum| << max |x_i| 2. max |x_i| / min |x_i| > 2^20 (ignoring zeros)
Adopting the long double approach for now.
This is still not good. A sum of ones and zeroes does not yield an integer. Suggested patch coming up.
Created attachment 35442 [details] [review] K-I-S-S
Hey, you can't just add numbers by adding them! :-)
Oh yes, I can!
See also 664656