Boost logo

Boost :

Subject: [boost] [accumulators] Help understanding implementation of weighted accumulators
From: Gabriel Redner (gredner_at_[hidden])
Date: 2013-05-01 16:13:27

Hi folks,

I am trying to implement a weighted accumulator, but I'm having
trouble understanding a few things about the existing ones.

Looking at the implementation of weighted_sum, I see (weighted_sum.hpp:37):

        template<typename Args>
        weighted_sum_impl(Args const &args)
          : weighted_sum_(
                args[parameter::keyword<Tag>::get() | Sample()]
                  * numeric::one<Weight>::value

My questions are:

- It's taking the first sample from the args and multiplying it by a
weight of 1. Isn't this wrong - ignoring the real weight of this
sample? Shouldn't this produce incorrect results?

- I've never understood anyways how there can be an initial argument
during construction of the accumulator. I haven't found any
explanation in the docs beyond "Maybe there is an initial value in the
argument pack". Maybe? How?

Probably more questions later.


Boost list run by bdawes at, gregod at, cpdaniel at, john at