Questions tagged [eigen]

Eigen is a C++ template library for linear algebra: matrices, vectors, and related algorithms.

Eigen is a C++ template library for linear algebra: matrices, numerical solvers, and related algorithms.

Despite its name, this tag should not be mistaken with the and ones.

Eigen covers a large set of features through an easy to use unified API. Here is quick and incomplete overview:

  • Dense algebra:
    • array/matrix manipulation
    • linear solvers and factorizations (Cholesky, LU, QR, SVD, EVD)
  • Sparse algebra:
    • compressed sparse representation
    • direct solvers and factorizations (Cholesky, LU, QR)
    • Krylov subspace methods (CG, BiCGSTAB, GMRES) with preconditioners (Jacobi, ILLT, ILUT)
  • Geometry:
    • space transformation and subspace primitives

Find more on Eigen's home page and its online documentation.

3438 questions
8
votes
1 answer

C++ Eigen - How to combine broadcasting and elementwise operations

I have a MatrixXf variable and a VectorXf variable. I would like to perform a rowwise division using the Vector on my Matrix. Is it possible to do something like this? #include #include "Eigen/Dense" using namespace std; using namespace…
yc2986
  • 1,101
  • 3
  • 20
  • 23
8
votes
2 answers

Principal Component Analysis with Eigen Library

I'm trying to compute the 2 major principal components from a dataset in C++ with Eigen. The way I do it at the moment is to normalize the data between [0, 1] and then center the mean. After that I compute the covariance matrix and run an eigenvalue…
Chris
  • 1,266
  • 4
  • 16
  • 34
8
votes
3 answers

Using Eigen Array-of-Arrays for RGB images

I'm trying to use the Eigen library for some simple image processing. I'd use Array3f for an RGB triple and an Array to hold an RGB image. This seems to work partially, and I can conveniently do component-wise addition, multiplication and division…
8
votes
1 answer

Wrong results using auto with Eigen

I got different results using auto and using Vector when summing two vectors. My code: #include "stdafx.h" #include #include "D:\externals\eigen_3_1_2\include\Eigen\Geometry" typedef Eigen::Matrix Vector3; void…
8
votes
4 answers

Using Eigen Library in ROS Indigo

I am working on a project in ROS Indigo that requires using the Eigen libraries. According to indigo/Migration page on the ROS Wiki, the FindEigen.cmake module is now in the cmake_modules package. After following steps to add the cmake_modules…
smannan
  • 136
  • 1
  • 1
  • 4
8
votes
2 answers

Eigen vs Matlab: parallelized Matrix-Multiplication

I would like to compare the speed of Matlab in matrix multiplication with the speed of Eigen 3 on an Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz. The code including Eigen: #include #include "Eigen/Dense" #include #include…
pawel_winzig
  • 902
  • 9
  • 28
8
votes
4 answers

Eigen and C++11 type inference fails for Cholesky of matrix product

I am trying to take the cholesky decomposition of the product of a matrix with its transpose, using Eigen and C++11 "auto" type. The problem comes when I try to do auto c = a * b auto cTc = c.tranpose() * c; auto chol = cTc.llt(); I am using XCode…
c0g
  • 103
  • 4
8
votes
3 answers

How to solve large-scale nonlinear optimization problems with Ceres?

I need to optimize a surface represented by a 2D grid of points to produce normal vectors of the surface that align with provided target normal vectors. The grid size is likely to be between 201x201 and 1001x1001. That means that the number of…
Eric
  • 244
  • 5
  • 10
8
votes
1 answer

Eigen Library assigning Matrix's elements?

I came across the following assigning for a matrix in Eigen Library here Matrix3f m; m << 1, 2, 3, 4, 5, 6, 7, 8, 9; as an alternative way of the boring one (m(0,0) = 1; ... etc). My question is any considerations should I pay at…
CroCo
  • 5,531
  • 9
  • 56
  • 88
8
votes
1 answer

setting a row of a matrix to 0, in eigen

kind of strange: I'm trying to set a full row of a matrix to 0 and neither of the four obvious constructs in eigen would compile: //U is a p by p matrix. I wanna set its last column to 0.0f U=solved.eigenvectors(); U.row(p-1).array()=0; …
user189035
  • 5,589
  • 13
  • 52
  • 112
8
votes
1 answer

SparseMatrix construction in Eigen

I am building a sparse linear system with multiple (soft) constraints. I am converting some code which used to build the matrix with boost::ublas, to Eigen. The boost:ublas has a convenient way to create a sparse matrix with known (or estimated)…
nbonneel
  • 3,286
  • 4
  • 29
  • 39
8
votes
2 answers

Array of pointers to Eigen Matrices

I am using MatrixXd matrices from Eigen on my code, and at a certain point I need a 3D one. Since Eigen does not have tridimensional matrix types, as it is optimized just for linear algebra, instead I am creating a pointer array of the MatrixXd…
joaocandre
  • 1,621
  • 4
  • 25
  • 42
8
votes
1 answer

Rotation matrix in Eigen

Can I use the Eigen library to get the rotation matrix which rotates vector A to vector B? I have been searching for a while, but cannot find related api.
LittleSweet
  • 534
  • 2
  • 6
  • 9
8
votes
2 answers

Mapping array back to an existing Eigen matrix

I want to map an array of double to an existing MatrixXd structure. So far I've managed to map the Eigen matrix to a simple array, but I can't find the way to do it back. void foo(MatrixXd matrix, int n){ double arrayd = new double[n*n]; // map…
Manolete
  • 3,431
  • 7
  • 54
  • 92
7
votes
1 answer

How can I initialize a SparseVector in Eigen

How can I initialize a SparseVector in Eigen ? The following code: #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include using namespace Eigen; SparseVector vec(3); main() { vec(0)=1.0; } gives me the following…
Tarek
  • 1,060
  • 4
  • 17
  • 38