Re: [Boost-bugs] [Boost C++ Libraries] #4471: Kahan sum

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4471: Kahan sum
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-12 17:09:16

#4471: Kahan sum
  Reporter: anonymous | Owner: eric_niebler
      Type: Feature Requests | Status: new
 Milestone: Boost 1.44.0 | Component: accumulator
   Version: Boost 1.44.0 | Severity: Problem
Resolution: | Keywords:

Comment (by eric_niebler):

 From Gaetano:

 At this page:

 I would add a link sum_kahan pointing to this:


 Implements the summation kahan's algorithm, reducing the accumulation
 error in case of floating point types.

 Result Type


 Depends On


 Initialization Parameters

 Accumulator Parameters

 Extractor Parameters

 Accumulator Complexity

     O(1), however compared to naive sum this accumulator
           performs 4 sum operations for each element accumulated

 Extractor Complexity



 #include <boost/accumulators/statistics/sum_kahan.hpp>


     accumulator_set<float, stats<tag::sum_kahan> > acc;

     BOOST_CHECK_EQUAL(0.0f, sum_kahan(acc));

     for (size_t i = 0; i < 1e6; ++i) {

     BOOST_CHECK_EQUAL(1.0f, sum_kahan(acc));

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC