|
Boost : |
From: Tom Brinkman (reportbase_at_[hidden])
Date: 2007-07-25 20:45:59
It struck me that the circular_buffer would work great as an great underlying
container in the boost::accumulators library.
It would allow us to create a generic functor such as the following:
template <typename Accumulator>
struct generic_smoothing_functor
{
Accumulator accumulator;
generic_smoothing_functor(std::size_t periods) :
accumulator(periods) {}
out operator()(type value, offset start, offset end)
{
return accumulator(value);
}
};
typedef generic_smoothing_functor<
tag::variance> variance_smoothing_functor;
typedef generic_smoothing_functor<
tag::momentum> momentum_smoothing_functor;
typedef generic_smoothing_functor<
tag::simple_moving_average> simple_smoothing_functor;
typedef generic_smoothing_functor<
tag::rate_of_change> rate_of_change_smoothing_functor;
This would be superior to creating a seperate smoothing functor
for each of the algorithms in the "accumulators" library.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk