2011-10-26 18 views
0

我有一些问题,加速蓄电池库结合Eigen::VectorXd类型:使用Boost蓄能器征:: vector的类型

#include <iostream> 
#include <Eigen/Core> 
#include <boost/accumulators/accumulators.hpp> 
#include <boost/accumulators/statistics/stats.hpp> 
#include <boost/accumulators/statistics/mean.hpp> 

using namespace boost::accumulators; 
using namespace Eigen; 

int main() 
{ 
    Vector2f a(1.0, 2.0), b(3.0, 10.0); 

    accumulator_set<Vector2f, stats<tag::mean> > acc(Vector2f::Zero()); 

    acc(a); 
    acc(b); 

    std::cout << mean(acc) << std::endl; 
    std::cout << ((a+b)/2.0) << std::endl; 

    return 0; 
} 

在我的系统中,这会产生:

4.41629e-39 
0 
2 
6 

因此而直接计算很好(特征向量支持所有通常的数值运算符)Boost累加器在运行时失败,没有错误。

回答