I wrote an implementation of Kahan summation here in a thread that you also participated in. Should I open a PR to add that to Numerics?
• • •
Also, do you have feedback on the dynamic-dispatch / generic implementation ideas I sketched here a few posts later in the same thread?
More info
I’d really like to be able to call sum()
in a generic context on a sequence whose elements are only constrained to AdditiveArithmetic
, and have it use the proper algorithm for the actual element type dynamically.
This isn’t too difficult to achieve (I have a working prototype), but it does require a different design with a protocol requirement that each conforming element type implements with its preferred algorithm.
In order to make the constraint be AdditiveArithmetic
, the requirement would have to be added to that protocol (with a default implementation), and the implementations for standard library types would have to be in the standard library itself rather than Numerics.