eigen

How to ensure Eigen isometry stays isometric?

冷暖自知 提交于 2020-01-03 16:58:59
问题 I am currently looking into Eigen::Isometry3f , defined as typedef Transform<float,3,Isometry> Isometry3f; . Therewith i cannot, for example, assign an Affine3f to that Isometry3f , which is good to keep the isometry intact. (The reason is, that Mode is checked in the assignment operator of Transform .) I can however - via the Transform::operator(...) , which shortcuts to Transform::m_matrix(...) - do Eigen::Isometry3f iso; iso.setIdentity(); iso(1, 1) = 2; //works (but should not ?!) and

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

佐手、 提交于 2020-01-02 16:30:27
问题 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

Best way of solving sparse linear systems in C++ - GPU Possible?

谁都会走 提交于 2020-01-02 06:24:06
问题 I am currently working on a project where we need to solve |Ax - b|^2 . In this case, A is a very sparse matrix and A'A has at most 5 nonzero elements in each row. We are working with images and the dimension of A'A is NxN where N is the number of pixels. In this case N = 76800 . We plan to go to RGB and then the dimension will be 3Nx3N . In matlab solving (A'A)\(A'b) takes about 0.15 s, using doubles. I have now done some experimenting with Eigens sparse solvers. I have tried: SimplicialLLT

Using Eigen::VectorXd (Eigen 3.3.4) as a state type in boost::numeric::odeint (Boost 1.65.1)

谁说我不能喝 提交于 2020-01-01 16:37:22
问题 During my work, it would be a requirement for me to use Eigen::VectorXcd as state type, to solve a huge linear ODE system. In that project, the matrix in the ODE system is sparse. Multiplying a it with a dense vector can be computed in parallel in a simple way using Eigen. However, I have faced some problems in that situation that I will tell in details below. Currently I am applying a not-so efficient solution, namely, I use arma::cx_vec as state type, and declare the matrix corresponding

Cast dynamic matrix to fixed matrix in Eigen

爱⌒轻易说出口 提交于 2020-01-01 11:10:06
问题 For flexibility, I'm loading data into dynamic-sized matrices (e.g. Eigen::MatrixXf ) using the C++ library Eigen. I've written some functions which require mixed- or fixed-sized matrices as parameters (e.g. Eigen::Matrix<float, 3, Eigen::Dynamic> or Eigen::Matrix4f ). Assuming I do the proper assertions for row and column size, how can I convert the dynamic matrix (size set at runtime) to a fixed matrix (size set at compile time)? The only solution I can think of is to map it, for example:

How can I initialize a SparseVector in Eigen

空扰寡人 提交于 2020-01-01 09:33:53
问题 How can I initialize a SparseVector in Eigen ? The following code: #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include <Eigen/Sparse> using namespace Eigen; SparseVector<float> vec(3); main() { vec(0)=1.0; } gives me the following error error: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type vec(0)=1.0; by the way, vec[0]=1.0 doesn't work either. 回答1: Looking at the documentation I noticed Scalar& coeffRef(Index

Most efficient way to loop through an Eigen matrix

99封情书 提交于 2019-12-31 10:48:43
问题 I'm creating some functions to do things like the "separated sum" of negative and positive number, kahan, pairwise and other stuff where it doesn't matter the order I take the elements from the matrix, for example: template <typename T, int R, int C> inline T sum(const Eigen::Matrix<T,R,C>& xs) { T sumP(0); T sumN(0); for (size_t i = 0, nRows = xs.rows(), nCols = xs.cols(); i < nRows; ++i) for (size_t j = 0; j < nCols; ++j) { if (xs(i,j)>0) sumP += xs(i,j); else if (xs(i,j)<0) //ignore 0

Substitutions for Eigen::MatrixXd typedefs

。_饼干妹妹 提交于 2019-12-31 04:38:09
问题 What is the simplest way to replace all Eigen::MatrixXd s and Eigen::VectorXd s with Vectors and Matrices that have long double elements? Every basic floating point variable in my code is of type long double . Also, everytime I use a matrix or vector, I use the following typedefs. typedef Eigen::VectorXd Vec; typedef Eigen::MatrixXd Mat; What's the best thing to switch these typedefs to? What happens if I leave them as they are? 回答1: Simply define your own typedefs based on Eigen's own global

No known expression from value to value&… Why?

孤街浪徒 提交于 2019-12-31 03:03:44
问题 I have tried writing a function which takes a ColXpr value as input: typedef Eigen::Array<float, Eigen::Dynamic, Eigen::Dynamic> Signal2D; void Threshold(Signal2D::ColXpr& params) { params = (params >= 0.0f).template cast<float>(); } When I try to call this function I do something like this: Signal2D arr; // fill it with stuff Threshold(arr.col(0)); Then I get this compiler error: src/core/Neuron.h:91:14: note: no known conversion for argument 1 from ‘Eigen::DenseBase<Eigen::Array<float, -1,

Serializing Decomposed Matrix from eigen (SparseLU object)

泄露秘密 提交于 2019-12-30 14:40:30
问题 I am trying to solve Ax=b where the matrix A can be big close to 1M x 1M in size, is sparse and symmetric but might not be positively defined. Problem is that it might take a long time to compute the decomposition using the sparseLU object in eigen and it will be idea for one to store the sparseLU matrix instead of the original matrix such that whenever we perform similar operation using the same matrix A, we can speed things up by not needing to re-compute the A quick search on stackoverflow