使用Boost与蓄电池::本征向量类型 [英] Using Boost Accumulators with Eigen::Vector types

查看:236
本文介绍了使用Boost与蓄电池::本征向量类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,结合征:: VectorXd 类型使用Boost库蓄电池:

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.

推荐答案

用户定义的类型需要专门的std :: numeric_limits。
看到 https://svn.boost.org/trac/boost/ticket/5491

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

这篇关于使用Boost与蓄电池::本征向量类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆