Boost logo

Boost :

Subject: Re: [boost] accurate sum accumulator (kahan)
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2010-07-26 14:48:21


On Mon, Jul 26, 2010 at 6:59 PM, Gaetano Mendola <mendola_at_[hidden]> wrote:
> 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 !
>

wouldn't the native sum be accurate (actually exact) for integral
types as long as the sum doesn't overflow?

-- 
gpd

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