How to check the version number of Eigen C++ template library?

This answer is only a summary from the comments above: At compile-time you have EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION and EIGEN_MINOR_VERSION, you can easily embed this information in your application. 3.1.91 sounds like a beta version of 3.2. The version number macros are defined in Macros.h located at \Eigen\src\Core\util\.

OpenCV CV::Mat and Eigen::Matrix

You can also use void eigen2cv(const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst) and void cv2eigen(const Mat& src, Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst) from #include <opencv2/core/eigen.hpp>.

Eigen how to concatenate matrix along a specific dimension?

You can use the comma initializer syntax for that. Horizontally: MatrixXd C(A.rows(), A.cols()+B.cols()); C << A, B; Vertically: // eigen uses provided dimensions in declaration to determine // concatenation direction MatrixXd D(A.rows()+B.rows(), A.cols()); // <– D(A.rows() + B.rows(), …) D << A, B; // <– syntax is the same for vertical and horizontal concatenation For … Read more

How can the C++ Eigen library perform better than specialized vendor libraries?

Eigen has lazy evaluation. From How does Eigen compare to BLAS/LAPACK?: For operations involving complex expressions, Eigen is inherently faster than any BLAS implementation because it can handle and optimize a whole operation globally — while BLAS forces the programmer to split complex operations into small steps that match the BLAS fixed-function API, which incurs … Read more

Why don’t C++ compilers do better constant folding?

This is because Eigen explicitly vectorize your code as 3 vmulpd, 2 vaddpd and 1 horizontal reduction within the remaining 4 component registers (this assumes AVX, with SSE only you’ll get 6 mulpd and 5 addpd). With -ffast-math GCC and clang are allowed to remove the last 2 vmulpd and vaddpd (and this is what … Read more

Initialise Eigen::vector with std::vector

According to Eigen Doc, Vector is a typedef for Matrix, and the Matrix has a constructor with the following signature: Matrix (const Scalar *data) Constructs a fixed-sized matrix initialized with coefficients starting at data. And vector reference defines the std::vector::data as: std::vector::data T* data(); const T* data() const; Returns pointer to the underlying array serving … Read more

Convert Eigen Matrix to C array

You can use the data() member function of the Eigen Matrix class. The layout by default is column-major, not row-major as a multidimensional C array (the layout can be chosen when creating a Matrix object). For sparse matrices the preceding sentence obviously doesn’t apply. Example: ArrayXf v = ArrayXf::LinSpaced(11, 0.f, 10.f); // vc is the … Read more