dhruva wrote:
Hello, I am using boost::accumulator_set to compute mean. After every 100 samples, I need to start afresh. Since I am using accumulator_set as a member variable in a class (I get samples one at a time and need to preserve accumulator_set object across function calls), I need some mechanism to reset it to its initial state.
The issue of being able to reset an accumulator_set was raised during its review. In the review summary, there is this note:
The ability to "reset" and accumulator was requested. Eric pointed out that it is quite possible to make accumulators with reset methods. He also pointed out that it might be desirable to reset accumulator_sets, but this could also pose a problem. It is not clear what should happen if one of the accumulators used by an accumulator set does not have a reset method. Further thought should be given to this for possible inclusion in a later revision.
For some accumulators, the "initial state" depends on its initialization parameters, so resetting can only be done if those parameters are cached somewhere, or else they are resupplied when calling reset(). It might actually be possible to define a "resetable" accumulator set that saves its configuration state in a type-erased form and then either resets itself either by constructing a temporary and doing an assignment, or else by in-place destruct/construct. The configuration state could be saved in a pseudo-accumulator. Hmm ... -- Eric Niebler BoostPro Computing http://www.boostpro.com