eigen

Link the R Package Depending on RcppEigen with MKL in Microsoft R Open

[亡魂溺海] 提交于 2019-12-06 08:11:03
问题 I have built a custom package with some functions written in RcppEigen. I also have Microsoft R open with Intel MKL enabled. How could I link the R package to the Intel MKL feature? Setup 1 : Below are procedures that I have tried to link the package with MKL in the normal R, but failed: The Eigen documents says I need: 1. #define EIGEN_USE_MKL_ALL 2. link your program to MKL libraries (the MKL linking advisor) Based on 2, in my file Makevars PKG_CXXFLAGS = -I/opt/intel/mkl/include PKG_LIBS =

From Matlab to C++ Eigen matrix operations - vector normalization

拜拜、爱过 提交于 2019-12-06 07:46:17
Converting some Matlab code to C++. Questions (how to in C++): Concatenate two vectors in a matrix. (already found the solution) Normalize each array ("pts" col) dividing it by its 3rd value Matlab code for 1 and 2: % 1. A 3x1 vector. d0, d1 double. B = [d0*A (d0+d1)*A]; % B is 3x2 % 2. Normalize a set of 3D points % Divide each col by its 3rd value % pts 3xN. C 3xN. % If N = 1 you can do: C = pts./pts(3); if not: C = bsxfun(@rdivide, pts, pts(3,:)); C++ code for 1 and 2: // 1. Found the solution for that one! B << d0*A, (d0 + d1)*A; // 2. for (int i=0, i<N; i++) { // Something like this, but

Eigen::Matrix vs. boost::multi_array vs. Eigen::Map

徘徊边缘 提交于 2019-12-06 07:39:48
I'm getting puzzling results while doing fairly simple tasks to compare the performance of: Eigen::Matrix boost::multi_array boost::multi_array mapped to Eigen::Matrix using Eigen::Map This is an abridged version of my test code; a fuller version can be found at: http://pastebin.com/faZ7TvJG . boost::multi_array<double, 2, Eigen::aligned_allocator<double> > boost_multi_array; Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_matrix; Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> > boost_multi_array_mapped(boost_multi_array.data(),

RcppEigen - going from inline to a .cpp function in a package and “Map”

自古美人都是妖i 提交于 2019-12-06 05:51:07
Everything seems to work in my package, but I wanted to check if the steps to make it were correct and about memory use using "Map". (It's a simple example, somewhere in-between the inline examples and the fastLm() example.) Here is an inline function that takes the maximum over each column of a matrix: library(Rcpp); library(inline); library(RcppEigen); maxOverColCpp <- ' using Eigen::Map; using Eigen::MatrixXd; // Map the double matrix AA from R const Map<MatrixXd> A(as<Map<MatrixXd> >(AA)); // evaluate and columnwise maximum entry of A const MatrixXd Amax(A.colwise().maxCoeff()); return

Eigen compilation error with gcc 8.2.1 on MSYS2

梦想的初衷 提交于 2019-12-06 05:50:39
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:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Eigen:2, from src/registration/transform/search.h:21,

How to wrap Eigen::SparseMatrix over preexistant 3-standard compress row/colum arrays

一世执手 提交于 2019-12-06 05:06:17
NOTE: I allready asked this question, but it was closed because of "too broad" without much explanation. I can't see how this question could be more specific (it deals with a specific class of a specific library for a specific usage...), so I assume that it was something like a "moderator's mistake" and ask it again... I would like to perfom sparse matrix/matrix multiplication using Eigen on sparse matrices. These matrices are already defined in the code I am working on in standard 3-arrays compressed row/column strorage. Then I would like to use the Eigen::SparseMatrix class as a wrapper on

How translation a matrix(4x4) in Eigen?

ぐ巨炮叔叔 提交于 2019-12-06 05:03:33
问题 How translation a matrix(4x4) in Eigen? //identity matrix 4x4 /*type=*/Eigen::Matrix<float, 4, 4> /*name=*/result = Eigen::Matrix<float, 4, 4>::Identity(); //translation vector // 3.0f // 4.0f // 5.0f Translation<float, 3> trans(3.0f, 4.0f, 5.0f); ie, I have matrix: 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 And I want get this: 1.0 0.0 0.0 3.0 0.0 1.0 0.0 4.0 0.0 0.0 1.0 5.0 0.0 0.0 0.0 1.0 Right? How I can do this? I can do this: result(0, 3) = 3.0f; result(1, 3) = 4.0f

How to bridge a JavaScript (ragged) array and an std::vector<std::vector<T>> object?

一个人想着一个人 提交于 2019-12-06 04:11:21
In JavaScript I have a list of "lines", each of which consists of indefinite number of "points", each of which has a form of [x, y] . So it is a 3D ragged array. Now I need to pass it to my C++ code with the help from emscripten ( embind ). Here's declaration of the C++ function: Eigen::MatrixXd f(const std::vector<std::vector<std::vector<double>>>& lines); And I would like to get a list of lists ( [[m11, m12],[m22, m22],...] ) in JavaScript after calling f . How to write the binding code in this case (the stuff inside EMSCRIPTEN_BINDINGS , for example)? UPDATE : I can now pass the JavaScript

PCL1.8.1 点云坐标变换

谁说胖子不能爱 提交于 2019-12-05 19:47:35
通过Eigen的矩阵运算,将点云进行Z轴旋转45°,再沿X轴平移2.5. pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud(new pcl::PointCloud<pcl::PointXYZ>()); pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud(new pcl::PointCloud<pcl::PointXYZ>()); float theta = M_PI / 4; // The angle of rotation in radians Eigen::Affine3f transform_2 = Eigen::Affine3f::Identity(); // Define a translation of 2.5 meters on the x axis. transform_2.translation() << 2.5, 0.0, 0.0; // The same rotation matrix as before; theta radians around Z axis transform_2.rotate(Eigen::AngleAxisf(theta, Eigen::Vector3f::UnitZ())); // Print the transformation

Reshaping tensors in C++

一世执手 提交于 2019-12-05 19:41:15
The C++ interface to TensorFlow doesn't seem to have a reshape method. Does anyone have an idea how to convert e.g. [A,B,C,D] into [A*B,C,D] ? It looks like the only way to do this is to use Eigen? However, the documentation there is very slim and the code is template hell and not easy to parse. Solution with checking whether reshaped tensor has the same number of elements of the source tensor: // Extracted image features from MobileNet_224 tensorflow::Tensor image_features(tensorflow::DT_FLOAT, tensorflow::TensorShape({1, 14, 14, 512})); tensorflow::Tensor image_features_reshaped(tensorflow: