kil*_*gre 11 c++ boost c++11 boost-accumulators
我最近发现了优秀的库boost :: accumulators,我想用它来代替我积累统计数据的一些代码.
我在文档中找不到的一件事是能够对两个累加器集合求和,如operator + =
例:
using namespace boost::accumulators;
typedef accumulator_set<double, features<tag::variance> > AccumSet;
class Foo {
AccumSet acc;
public:
Foo& operator+=(const Foo& that) {
this->acc += that.acc; // error! no such operator
return *this;
}
double GetVariance() { return variance(acc); }
};
Run Code Online (Sandbox Code Playgroud)
如何使用可用的API实现此目的?我不知道这是否可以实现库中所有类型的累加器(可能不是尾部),但它肯定可以用于重要的事情,如计数,总和,平均值,时刻,协方差等
| 归档时间: |
|
| 查看次数: |
778 次 |
| 最近记录: |