[accumulators] help/advise required: Need a container to hold accumulator_set
Hello,
I am writing a wrapper class which gets data over time and has to compute a variety of statistics using boost::accumulators. The accumulator cannot be a variable on the stack (function local variable) as it will go out of scope after the function invocation. I will have to make it a member variable of a class. I will not know the type of calculations to requested at compile time. I therefore need a generic accumulator type as member and add the specific type at runtime.
In short, I need a container to hold accumulator_set objects. Different type of accumulator_set objects in the container will perform different calculations. The type of calculation I want to perform will be based on input at runtime.
pseudo code:
#define MEAN 1
#define MAX 2
class calc {
public:
setmetric(int metricType) {
accumulator_set
dhruva wrote:
Hello, I am writing a wrapper class which gets data over time and has to compute a variety of statistics using boost::accumulators. The accumulator cannot be a variable on the stack (function local variable) as it will go out of scope after the function invocation. I will have to make it a member variable of a class. I will not know the type of calculations to requested at compile time. I therefore need a generic accumulator type as member and add the specific type at runtime. <snip>
It doesn't sound like Boost.Accumulators is a good fit for your problem. Accumulators uses static type information to resolve computational dependencies and order calculations. As you don't know what you will be computing until runtime, you can't provide Accumulators with the static type information it requires. -- Eric Niebler BoostPro Computing http://www.boostpro.com
Hello, ----- Original Message ----
From: Eric Niebler
To: boost-users@lists.boost.org Sent: Sunday, 22 February, 2009 11:25:30 AM Subject: Re: [Boost-users] [accumulators] help/advise required: Need a container to hold accumulator_set dhruva wrote:
will have to make it a member variable of a class. I will not know the type of calculations to requested at compile time. I therefore need a generic accumulator type as member and add the specific type at runtime.
It doesn't sound like Boost.Accumulators is a good fit for your problem. Accumulators uses static type information to resolve computational dependencies and order calculations. As you don't know what you will be computing until runtime, you can't provide Accumulators with the static type information it requires.
The approach I proposed by using droppable types and dropping those that are not required. is it expensive? Though it might look not so elegant, would that work? -dhruva Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/
participants (2)
-
dhruva
-
Eric Niebler