Eigen的配置

来源:互联网 发布:js 银行卡格式 编辑:程序博客网 时间:2024/05/23 05:09

1、  下载Eigen

Eigen的官网下载地址:http://eigen.tuxfamily.org/index.php?title=Main_Page#Download

下载后的文件名为:eigen-eigen-5097c01bcdc4.tar.bz2,为方便使用将其名字修改为eigen3,

另外在CSDN资源里也可以下载,其地址为:http://download.csdn.net/detail/hjx_1000/4983537

如图1所示:


图1、eigen下载后解压缩目录

使用时需在VS2005的项目中包含Dense文件(其目录为:eigen3\Eigen),如图2所示:


图2、Dense文件的位置

2、VS2005项目中的配置,直接在“Additional Include Directories”中加入eigen3的目录即可,如图3所示:


图3、在项目中添加Eigen目录

3、在项目中包含eigen的目录、命名空间,并使用其中的矩阵

[cpp] view plaincopy
  1. #include "stdafx.h"  
  2. #include <iostream>    
  3. #include <Eigen/Dense>    
  4. #include <Eigen/Dense>  
  5. using Eigen::MatrixXd;  
  6.   
  7. using namespace std;   
  8.   
  9. int _tmain(int argc, _TCHAR* argv[])  
  10. {  
  11.     MatrixXd m(2,2);  
  12.     m(0,0) = 3;  
  13.     m(1,0) = 2.5;  
  14.     m(0,1) = -1;  
  15.     m(1,1) = m(1,0) + m(0,1);  
  16.     std::cout << m << std::endl;  
  17.     system("pause");  
  18.     return 0;  
  19. }  
0 0
原创粉丝点击