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

efficient computation of Trace(AB^{-1}) given A and B

I have two square matrices A and B. A is symmetric, B is symmetric positive definite. I would like to compute $trace(A.B^{-1})$. For now, I compute the Cholesky decomposition of B, solve for C in the equation $A=C.B$ and sum up the diagonal…
yannick
  • 397
  • 3
  • 19
7
votes
1 answer

Multiplying Transform and Matrix types in Eigen

To me this should just work, so the fact it does not, almost certainly means I am the one in the wrong. Even though in principle a Transform< double, 3, Affine > is the same as a Matrix< double, 4, 4 >, they cannot be used together…
cmannett85
  • 21,725
  • 8
  • 76
  • 119
7
votes
1 answer

Why Eigen use Column-Major by default instead of Row-Major?

Although Eigen is C++ library and C/C++ use row-major storage structure, why Eigen prefers to use column-major storage order? From Why does MATLAB use column-major order? post, I understand that MATLAB use it because of historical (due to FORTRAN)…
FurkanCoskun
  • 86
  • 1
  • 6
7
votes
2 answers

Cannot fetch Eigen with bazel: 406 Not Acceptable

When trying to download Eigen with http_archive( name = "eigen", strip_prefix = "eigen-3.3.7", sha256 = "d56fbad95abf993f8af608484729e3d87ef611dd85b3380a8bad1d5cbc373a57", urls = [ …
piarston
  • 1,685
  • 1
  • 13
  • 25
7
votes
1 answer

Ensuring that Eigen uses AVX vectorization for a certain operation

I've written vectorized versions of some functions that are currently the bottleneck of an algorithm, using Eigen's facilities to do so. I've also checked that AVX is enabled by making sure that EIGEN_VECTORIZE_AVX is defined after including…
bitonic
  • 126
  • 1
  • 7
7
votes
1 answer

Debugging Eigen in VSCode

During debugging I'd like to have access to eigen matrices and vectors values. It seems that once I have a .natvis file, a custom view of c++ object could be created. There is a .natvis file for Eigen here, however I don't know a way to integrate it…
ignacio
  • 1,181
  • 2
  • 15
  • 28
7
votes
2 answers

C++ Eigen Matrix clarifications

I have only recently started exploring C++ Eigen library and a little puzzled with some of the documentation. It would be great if someone can clarify this. In the common pitfalls (https://eigen.tuxfamily.org/dox-devel/TopicPitfalls.html) Alignment…
cplusplusrat
  • 1,435
  • 12
  • 27
7
votes
3 answers

How to extract matrixL() and matrixU() when using Eigen::CholmodSupernodalLLT?

I'm trying to use Eigen::CholmodSupernodalLLT for Cholesky decomposition, however, it seems that I could not get matrixL() and matrixU(). How can I extract matrixL() and matrixU() from Eigen::CholmodSupernodalLLT for future use?
coldsky
  • 85
  • 3
7
votes
3 answers

Copy templated function argument in Eigen

I am writing a generic class that utilizes Eigen data types. I already have problems assigning constructor arguments to class member variables. A simplified version of my code would be: template class A { public: …
7
votes
2 answers

CMake find_package not working for Eigen?

I'm currently developing a Kalman Filtering library using Eigen and I've successfully gotten it working on my development Mac. Now I'm trying to set it up with Travis CI and CMake is having trouble with finding the package. First I sudo apt install…
A Tyshka
  • 3,830
  • 7
  • 24
  • 46
7
votes
1 answer

C++ Eigen for solving linear systems fast

So I wanted to test the speed of C++ vs Matlab for solving a linear system of equations. For this purpose I create a random system and measure the time required to solve it using Eigen on Visual Studio: #include #include…
user3199900
  • 141
  • 2
  • 6
7
votes
1 answer

Exponential Averaging using Eigen

Consider the following code. const int N = 100; const float alpha = 0.9; Eigen::MatrixXf myVec = Eigen::MatrixXf::Random(N,1); Eigen::MatrixXf symmetricMatrix(N, N); for(int i=0; i
Soo
  • 885
  • 7
  • 26
7
votes
3 answers

Eigen and huge dense 2D arrays

I am using 2D Eigen::Arrays for a project, and I like to keep using them in the case of huge 2D arrays. For avoiding memory issues, I thought to use memory mapped files to manage (read/modify/write) these arrays, but I cannot find working examples.…
gmas80
  • 1,218
  • 1
  • 14
  • 44
7
votes
1 answer

Why does std::less fail to compile?

I implemented a comparison operator operator< for Eigen::VectorXd, and sometimes, I need to pass a compare function to another of my function, I am tired of wrapping the operator< into [](const VectorXd& v1, const VectorXd& v2)->bool{return v1 <…
Alaya
  • 3,287
  • 4
  • 27
  • 39
7
votes
5 answers

Solving normal equation system in C++

I would like to solve the system of linear equations: Ax = b A is a n x m matrix (not square), b and x are both n x 1 vectors. Where A and b are known, n is from the order of 50-100 and m is about 2 (in other words, A could be maximum…
Eagle
  • 3,362
  • 5
  • 34
  • 46