Boost logo

Boost Users :

Subject: Re: [Boost-users] accumulators: not copying doubles into the acc set
From: MM (finjulhich_at_[hidden])
Date: 2012-07-07 09:15:28


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Eric Niebler
> Sent: 06 July 2012 17:26
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] accumulators: not copying doubles into the
> acc set
>
> 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.
>
Right, it makes sense

Now I tried to find 2 comparables ways of calculating the mean on a large
number of doubles and time them

http://codepad.org/12Uw654j

Is this a fair comparison?

2. is twice as slow as 1. for the few runs I've done.

It is understood the benefits from using acc set appear when calculating
many moments that have common calculations, in a generic way, but I'd like
to see the runtime cost of this feature

MM


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