eigen

Quaternion is flipping sign for very similar rotations?

隐身守侯 提交于 2020-01-12 10:14:06
问题 Consider the following minimal working example: #include <iostream> #include <math.h> #include <eigen3/Eigen/Dense> int main() { // Set the rotation matrices that give an example of the problem Eigen::Matrix3d rotation_matrix_1, rotation_matrix_2; rotation_matrix_1 << 0.15240781108708346, -0.98618841818279246, -0.064840288106743013, -0.98826031445019891, -0.1527775600229907, 0.00075368177315370682, -0.0106494132438156, 0.063964216524108775, -0.99789536976680049; rotation_matrix_2 << -0

how to initialize a Eigen Matrix from an opencv cv::Mat, or from an array which is row-major?

橙三吉。 提交于 2020-01-12 08:07:33
问题 I found that Eigen's Matrix is default column-major, which is like MATLAB, but how do I initialize an Eigen::MatrixXd from an cv::Mat? The following code is my test. But none of them could be compiled successfully. Could someone give me some advice, please? or some other links? Thanks. cv::Mat A_M=cv::Mat(rows, cols, CV_64FC1); double *A=(double *)A_M.data(); typedef Map<MatrixXd> MapMat; MapMat A_eigen(A,m,n); Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> A_eigen; Eigen

C++ Eigen initialize static matrix

时光毁灭记忆、已成空白 提交于 2020-01-12 04:27:32
问题 Is it possible to initialize a static eigen matrix4d in a header file? I want to use it as a global variable. I'd like to do something along the lines of: static Eigen::Matrix4d foo = Eigen::Matrix4d(1, 2 ... 16); Or similar to vectors: static Eigen::Matrix4d foo = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; Here is a link to the eigen matrix docs. I can't seem to find how to do this from there. 回答1: On the lines of Dawid's answer (which has a small issue, see the comments), you can do: static

使用Eigen出现了问题

孤街醉人 提交于 2020-01-07 22:00:25
这里写自定义目录标题 做点云拼接时遇到的问题,一直没能解决 slamBase.hpp # pragma once //保证头文件只被编译一次 #include <iostream> #pragma pack(push, 16) // opencv #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> // pcl #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/common/transforms.h> #include <Eigen/Core> #include <Eigen/Geometry> #include <sophus/se3.h> #pragma pack(pop) using namespace std; using namespace cv; typedef pcl::PointXYZRGB PointT; typedef pcl::PointCloud<PointT> PointCloud; // camera instrinsic parameters struct CAMERA_INTRINSIC_PARAMETERS { double fx, fy, cx, cy, scale;

How do you change a Block in Eigen?

◇◆丶佛笑我妖孽 提交于 2020-01-07 07:40:20
问题 I'm having trouble reassigning a Block . In the code below I store the matrix A in two different ways: as 3 ArrayXd s, one for each row as an ArrayXXd . // data ArrayXXd A (3, 3); A << 0, 1, 2, 3, 4, 5, 6, 7, 8; std::vector<ArrayXd> A_rows = {A.row(0), A.row(1), A.row(2)}; // std::vector<ArrayXd> solution // first row ArrayXd & current_row = A_rows[0]; // read it, write it, do stuff // start working with the second row current_row = std::ref(A_rows[1]); cout << current_row << endl << endl; //

I get no multithreading when compiling for release mode

时间秒杀一切 提交于 2020-01-07 07:24:09
问题 I am programming a matrix-matrix multiplication using the Eigen library in VS2010. When I run in debug mode the application uses all my CPU, but when I run in release mode it uses only 1 thread. Is there a setting I need to change in order to enable multi-threading? 回答1: This is so silly but i never enabled openMP for RELEASE mode in properties configuration even though i thought i did. 来源: https://stackoverflow.com/questions/10517243/i-get-no-multithreading-when-compiling-for-release-mode

What is the correct way to solve a least square equation with eigen?

核能气质少年 提交于 2020-01-07 06:26:25
问题 I have the following simple example to perform a least square, but got the following assertion error. Assertion failed: (i>=0) && ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i What is the correct way to do this? typedef Eigen::ArrayXd arr; typedef Eigen::ArrayXXd arr2; arr2 A(3, 3); arr B(3); A << 1, 0, 0, 0, 1, 0, 0, 0, 1; B << 1, 2, 3; auto x = A.matrix().colPivHouseholderQr().solve(B.matrix()); 回答1: As said in my comment, the problem is that x is an abstract expression

Dynamic Eigen vectors in Boost::odeint

允我心安 提交于 2020-01-07 03:51:31
问题 I am trying to use dynamic Eigen matrices and vectors with boost::odeint. The reason is that I want to solve a problem defined by user input of arbitrary size. The problem can be captured in a state space equation in the following form: x' = A*x + B*u (https://en.wikipedia.org/wiki/State-space_representation), which is basically the dxdt() function required for boost::odeint. Following code is an example of what I am trying do: #include <iostream> #include <Eigen/Core> #include <cstdlib>

Fortran modules and C++ with Eigen

天大地大妈咪最大 提交于 2020-01-06 23:46:09
问题 I am a Fortran user and a complete newbie to C++ and Eigen. I use modules in Fortran to be able to keep my variables, arrays and matrices in different groups and use them as needed. How to implement the idea of modules in Fortran in C++ so that I am able to pass on the data between different subroutines? I cannot paste the entire Fortran code as it is too large and there will be many new concepts which I would like to write directly in C++. Perhaps, a sample snippet or document showing how to

No speed-up after using MKL for Eigen

倖福魔咒の 提交于 2020-01-06 15:43:10
问题 I use Eigen 3.3 and Intel MKL 2017, and write and run program in Visual Studio 2012 with Win-7 64-bit system and Intel Xeon(R) CPU E5-1620 v2@3.70GHZ CPU. I belive that my configuration for MKL is correct, because I can succesfully run MKL examlpe codes. The configuraton for using Intel MKL from Eigen follows from https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html. For Visiual Studio 2012, I complie codes via Intel C++ Complier in Release x64 model. However, the following code always