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
11
votes
3 answers

How to use pretty debugging printers to see Eigen objects in QtCreator?

I am trying to see the contents of an Eigen vector in the Locals and Expressions window of the QtCreator: I see that it is a vector with 10 components: but when I click it open I get: I tried to use this script to do the trick. I saved it along…
Martin Drozdik
  • 12,742
  • 22
  • 81
  • 146
11
votes
3 answers

Eigen and boost::serialize

I tried to write a generic serialize function which takes any dense matrix and serializes it: Some other questions which help but not to the end are here: Question1 Question2 I tried the following which should work: namespace boost { namespace…
Gabriel
  • 8,990
  • 6
  • 57
  • 101
11
votes
2 answers

Why Eigen is 5x slower than ublas on following example?

At Eigen version I use "true" fixed size matrices and vectors, better algorithm (LDLT versus LU at uBlas), it uses SIMD instructions internally. So, why it is slower than uBlas on following example? I am sure, I am doing something wrong - Eigen MUST…
qble
  • 1,256
  • 2
  • 12
  • 29
11
votes
2 answers

How to implement an array of 3d vectors

I decided to use Eigen library in my project. But it is not clear from documentation how the most efficiently one should specify an array of 3d vectors. As I suggest, the first way is Eigen::Matrix
Oleg Zhyan
  • 113
  • 1
  • 6
10
votes
1 answer

Transitive effect of Eigen EIGEN_MAKE_ALIGNED_OPERATOR_NEW?

Recently, I was made aware of the potential issues of memory alignment for Fixed-size vectorizable Eigen objects. The correct code as stated in the doc: class Foo { ... Eigen::Vector2d v; ... public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; ... …
Catree
  • 2,477
  • 1
  • 17
  • 24
10
votes
6 answers

Worse performance using Eigen than using my own class

A couple of weeks ago I asked a question about the performance of matrix multiplication. I was told that in order to enhance the performance of my program I should use some specialised matrix classes rather than my own class. StackOverflow users…
george
  • 121
  • 1
  • 2
  • 5
10
votes
1 answer

C++ use of Eigen in tensorflow

What is the relation between tensorflow and Eigen, particularly regarding the tensor datastructures? There are some older quotations (e.g. here) which state that tensorflow is using Eigen extensively (afaik a tensorflow guy has extended the Eigen…
davidhigh
  • 14,652
  • 2
  • 44
  • 75
10
votes
2 answers

Eigen efficient inverse of symmetric positive definite matrix

In Eigen, if we have symmetric positive definite matrix A then we can calculate the inverse of A by A.inverse(); or A.llt().solve(I); where I is an identity matrix of the same size as A. But is there a more efficient way to calculate the inverse…
dpritch
  • 1,149
  • 13
  • 15
10
votes
2 answers

What does Transform::linear() return in the Eigen library?

With the Eigen C++ library, I'm having trouble understanding the Transform::linear() function. According to the documentation, it returns the linear part of the transformation. But what does this mean? Surely all matrix transformations are…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
10
votes
6 answers

Euler to Quaternion / Quaternion to Euler using Eigen

I'm trying to implement a functionality that can convert an Euler angle into an Quaternion and back "YXZ"-convention using Eigen. Later this should be used to let the user give you Euler angles and rotate around as Quaternion and convert Back for…
Little-God
  • 183
  • 1
  • 3
  • 16
10
votes
5 answers

How can I calculate inverse of sparse matrix in Eigen library

I have a question about Eigen library in C++. Actually, I want to calculate inverse matrix of sparse matrix. When I used Dense matrix in Eigen, I can use .inverse() operation to calculate inverse of dense matrix. But in Sparse matrix, I cannot…
kujungmul
  • 115
  • 1
  • 1
  • 7
10
votes
3 answers

Eigen Matrix vs Numpy Array multiplication performance

I read in this question that eigen has very good performance. However, I tried to compare eigen MatrixXi multiplication speed vs numpy array multiplication. And numpy performs better (~26 seconds vs. ~29). Is there a more efficient way to do this…
Akavall
  • 82,592
  • 51
  • 207
  • 251
10
votes
1 answer

Coefficient-wise custom functions in Eigen

I have a do_magic method which takes a double and adds 42 to it. I'd like to apply this method to each coefficient of a Eigen::Matrix or Eigen::Array (that means, I wouldn't mind if it's only possible with one of both types). Is this possible? Like…
wal-o-mat
  • 7,158
  • 7
  • 32
  • 41
10
votes
1 answer

Eigen dynamic matrix initialization

I am having some trouble figuring out how to set the rows and columns of a MatrixXd at runtime in Eigen. Can anyone point me to some documentation or give some pointer on how to do this? Thanks.
vPraetor
  • 313
  • 1
  • 3
  • 13
10
votes
1 answer

Initialize an Eigen::MatrixXd from a 2d std::vector

This should hopefully be pretty simple but i cannot find a way to do it in the Eigen documentation. Say i have a 2D vector, ie std::vector > data Assume it is filled with 10 x 4 data set. How can I use this data to fill out an…
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175