請直接跳轉 → 2.配置過程
1. 說明
- Eigen官網:http://eigen.tuxfamily.org
- Eigen代碼託管:https://gitlab.com/libeigen/eigen
本文使用Eigen版本爲Eigen3 3.1.2
,文件結構如下所示:
├─bench
│ ├─btl
│ │ ├─actions
│ │ ├─cmake
│ │ ├─data
│ │ ├─generic_bench
│ │ │ ├─init
│ │ │ ├─static
│ │ │ ├─timers
│ │ │ └─utils
│ │ └─libs
│ │ ├─BLAS
│ │ ├─blitz
│ │ ├─eigen2
│ │ ├─eigen3
│ │ ├─gmm
│ │ ├─mtl4
│ │ ├─STL
│ │ ├─tvmet
│ │ └─ublas
│ └─spbench
├─blas
│ └─testing
├─cmake
├─debug
│ ├─gdb
│ └─msvc
├─demos
│ ├─mandelbrot
│ ├─mix_eigen_and_c
│ └─opengl
├─doc
│ ├─examples
│ ├─snippets
│ └─special_examples
├─Eigen
│ └─src
│ ├─Cholesky
│ ├─CholmodSupport
│ ├─Core
│ │ ├─arch
│ │ │ ├─AltiVec
│ │ │ ├─Default
│ │ │ ├─NEON
│ │ │ └─SSE
│ │ ├─products
│ │ └─util
│ ├─Eigen2Support
│ │ └─Geometry
│ ├─Eigenvalues
│ ├─Geometry
│ │ └─arch
│ ├─Householder
│ ├─IterativeLinearSolvers
│ ├─Jacobi
│ ├─LU
│ │ └─arch
│ ├─misc
│ ├─OrderingMethods
│ ├─PardisoSupport
│ ├─PaStiXSupport
│ ├─plugins
│ ├─QR
│ ├─SparseCholesky
│ ├─SparseCore
│ ├─StlSupport
│ ├─SuperLUSupport
│ ├─SVD
│ └─UmfPackSupport
├─failtest
├─lapack
├─scripts
├─test
│ └─eigen2
└─unsupported
├─doc
│ ├─examples
│ └─snippets
├─Eigen
│ └─src
│ ├─AutoDiff
│ ├─BVH
│ ├─FFT
│ ├─IterativeSolvers
│ ├─KroneckerProduct
│ ├─MatrixFunctions
│ ├─MoreVectorization
│ ├─NonLinearOptimization
│ ├─NumericalDiff
│ ├─Polynomials
│ ├─Skyline
│ ├─SparseExtra
│ └─Splines
└─test
└─mpreal
從上結構樹可以看出,代碼主要位於Eigen
文件夾下,熟悉文件結構對於我們正確引用頭文件有幫助。
2. 配置過程
解壓壓縮包,在*.pro
文件中配置包含路徑,以博主爲例,將其置於G:\CodeBase\
下,並修改文件夾名稱爲eigen_3_1_2
:
INCLUDEPATH += G:\CodeBase\eigen_3_1_2
測試代碼如下:
#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Matrix2d a;
a << 1, 2,
3, 4;
MatrixXd b(2,2);
b << 2, 3,
1, 4;
std::cout << "a + b =\n" << a + b << std::endl;
std::cout << "a - b =\n" << a - b << std::endl;
std::cout << "Doing a += b;" << std::endl;
a += b;
std::cout << "Now a =\n" << a << std::endl;
Vector3d v(1,2,3);
Vector3d w(1,0,0);
std::cout << "-v + w - v =\n" << -v + w - v << std::endl;
return 0;
}
測試結果: