spire icon indicating copy to clipboard operation
spire copied to clipboard

Add facility for summing series of doubles using Kahan summation

Open sirthias opened this issue 6 years ago • 2 comments

When adding longer series of n Doubles the worst-case error can grow proportionally to n. The Kahan summation algorithm is a simple way to keep the error bounded and independent of n.

Here is an implementation in Java: https://github.com/jenetics/jpx/blob/master/jpx/src/main/java/io/jenetics/jpx/geom/DoubleAdder.java

It looks like this is something that spire could easily provide as well out of the box.

sirthias avatar Jun 28 '19 15:06 sirthias

Hi, and thanks for the proposal! Keep in mind that Spire is 50kloc already and its migration to Scala 3 will require major refactoring. Thus, at the time, we won't be adding features or accepting PRs in that direction. Keeping the issue open, so that such requests can be consolidated.

If you wish to keep an eye on the development, join https://gitter.im/typelevel/spire-dev

denisrosset avatar Jun 28 '19 15:06 denisrosset

Thank you, @denisrosset, that is absolutely understandable. 👍 Hopefully the Scala 3 migration will go relatively smoothly.

sirthias avatar Jun 28 '19 16:06 sirthias