Questions tagged [eigen3]

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

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. Homepage: http://eigen.tuxfamily.org

Please use eigen3 tag specifically for questions related to version 3 of the library.

1014 questions
9
votes
0 answers

std::sort with struct containing Eigen datatype causes segfault

I have the following issue when compiling in release mode using MSVC 19.31.31106.2 (and C++17, as far as I understand the eigen page, alignment should be not an issue anymore) that I get a segfault from within of std::sort. The official Eigen 3.4…
Anima
  • 339
  • 2
  • 16
9
votes
1 answer

Python numpy code more efficient than eigen3 or plain C++

I had some code in Python3 (with numpy) that I wanted to convert to C++ (with eigen3) in order to get a more efficient program. So I decided to test a simple example to assess the performance gain I would get. The code consists on two random arrays…
Sermal
  • 187
  • 1
  • 9
9
votes
2 answers

Use BLAS and LAPACK from Eigen

I've implemented a piece of code with Eigen and I would like Eigen to use BLAS and LAPACK . I've seen here, that is possible but I don't know how or where to put those values/directives in the code. I have to expecify somewhere the value…
Santi Peñate-Vera
  • 1,053
  • 4
  • 33
  • 68
9
votes
1 answer

Using Eigen 3.3 in a CUDA kernel

Since Nov. 2016 it's possible to compile CUDA code which references Eigen3.3 - see this answer This answer is not what I'm looking for and may now be "outdated" in the sense that there might now be an easier way, since the following is written in…
GPMueller
  • 2,881
  • 2
  • 27
  • 36
9
votes
4 answers

Eigen matrix library filling a matrix with random float values in a given range

The setRandom function in the Eigen matrix library fills a given matrix with random numbers in the range [-1,1]. How can I extend this to generate numbers within any given range? I require floating point numbers and I am okay with pseudo-randomness.…
pincir
  • 345
  • 1
  • 3
  • 7
9
votes
3 answers

Eigen - Check if matrix is Positive (Semi-)Definite

I'm implementing a spectral clustering algorithm and I have to ensure that a matrix (laplacian) is positive semi-definite. A check if the matrix is positive definite (PD) is enough, since the "semi-" part can be seen in the eigenvalues. The matrix…
dim_tz
  • 1,451
  • 5
  • 20
  • 37
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
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
1 answer

Ambiguous recursive template function

In C++11, I need to call a function recursively from 0,...,n (where n is a compile time constant). This is the structure of the problem, which appears to be fatally flawed: #include "Eigen/Dense" template struct Int { }; template
bremen_matt
  • 6,902
  • 7
  • 42
  • 90
8
votes
0 answers

Eigen/Eigenvalues: Too many sections with mingw-w64

I want to compile the following example based on Eigen's general eigenvalue solver (Eigen 3.3.3): #include #include int main() { Eigen::Matrix4f A; A << -0.75, 0, -1.5, -1, -1.25, 0, -1.5, -1, …
MannyC
  • 91
  • 3
8
votes
3 answers

How to convert Eigen library's Matrix or Vector types to string?

How to get text representation for Vector3f or other types in Eigen library. I see lot of examples that uses .format() which returns WithFormat class. This then can be used with cout. However I'm looking for way to get Vector3f as std:string in some…
Shital Shah
  • 63,284
  • 17
  • 238
  • 185
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

conservativeResize() with zero values for the new values

How to set the new values to zero after resizing a matrix? It is really weird that after resizing the matrix, the new values are set to trash values instead of at least set to zero. N = 0; Eigen::MatrixXd CO; CO.setZero(3+3*N, 3+3*N); std::cout <<…
CroCo
  • 5,531
  • 9
  • 56
  • 88
8
votes
1 answer

Checking if all entries in the matrix are zero in Eigen Library

First of all, I'm not really sure if this is possible. I would like to check whether a matrix is zero or not in Eigen Library (note: I have to declare it). My solution is to check if all elements are zero. My question is Is there another way fulfill…
CroCo
  • 5,531
  • 9
  • 56
  • 88
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
1
2
3
67 68