Changes between Version 5 and Version 6 of soc2009


Ignore:
Timestamp:
Mar 18, 2009, 8:33:52 PM (14 years ago)
Author:
viboes
Comment:

Adding dependent accumulators

Legend:

Unmodified
Added
Removed
Modified
  • soc2009

    v5 v6  
    174174}}}
    175175
    176 
     176== Boost.Accumulators ==
     177== Dependents accumulators ==
     178
     179The accumulator library allows to determine dependency between accumulator, but not between accumulator_sets.
     180I would like to define an accumulator_set c so when we cumulate in two others c1 and c2 accumulator_sets we cumulate also in c, some thing like:
     181{{{
     182#!cpp
     183typedef dependable_accumulator_set <double, ...> dependable_acc_type;
     184
     185dependable_acc_type c1, c2;
     186dependable_acc_type c=c1+c2
     187
     188dependable_acc_type c3;
     189
     190c+=c3;
     191
     192c1(1);
     193c2(1);
     194c3(2);
     195assert(count(c)==3);
     196assert(sum(c)==4);
     197}}}
     198How dependable_accumulator_set  can be defined? Here follows the interfaces of such a class and the pseudo code, I've named the class dependable_accumulator_set, sorry but I have not found a shorter and better name (may be observed/listened?)
     199{{{
     200#!cpp
     201template <typename T, typename F, typename W>
     202class dependable_accumulator_set : public acumulator_set<T,F,W>
     203{
     204public:
     205    dependable_accumulator_set();
     206    void add_dependent(dependable_acumulator_set&);
     207    void remove_dependent(dependable_acumulator_set&);
     208
     209    template<typename A1>
     210    void operator ()(A1 const &a1) {
     211        for (acc in dependents) {
     212            acc(a1);
     213        }
     214        this->accumulator_set_type::operator()(a1);
     215    }
     216    dependable_accumulator_set<T,F,W>& operator+=(dependable_accumulator_set<T,F,W>);
     217    dependable_accumulator_set<T,F,W>& operator-=(dependable_accumulator_set<T,F,W>);
     218};
     219
     220template <typename T, typename F, typename W>
     221dependable_accumulator_set<T,F,W>
     222operator+()(dependable_accumulator_set<T,F,W>,dependable_accumulator_set<T,F,W>);
     223}}}
     224
     225Another variant could be also to have a temporary accumulator that cyclically push its current value on another accumulator.
     226
     227It will also interesting to have a dependable and cyclic accumulator set. It would be great to integrate these features on a unique class (accumulator_set?) in a clean way.
     228{{{
     229#!cpp
     230template <typename T, typename F, typename W,
     231          typename DependablePolicy,
     232          typename CyclicPolicy>
     233class accumulator_set;
     234}}}
     235
     236