0

Eigen::VectorXdタイプとBoostアキュムレータライブラリの組み合わせに問題があります。

#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

したがって、直接計算は問題ありませんが(固有ベクトルは通常の数値演算子をすべてサポートします)、ブーストアキュムレータは実行時にエラーなしで失敗します。

4

1 に答える 1

1

ユーザー定義型には、std::numeric_limitsを特殊化する必要があります。https://svn.boost.org/trac/boost/ticket/5491を参照してください

于 2011-10-27T01:06:55.620 に答える