1. 下载Eigen3
查看Eigen的包
$ apt-cache search eigen3
下载Eigen
$ sudo apt-get install libeigen3-dev
查看Eigen安装路进,用apt装的话就是在/usr/include的。手动编译才可能变掉
$ whereis eigen3
eigen3: /usr/include/eigen3
2. clion-CMakelists.txt中添加
include_directories(/usr/include/eigen3)
输入代码测试:
#include
#include
using namespace Eigen;
using namespace std;
int main()
{
MatrixXd m = MatrixXd::Random(3,3);
m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
cout << "m =" << endl << m << endl;
VectorXd v(3);
v << 1, 2, 3;
cout << "m * v =" << endl << m * v << endl;
}
参考:
ubuntu16.04+eigen3安装