|
Boost Users : |
Subject: Re: [Boost-users] accumulators: not copying doubles into the acc set
From: Eric Niebler (eric_at_[hidden])
Date: 2012-07-06 12:25:58
On 7/6/2012 8:32 AM, MM wrote:
> Hello,
>
> Having a list of doubles stored somewhere, is there a way not to copy the
> doubles into the accumulator set and just iterate somehow through the
> existing data in order to save memory.
>
> Imagine I have a std::vector<double> with 10million entries.
>
> Then pushing each double to the accumulator set object, then I'd imagine, at
> one point, the process would hold the 10 million doubles twice.
That's not true. Accumulators do not store the values they've seen. They
only store enough intermediate information to calculate their result.
For most accumulators, this is little to no information. Think of the
count accumulator. It just increments an internal counter per value. Or
sum. It just adds the value to a running sum and then discards the
value. And the mean accumulator stores nothing at all. It just divides
the result of the sum accumulator by the result of the count accumulator.
HTH,
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net