Matrix类 | ||||||||||
官方文档:https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html Matrix类是Eigen最基本的类,Vector也只是一类特殊的Matrix。常见的typedef含义如下
声明 Matrix3f a; // a is a 3-by-3 matrix, with a plain float[9] array of uninitialized coefficients, MatrixXf b; // b is a dynamic-size matrix whose size is currently 0-by-0, and whose array of coefficients hasn't yet been allocated at all. MatrixXf a(10,15); // a is a 10x15 dynamic-size matrix, with allocated but currently uninitialized coefficients. VectorXf b(30); // b is a dynamic-size vector of size 30, with allocated but currently uninitialized coefficients. | ||||||||||
Array类 | ||||||||||
官方文档:https://eigen.tuxfamily.org/dox/group__TutorialArrayClass.html Array类与Matrix类不同,后者主要为通用的线性代数求解服务,而前者提供了coefficient-wise与element-wise的计算。 Array是一个泛型类,有三个参数,第一个参数指定元素数据类型,第二个第三个参数指定矩阵大小,为了方便使用,Eigen提供了常见矩阵类型的typedef如下: 声明 Eigen::ArrayXXf m(2,2);
输出 std::cout << m << std::endl << std::endl;
初始化 m(0,0) = 1.0; m(0,1) = 2.0; m(1,0) = 3.0; m(1,1) = m(0,1) + m(1,0); 或者 m << 1.0,2.0, 3.0,4.0; | ||||||||||
resize | ||||||||||
获取matrix大小: | ||||||||||
Reduction, Visitor, Broadcast | ||||||||||
Reduction 沿着axis reduction M.rowwise().sum() 每行求和 M.colwise().sum()每列求和 | ||||||||||
数学运算 | ||||||||||
官方文档:https://eigen.tuxfamily.org/dox/group__CoeffwiseMathFunctions.html m.erfc() |