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
9
votes
2 answers

How to convert Eigen::Matrix4f to Eigen::Affine3f

I want to convert a matrix from Eigen::Matrix4f to Eigen::Affine3f Any one help? Thanks
Vincent 炜森
  • 109
  • 1
  • 2
  • 7
9
votes
2 answers

Eigen alignment issues

Do the memory alignment issues with Eigen listed in the documentation still apply with C++11? It seems that C++11 can already take care of properly aligning objects on the stack and on the heap, with alignas and std::allocator which supports…
tmlen
  • 8,533
  • 5
  • 31
  • 84
9
votes
1 answer

Eigen: How to make a deep copy of a matrix?

Using the Eigen C++ library, how can I make a deep copy of a matrix? For example, if I have: Eigen::Matrix4f A; Eigen::Matrix4f B = A; And then I modify A, it will also modify B. But I want B to be a copy of the elements of the original A. How can…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
9
votes
2 answers

Creating an Eigen matrix from an array with row-major order

I have an array of doubles, and I want to create a 4-by-4 matrix using the Eigen library. I also want to specify that the data is stored in row-major order. How can I do this? I have tried the following, but it does not compile: double…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
9
votes
2 answers

Convert an Eigen matrix to Triplet form C++

I think Eigen uses compressed methods to store sparse matrices. Is there any way that I can extract Triplet-format vectors of an Eigen sparse matrix in from of std::vectors? Thanks. More info (an example of triplet format) Triplet format of matrix :…
Sina J
  • 193
  • 1
  • 4
9
votes
1 answer

Trilateration in Android using iBeacons

We want to implement some kind of indoor position determination using iBeacons. This article seems really interesting, in which the author implemented the Non-linear Least Squares Triangulation, using the Eigen C++ library and the Levenberg…
Lucas Coelho
  • 583
  • 6
  • 11
9
votes
4 answers

How to optimize this product of three matrices in C++ for x86?

I have a key algorithm in which most of its runtime is spent on calculating a dense matrix product: A*A'*Y, where: A is an m-by-n matrix, A' is its conjugate transpose, Y is an m-by-k matrix Typical characteristics: …
Jason R
  • 11,159
  • 6
  • 50
  • 81
9
votes
2 answers

Eigen - get a matrix from a map?

I'm using Eigen::Map to get access to create an object from a C-array. I would like to save that object as a member variable of type MatrixXf. How do I do that? I couldn't find a way to convert the Map to a Matrix. Thanks.
Ran
  • 4,117
  • 4
  • 44
  • 70
9
votes
1 answer

Convert an Eigen affine transformation to an Eigen isometry transformation

What is the simplest way to convert an affine transformation to an isometric transformation (i.e. consisting of only a rotation and translation) using the Eigen library? Both transformations are 3D. The affine matrix has a general 3x3 matrix (i.e.…
user664303
  • 2,053
  • 3
  • 13
  • 30
9
votes
2 answers

Setting up projection, model, and view transformations for vertex shader in eigen

I've looked around and have never seen, nailed down, exactly what each matrix does and what operations form them (so the actual eigen function calls). This is what I'm looking for. Or at least a description of the process and a couple examples…
user173342
  • 1,820
  • 1
  • 19
  • 45
9
votes
1 answer

Eigen: Best way to evaluate A*S*A_transpose and store the result in a symmetric matrix

Let S be a symmetric n x n matrix and A be a m x n matrix. Given: B = A * S * A_transpose (where "*" represents a matrix product operation) B will also be a symmetric matrix. Using the tuxfamily Eigen library, version 3, what is a clean and…
arr_sea
  • 841
  • 10
  • 16
8
votes
0 answers

Compiler, library, or user error? Eigen::Array, GCC 12.1, "array subscript [...] is partly outside array bounds"

After updating to GCC 12.1, I got a array subscript ‘__m256d_u[0]’ is partly outside array bounds error (or rather warning with -Werror) in my project, so I tried isolating the problem. Here's an MWE, which I also put on godbolt (vector type is…
RL-S
  • 734
  • 6
  • 21
8
votes
2 answers

Implementing a multivariate gaussian probability density function for >2 dimensions in C++

I'm working on implementing a probability density function of a multivariate Gaussian in C++, and I'm stuck on how to best handle the cases where dimension > 2. The pdf of a gaussian can be written as where (A)' or A' represents the transpose of…
kmore
  • 924
  • 9
  • 18
8
votes
0 answers

RcppEigen slicing method to obtain subset of a matrix not working consistently and causes fatal error/crash

I'm writing an R package using Rcpp and RcppEigen and I'm having a problem with matrix slicing and sub-setting. I need to get an off-diagonal square matrix from a larger square matrix The Eigen::MatrixXd slicing methods seem to be the problem. Using…
morrowcj
  • 169
  • 6
8
votes
2 answers

Suppressing warning C4996: why not working?

Context: I am playing around with spline fitting module of Eigen library. The fit works nice enough, but I do get some warnings (in Visual Studio 2013). The question: Why am I able to disable some warnings whereas other persist even after they…