C++ Eigen Library
C++ Eigen Library
我很难用#include编译该程序。我看到,如果我评论这一行,它会编译。
matrixxd a =(1.0/(double(d( *(p * u * p.p.transpose(( - (p * u( *(p * u(.transpose((.transpose(((。inverse((;
我无法更改标头,因为我需要在ROS中运行此代码,并且必须使用内部构建的特征库。我正在使用此链接中所述的代码
如何在一组2D点上安装边界椭圆。
任何帮助都大大应用了。
pound include iostream
pound include Eigen/Dense
using namespace std;
using Eigen::MatrixXd;
int main ( )
{
//The tolerance for error in fitting the ellipse
double tolerance = 0.2;
int n = 12; // number of points
int d = 2; // dimension
MatrixXd p(d,n); //Fill matrix with random points
p(0,0) = -2.644722;
p(0,1) = -2.644961;
p(0,2) = -2.647504;
p(0,3) = -2.652942;
p(0,4) = -2.652745;
p(0,5) = -2.649508;
p(0,6) = -2.651345;
p(0,7) = -2.654530;
p(0,8) = -2.651370;
p(0,9) = -2.653966;
p(0,10) = -2.661322;
p(0,11) = -2.648208;
p(1,0) = 4.764553;
p(1,1) = 4.718605;
p(1,2) = 4.676985;
p(1,3) = 4.640509;
p(1,4) = 4.595640;
p(1,5) = 4.546657;
p(1,6) = 4.506177;
p(1,7) = 4.468277;
p(1,8) = 4.421263;
p(1,9) = 4.383508;
p(1,10) = 4.353276;
p(1,11) = 4.293307;
cout << p << endl;
MatrixXd q = p;
q.conservativeResize(p.rows() + 1, p.cols());
for(size_t i = 0; i < q.cols(); i++)
{
q(q.rows() - 1, i) = 1;
}
int count = 1;
double err = 1;
const double init_u = 1.0 / (double) n;
MatrixXd u = MatrixXd::Constant(n, 1, init_u);
while(err > tolerance)
{
MatrixXd Q_tr = q.transpose();
cout << "1 " << endl;
MatrixXd X = q * u.asDiagonal() * Q_tr;
cout << "1a " << endl;
MatrixXd M = (Q_tr * X.inverse() * q).diagonal();
cout << "1b " << endl;
int j_x, j_y;
double maximum = M.maxCoeff(&j_x, &j_y);
double step_size = (maximum - d - 1) / ((d + 1) * (maximum + 1));
MatrixXd new_u = (1 - step_size) * u;
new_u(j_x, 0) += step_size;
cout << "2 " << endl;
//Find err
MatrixXd u_diff = new_u - u;
for(size_t i = 0; i < u_diff.rows(); i++)
{
for(size_t j = 0; j < u_diff.cols(); j++)
u_diff(i, j) *= u_diff(i, j); // Square each element of the matrix
}
err = sqrt(u_diff.sum());
count++;
u = new_u;
}
cout << "3 " << endl;
MatrixXd U = u.asDiagonal();
MatrixXd A = (1.0 / (double) d) * (p * U * p.transpose() - (p * u) * (p * u).transpose()).inverse();
MatrixXd c = p * u;
cout << A << endl;
cout << c << endl;
return 0;
}
如果我用
替换了明显的pound include
bogus #include <iostream>
#include <Eigen/Dense>
它可以很好地编译。它还运行,打印一些数字并返回0。
相关文章:
- Eigen如何在容器循环中干净地附加矩阵
- 当在带有Eigen的C++中使用GDB时,我如何才能看到更多的大矩阵
- Boost Graph Library,修复节点大小
- SFML library: http request
- 使用Pybind11向Python公开Eigen::张量
- 如何在没有数据拷贝的情况下从指针创建一个Eigen VectorXd对象
- Eigen:调用lpNorm()的正确方法
- 如何调整 std::vector of Eigen::MatrixXd 的大小
- 如何将 Eigen::Ref 与 pybind11 一起使用?
- Eigen c++ 三角形来自
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- Linking library C++
- 使用 operator() 扩展 Eigen::EigenBase
- 在VS2019项目中集成ImageMagick:x64-windows-static library
- 如何将 Eigen 库安装到 IAR c/c++ 编译器
- C++ Eigen Library
- 布尔乘法与 exclusive-or, not or (with Eigen Matrix Library)
- 如何在iPhone 4上使用Library Eigen
- Pc Lint + Eigen library
- 使用python中的Eigen Library函数调用c++