模块和头文件
Core
#include<Eigen/Core>
,包含Matrix和Array类,基础的线性代数运算和数组操作。Geometry
#include<Eigen/Geometry>
,包含旋转,平移,缩放,2维和3维的各种变换。LU
#include<Eigen/LU>
,包含求逆,行列式,LU分解。Cholesky
#include<Eigen/Cholesky>
,包含LLT和LDLT Cholesky分解。SVD
`#include<Eigen/SVD>,包含SVD分解。QR
`#include<Eigen/QR>,包含QR分解。Eigenvalues
#include<Eigen/Eigenvalues>
,包含特征值,特征向量分解。Sparse
#include<Eigen/Sparse>
,包含稀疏矩阵的存储和运算。Dense
#include<Eigen/Dense>
,包含了Core/Geometry/LU/Cholesky/SVD/QR/Eigenvalues模块。Eigen
#include<Eigen/Eigen>
,包含Dense和Sparse。
不仅有函数的基本形式,还有对应的matlab函数,用起来很方便。
Eigen 矩阵定义
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
Vector3f x, y, z; // 3x1 float matrix.
RowVector3f a, b, c; // 1x3 float matrix.
VectorXd v; // Dynamic column vector of doubles
// Eigen // Matlab // comments
x.size() // length(x) // vector size
C.rows() // size(C,1) // number of rows
C.cols() // size(C,2) // number of columns
x(i) // x(i+1) // Matlab is 1-based
C(i,j) // C(i+1,j+1) //
Eigen 基础使用
// Basic usage
// Eigen // Matlab // comments
x.size() // length(x) // vector size
C.rows() // size(C,1) // number of rows
C.cols() // size(C,2)