Ubuntu安装eigen

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.

 

1.官网下载源码

http://eigen.tuxfamily.org/index.php?title=Main_Page

2.解压后,在源码目录创建一个新目录

1) mkdir build

2) cd build

3) cmake ..

4) make 

5) sudo make install

3.默认安装到//usr/local/include/eigen3

cd  /usr/local/include/eigen3

sudo cp * ../  -a

PS:由于eigen是一个模板类,并没有实际编译成动态库,此处只是将相应头文件拷贝到系统默认目录下/usr/lcoa/include/

 

3.test

#include 
#include 
#include "Eigen/Dense"

using std::cout;
using std::endl;
using std::vector;
using Eigen::VectorXd;
using Eigen::MatrixXd;

// Kalman Filter variables
VectorXd x;	// object state
MatrixXd P;	// object covariance matrix
int main() {
	/**
	* Code used as example to work with Eigen matrices
	*/
	// design the KF with 1D motion
	x = VectorXd(2);
	x << 0, 0;
	std::cout<<"Matrix x:\n"<

g++ km.cpp

./a.out

Ubuntu安装eigen_第1张图片

你可能感兴趣的:(数学,有用工具库,矩阵计算类模板,C++,Eigen)