eigen

Least Squares Solution of Linear Algerbraic Equation Ax = By in Eigen C++

旧街凉风 提交于 2019-12-08 09:07:28
问题 I have a set of linear algebraic equations in matrices form, Ax=By . Where A is matrix of 36x20 and x is a vector of size 20 , B is 36x13 and y is 13x1 . Rank(A)=20 . Because system is overdetermined (there are more number of equations than the variables), so least squares solution is possible, i,e; x = (A^TA)^-1A^TBy . I want the solution so that the residual error e = Ax-By should be minimized. Using Eigen/Dense library of C++ i have formulated all the matrices etc. I tried the method

Visual studio 2015. c++ compiler error C2280 attempting to reference a deleted function

烂漫一生 提交于 2019-12-08 08:48:56
问题 What i am trying to do is to compile project which was built by CMake. In my code i have next method: /** "in-place" version of TriangularView::solve() where the result is written in \a other * * \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here. * This function will const_cast it, so constness isn't honored here. * * See TriangularView:solve() for the details. */ template<typename MatrixType, unsigned int Mode> template<int Side,

Eigen's LeastSquaresConjugateGradient solver: using Incomplete Cholesky preconditioner and specifying coefficient starting values

↘锁芯ラ 提交于 2019-12-08 07:26:23
问题 To solve a rectangular sparse linear system of equations I would like to use Eigen's LeastSquaresConjugateGradient. Aside from the default Jacobi and Identity preconditioner I was wondering though if it is possible to also use Incomplete Cholesky as a preconditioner within LeastSquaresConjugateGradient? The Rcpp code I have and which uses the default Jacobi ([LeastSquareDiagonalPreconditioner) preconditioner is: library(inline) library(RcppEigen) solve_sparse_lsconjgrad <- cxxfunction(

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

Transform dolfin::Matrix into Eigen::Matrix

谁都会走 提交于 2019-12-08 06:35:52
问题 I am coding in C++ and use Fenics for finite element discretization. Now I would like to transform a dolfin::Matrix into a Eigen::Matrix. How can I do that? I have done something similar for vectors: I have given c_vec which has the type: std::shared_ptr<dolfin::Vector> Then I have used std::vector<double> c_vec_new; c_vec->gather_on_zero(c_vec_new); (I am computing parallel). And then I could create a Eigen::Vector by Eigen::Map<Eigen::VectorXd> c_vec_eigen(c_vec_new.data(),c_vec_new.size())

Eigen on ARM Cortex M3 with armcc

纵饮孤独 提交于 2019-12-08 04:13:46
问题 I'm trying to use Eigen library with armcc compiler using Keil for Cortex M3 target and I get compilation error: Eigen/src/Core/Transpositions.h(387): error: #135: class template "Eigen::Transpose<Eigen::TranspositionsBase<Derived>>" has no member "derived" It comes from this code: class Transpose<TranspositionsBase<TranspositionsDerived> > { typedef TranspositionsDerived TranspositionType; typedef typename TranspositionType::IndicesType IndicesType; public: explicit Transpose(const

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

大憨熊 提交于 2019-12-08 02:16:44
问题 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

Replicating TensorFlows Conv2D Operating using Eigen Tensors

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:54:22
问题 I'm trying to implement a lightweight (minimal library dependencies) version of a TensorFlow graph in c++ and I'm trying to use Eigen Tensor objects to perform the graphs operations. Right now I'm stuck trying to use the Eigen Tensor.convolve() method to try and replicate the behaviour of TensorFlow's Conv2D operation. To keep things simple my initial Conv2D operation has no padding and strides of one. The input to convolutional layer is a 51x51x1 tensor which is being convolved with a filter

Eigen cmake requires “target_link_libraries” even though it's template-only

梦想的初衷 提交于 2019-12-08 00:02:14
问题 In Eigen library's official cmake doc, it requires the line target_link_libraries (example Eigen3::Eigen) . I have tried removing that line, but then the compilation would fail with "Eigen not found". This directly contradicts the discussion in another StackOverflow question: Using Eigen Lib in my Cmake project? I don't understand why Eigen would need target_link_libraries even though it's a template-only library? Just like the above StackOverflow question, I'd assume I only have to include