Boost logo

Boost Users :

Subject: Re: [Boost-users] [accumulators] when typeof power is not the same as source
From: Eric Niebler (eric_at_[hidden])
Date: 2010-05-07 14:01:56


On 5/6/2010 9:32 PM, alfC wrote:
> Hi,
>
> Some features of accumulator, such as variance needs to compute powers
> of quantities. What happens if the power of quantity is not the same
> as the type of the original quantity?
>
> An example is a boost::units::quantity,
>
> accumulator_set< quantity<si::energy>, stats<tag::mean, tag::moment<2> > > acc; //not compiling because of moment<2>
> acc(1.2*si::joules);
> ...

So quantity<si::energy> is a type such that squaring it yields a
different type. I'm sorry to say that the accumulators library doesn't
handle such sample types. You can submit a feature request, or (better)
submit a patch. You'd need to change moment_impl in moment.hpp to use
some new trait (numeric::functional::pow?) to compute the type of a
variable raised to the Nth power.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net