Boost logo

Boost :

Subject: Re: [boost] accurate sum accumulator (kahan)
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2010-07-26 13:59:36


On 07/26/2010 06:55 PM, Jeffrey Lee Hellrung, Jr. wrote:
> Or is the proposition to replace the (naive) summation algorithm with
> kahan summation algorithm for only floating point types?

A possible scenario can be:

1) Leave the naive summation algorith as it is now
2) Create (with a typedef?) fast_sum that is the same of sum (naive)
2) Rename the sum_kahan as accurate_sum implemented as sum (naive)
3) Specialize the accurate_sum for floating points types implemented
    as the real kahan's algorithm

however this can lead to have someone using accurate_sum for integral
type and find it out is not accurate at all !

IMHO "accurate" or "fast" are missleading. What if someone comes out
with an algorithm that gives better results and even faster than
actual implementation?

Think about how many sorting algorithms there are out there.

I think the best is to leave sum as it is now (no complains about
someone's regression tests failing), implement the sum_kahan only for
floating types and have it listed in documentation specifying that is
implemented only for floating types. The string Kahan in the name will
also give to users the hint on what it does and what the performance
loss is going to be.

BTW, what's the procedure to submit something officially to boost?

Regards
Gaetano Mendola


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk