1、下载Eigen库,如下:

2、解压到项目目录下,如下:


3、 在C/C++中包含文件,如下:

4、在头文件中加入如下代码:

5、测试代码:
//.cpp文件
#include "testEigen.h"
testEigen::testEigen(QWidget *parent)
    : QWidget(parent)
{
    ui.setupUi(this);
    MatrixXd matrix(2, 3);
    matrix << 1, 2, 4, 8, 16, 32;
    cout << matrix << endl;
}
testEigen::~testEigen()
{}
 
输出入下:




















