Opened 12 years ago
#5302 new Bugs
[accumulator] Generalise type arithmetics, e.g. make it play well with boost.units.
Reported by: | Owned by: | Eric Niebler | |
---|---|---|---|
Milestone: | To Be Determined | Component: | accumulator |
Version: | Boost 1.45.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Accumulators library assumes that for an accumulated type T*T is also of type T. This makes it difficult to play it well with boost.unit for example; specially for the variance accumulator.
Based on http://groups.google.com/group/boostusers/msg/86ebe100e3a86794 Below is the goal code:
#include<boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics/variance.hpp> #include<boost/units/systems/si.hpp> #include<boost/units/io.hpp>
using namespace boost::accumulators; using namespace boost::units; int main(){
accumulator_set<
quantity<si::time>, features<
tag::variance,
a;
a(1.0*si::second); a(2.0*si::second); a(3.0*si::second); std::cout
<< extract::variance(a)
; return 0;
}