eigen3

Eigen::Ref<> as a member variable

不想你离开。 提交于 2019-12-09 01:42:33
问题 I need a class to have an Eigen::Ref variable as a static member which would be initialized through an init static method. Something like this: class CostFunction { public: static Eigen::Ref<Eigen::VectorXd> data; static void init(const Eigen::Ref<Eigen::VectorXd>& d) { data = d; } CostFunction() {} }; int main() { Eigen::VectorXd data = Eigen::VectorXd::Random(30); CostFunction cf; cf.init(data); return 0; } This doesn't compile. I get an error which looks like this: /var/tmp/doNotRemove

Eigen with PointCloud (PCL)

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:26:21
问题 I have been following the tutorial http://pointclouds.org/documentation/tutorials/pcl_visualizer.php#pcl-visualizer and could get a simple viewer working. I looked up the documentation and found the function getMatrixXfMap which returns the Eigen::MatrixXf from a PointCloud . // Get Eigen matrix Eigen::MatrixXf M = basic_cloud_ptr->getMatrixXfMap(); cout << "(Eigen) #row :" << M.rows() << endl; cout << "(Eigen) #col :" << M.cols() << endl; Next I process M (basically rotations, translations

Eigen matrix library coefficient-wise modulo operation

陌路散爱 提交于 2019-12-08 07:06:45
问题 In one of the functions in the project I am working on, I need to find the remainder of each element of my eigen library matrix when divided by a given number. Here is the Matlab equivalent to what I want to do: mod(X,num) where X is the dividend matrix and num is the divisor. What is the easiest way to achieve this? 回答1: You can use a C++11 lambda with unaryExpr : MatrixXi A(4,4), B; A.setRandom(); B = A.unaryExpr([](const int x) { return x%2; }); or: int l = 2; B = A.unaryExpr([&](const int

Eigen compilation error with gcc 8.2.1 on MSYS2

限于喜欢 提交于 2019-12-07 22:46:33
问题 We are facing errors compiling against Eigen 3.3.7 (and probably older versions) against the latest versions of GCC 8.2.1 supplied by MSYS2. Strangely, this only happens with the latest builds of the same package ( mingw-w64-x86_64-gcc 8.2.1): 8.2.1+20181123-1 : fine 8.2.1+20181130-1 : error 8.2.1+20181207-1 : error The error is: In file included from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/SparseCore:50, from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Sparse:26, from C:

How to use Eigen FFT with MatrixXf?

北慕城南 提交于 2019-12-07 16:54:01
问题 I am new to the Eigen library. I would like to compute FFT of Eigen Matrices. However, my attempts to do so indicate that the unsupported Eigen FFT module can't be used with MatrixXf. I want to pull off something like: #include <eigen3/unsupported/Eigen/FFT> #include<Eigen/Dense> #include<iostream> using namespace std; using namespace Eigen; int main(){ MatrixXf A = MatrixXf::Random(3,10); FFT<float> fft; MatrixXf B; fft.fwd(B,A); } Is this achievable? Any other suggestions are welcome. It

Sparse eigenvalues using eigen3/sparse

南笙酒味 提交于 2019-12-07 06:33:19
问题 Is there an distinct and effective way of finding eigenvalues and eigenvectors of a real, symmetrical, very large, let's say 10000x10000, sparse matrix in Eigen3 ? There is an eigenvalue solver for dense matrices but that doesn't make use of the property of the matrix e.g. it's symmetry. Furthermore I don't want to store the matrix in dense. Or (alternative) is there a better (+better documented) library to do that? 回答1: Armadillo will do this using eigs_sym Note that computing all the

Using Eigen 3.3 in a CUDA kernel

你说的曾经没有我的故事 提交于 2019-12-07 02:07:40
问题 Since Nov. 2016 it's possible to compile CUDA code which references Eigen3.3 - see this answer This answer is not what I'm looking for and may now be "outdated" in the sense that there might now be an easier way, since the following is written in the docs Starting from Eigen 3.3, it is now possible to use Eigen's objects and algorithms within CUDA kernels. However, only a subset of features are supported to make sure that no dynamic allocation is triggered within a CUDA kernel. See also here.

Why does std::less<Eigen::VectorXd> fail to compile?

流过昼夜 提交于 2019-12-07 01:44:42
问题 I implemented a comparison operator operator< for Eigen::VectorXd , and sometimes, I need to pass a compare function to another of my function, I am tired of wrapping the operator< into [](const VectorXd& v1, const VectorXd& v2)->bool{return v1 < v2} , so I think the std::less class would be useful, as, to my understanding, it can generate the lambda function as long as operator< is defined. However, I found that std::less<VectorXd> didn't work for me, for example, the below code works fine:

Convert Eigen Affine3d to Affine2d

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:33:20
I have an affine transform in 3D and I wish to discard any z-axis information from. Is there a convenient way to convert from an Affine3d to and Affine2d ? Try following: Affine2d S2d = Translation2d(S3d.translation().topRows<2>()) * S3d.linear().topLeftCorner<2,2>(); Demo: #include <Eigen/Dense> #include <iostream> #include <string> int main() { using namespace Eigen; using namespace std; Vector3d p3d(1.,2.,3.); cout << p3d << endl << endl; Affine3d S3d = Translation3d(2.,2.,2.)*Scaling(3.,2.,5.); Vector3d scalled = S3d*p3d; cout << S3d.matrix() << endl << endl; cout << scalled << endl <<

Eigen unsupported Tensor to Eigen matrix

穿精又带淫゛_ 提交于 2019-12-06 06:21:52
问题 I get a Eigen::Tensor<std::complex, 2> after some operations on a Tensor with more dimensions. Is there an easy way to create a Eigen::MatrixXcf from this Tensor-object or do I have to copy the values manually? 回答1: I am currently using Eigen version 3.3.4, and there is no easy built-in function to cast between Eigen::Tensor types and the more familiar Matrix or Array types. It would have been handy to have something like the .matrix() or .array() methods. There is also no easy way to add