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
1
vote
1 answer

Computing eigen values using python different from Eigen Library in Cpp in non-positive components

I am using scipy.linalg import eigh to compute Eigenvalues. Everything works correctly, however, while computing a non-positive eigenvalue.The results provided from Scipy is different from Eigen library in Cpp. I tried the same array data on 2 Cpp…
anhbeo
  • 11
  • 1
1
vote
0 answers

Eigen::SparseQR::matrixQ() hangs forever for a large thin sparse matrix

I have a large but sparse matrix B, with size 19068 x 156, and 79884 nonzeros (so about 2.7% of entries are non-zero). I want to compute the kernal of the matrix Bᵀ, so I did a sparse QR decomposition on B. So if B = [Q₁ Q₂] * [R; 0], then Q₂ is a…
Hongkai Dai
  • 2,546
  • 11
  • 12
1
vote
0 answers

How does Eigen's SparseQR solve underdetermined systems

I am trying to solve a sparse least-squares like problem using the SparseQR solver in Eigen. In the course of my application, I have to solve for both the over and underdetermined equations provided by some matrix A where A is overdetermined and…
NateM
  • 177
  • 1
  • 12
1
vote
1 answer

Euler angle flips when close to zero degree

I am using quaternion in Eigens to calculate ZYX euler angles by: quaternion.toRotationMatrix().eulerAngles(2, 1, 0); But I found the values can occasionally flip between a very small number and a number very close to PI. I roughly understand why…
shelper
  • 10,053
  • 8
  • 41
  • 67
1
vote
1 answer

Eigen equivalent of Matlab rescale command

I'd like to recreate the Matlab rescale command in Eigen https://www.mathworks.com/help/matlab/ref/rescale.html I've tried to translate but not sure about it. My Eigen knowledge is too limited still... auto rescale = [&]( Eigen::MatrixXd mat,…
Kabu
  • 519
  • 6
  • 16
1
vote
1 answer

gprof declares too much as “spontaneous” with Eigen

I have a C++ project which uses the Eigen matrix library. In order to improve performance I need to get a profile for it. I have tried using gprof, but the profile contains a bunch of results like this, where it is marked as “spontaneous”: …
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
1
vote
0 answers

Product of an array of infinity by an array of zeros gives me an array of NaN

I want to multiply an array of infinity by another array of zeros using Eigen library: Eigen::ArrayXd a(2); a << INFINITY, INFINITY; Eigen::ArrayXd b(2); b << 0.000, 0.000; The result gives me: std::cout
RangerBob
  • 473
  • 3
  • 13
1
vote
1 answer

Error in CoeffRef of Eigen sparse matrix with elements type of a vector

I define a sparse matrix as Eigen::SparseMatrix< Eigen::Matrix >, which means each element of the matrix is a 3x1 vector. However, when I am calling the function CoeffRef in order to assign a vector into the elements, I got the…
Somayeh
  • 15
  • 3
1
vote
1 answer

Question about Eigen::MatrixXd column-wise calculation

Is there anyway to apply the column-wise calculation as follows? (each column divided by the last entry of the column) Eigen::MatrixXd A(3,5), B(3,5); A << 1, 4, 9, 16, 25, 2, 4, 6, 8, 10, 1, 2, 3, 4, 5; B = (A.col) /…
XJY95
  • 89
  • 6
1
vote
1 answer

Error when extracting rotation from Eigen::Isometry3d?

Eigen::Isometry3d M = Eigen::Isometry3d::Identity(); cout << M.rotation <
XJY95
  • 89
  • 6
1
vote
1 answer

strange memory behave of resize and reserve about vector

I know reserve(n) only allocate n space but size is zero. while resize(n) allocate n space and size is n. but when I observe the memory change by window task manager in the test , I'm confused by the result. I have a code already take 100MB, then I…
Mr.Guo
  • 167
  • 1
  • 9
1
vote
1 answer

Error compiling code which creates Eigen::ThreadPoolDevice object

Eigen Version 3.3.90 gcc Version 5.4.0 I'm currently trying to add multi-threading support to my Eigen Tensor project, and I've hit a problem creating the ThreadPoolDevice required to evaluate tensor operations. A minimal code example which…
1
vote
1 answer

Large sparse linear system solving with SimplicialCholesky Eigen

I am actually trying to solve large sparse linear systems using C++ lib Eigen. Sparse matrices are taken from this page. Each system as this structure: Ax = b where A is the sparse matrix (n x n), b is computed as A*xe with xe vector of dimension n…
Anto
  • 119
  • 1
  • 13
1
vote
1 answer

How does solve() compares with a simple matrix-vector multiplication in performance?

I need to solve a large number of linear problems with the same matrix of size of a few hundred. The initialization cost is irrelevant, but the run-time cost is critical. Naively, my LA background tells me I should just invert my matrix and use the…
1
vote
1 answer

Using a CwiseUnaryOp as an lvalue

I'm using Eigen's EIGEN_MATRIXBASE_PLUGIN functionality to implement a CwiseUnary expression and I'm having trouble working out to extend this work with operator= I'm working with a struct that has two members: .val_ and .d_, and I've added a…
AndrewrJ
  • 49
  • 1
  • 8