
On 5/21/2010 8:18 AM, Tim Odenthal wrote:
Hi!
I just discovered this nice functionality in boost, but while trying something as simple as calculating a mean from a set of numbers, I hit a strange drawback:
It seems to be impossible to use the same accumulator again for a different set of numbers, because I cannot clear/ reset it. I found some old (ok, March 2009) discussions about this, but nothing in the documentation.
No, accumulator_set::reset is not implemented yet. As others noted in the thread you found, you can assign to it a similarly initialized accumulator_set to get back to its original state.
By the way, does the accumulator do something to prevent an overflow when I add up everything into one variable?
No. It uses native intrinsics for raw performance. If you want anything fancy, you can use your own UDT for samples that check for overflow. Some construction required. :-( If you do build such a thing, I would consider making it an official part of Accumulators.
And does it prevent a loss of precision, when at a late stage the variable I sum everything into is very big, but the thing I add is very small?
No. See above.
Maybe it would be a good idea to mention this in the documentation, as well...
Indeed. Could you file a ticket at http://svn.boost.org so this doesn't get lost? Thanks, -- Eric Niebler BoostPro Computing http://www.boostpro.com