Using Boost Accumulators with Eigen::Vector types

≯℡__Kan透↙ 提交于 2019-12-23 05:29:23

问题


I am having some problems combining Eigen::VectorXd types with the Boost accumulator library:

#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;
}

On my system this produces:

4.41629e-39
0
2
6

So while direct computation is fine (Eigen vectors support all of the usual numerical operators) Boost accumulators fail at runtime without an error.


回答1:


User defined type need specialize std::numeric_limits. see https://svn.boost.org/trac/boost/ticket/5491



来源:https://stackoverflow.com/questions/7908982/using-boost-accumulators-with-eigenvector-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!