Questions tagged [eigen]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
95 views

Can Spectra find eigenvectors and eigenvalues of complex-valued matrices?

I am using Spectra to iteratively solve large-scale eigenvalue problems. I like it because it readily works on windows, and is header-only. I would like to know if it supports complex-valued matrices. ...
DJames's user avatar
  • 403
1 vote
0 answers
64 views

How can I optimize the solution of linear systems in my Finite Element Method code for solving nonlinear computational mechanics problems?

Currently, I use Eigen3 for linear algebra operations on sparse matrices and either UMFPACK or CHOLMOD from SuiteSparse to solve sparse linear systems. However, as my model grows larger and the need ...
Joaquim José da Silva Xavier's user avatar
0 votes
0 answers
49 views

How best to iterate over three dimensional grid?

My problem is to iterate through $[0.95,1] \times [0.95,1] \times[0.95,1] \in \mathbb{R}^{3}$. Is there a generic way to do this? I was considering rolling it all out and effectively vectorising the ...
KeynesCoeFen's user avatar
0 votes
0 answers
97 views

Numerical integration library interfacing with eigen

I am looking for a numerical integration library like this one. The examples look very appealing but I see that all test functions use very barebones C arrays. Do you have any recommendations of ...
KeynesCoeFen's user avatar
0 votes
0 answers
86 views

Solving L1 minimization problems in Eigen

I have an $m\times n$ dense matrix $\mathbf{M}$ and wish to solve $\mathbf{M}\mathbf{x} = \mathbf{b}$ via any of the "L1" methods using Eigen. By this I mean I'm happy with using basis ...
user14717's user avatar
  • 2,125
-1 votes
1 answer
467 views

How to initialize Eigen C++ parameters within for-loop? [closed]

I am new to Eigen C++ programming. I am trying to create an Rcpp function to call from R. The function takes a list of matrices (Xlst), and two lists of vectors (ylst and smwlst). In each for-loop ...
Shakil's user avatar
  • 1
0 votes
1 answer
2k views

Dynamic Sized Identity Matrix in Eigen

I am aware of creating an identity matrix in Eigen if the number of rows and columns are known. How do we create them dynamically when the size is not known? An example would be useful. Thanks.
user1408865's user avatar
1 vote
0 answers
751 views

Symmetric Matrix in Eigen C++

I am aware of a symmetric matrix type in uBLAS as ublas::symmetric_matrix matrix. Is there an equivalent for this in Eigen library that can be used to construct one or do we need to explicitly check ...
user1408865's user avatar
7 votes
1 answer
2k views

Eigen C++ Library Over 4x Slower than Fortran

I am experimenting with ways to call compiled programs from Python. My primary interest is iterative optimization methods, so I'm testing an implementation of Newton's method to solve a logistic ...
Robert Bassett's user avatar
0 votes
1 answer
4k views

C++ Eigen::Map class questions

The Eigen::Map documentation here (https://eigen.tuxfamily.org/dox/classEigen_1_1Map.html) mentions the following: This class represents a matrix or vector expression mapping an existing array of data....
commonys's user avatar
1 vote
0 answers
254 views

Why does Eigen allocate a temporary to evaluate A.noalias() = B.transpose()*C in parallel?

I wrote a program which iteratively transforms data using matrix multiplications. To minimize the number of large memory allocations, I use two roughly equal-sized ...
Wout12345's user avatar
2 votes
2 answers
264 views

Matlab - Compute approximative common eigenvectors basis between two matrices as a function of tolerance

I am looking for finding or rather building common eigenvectors matrix X between 2 matrices A and B such as : ...
user avatar
2 votes
1 answer
43 views

In Eigen, can a sparse matrix contain vectors/objects instead of simple scalar values?

I need to have a sparse matrix whose elements are not simple numbers, but objects, e.g. a couple of floating point values and a bunch of integer indices. I am wondering if Eigen has something similar, ...
Pietro's user avatar
  • 171
1 vote
1 answer
291 views

Range of a matrix from its complete orthogonal decomposition

In this StackOverflow answer, @Gokul has shown how to get a basis of the kernel of a matrix with the help of the 'Eigen' function CompleteOrthogonalDecomposition. ...
Stéphane Laurent's user avatar
1 vote
0 answers
416 views

Optimize speed for calculating the approximate inverse of a large matrix

I am searching for a faster method to calculate an approximate inverse of a large matrix (up to 32000x32000) resulting from a discrete non-linear system of partial differential equations. I'm using C++...
enco909's user avatar
  • 11
3 votes
1 answer
1k views

'Eigen' matrices with static dimension

I noticed that 'Eigen' matrices with dynamic dimension are less efficient than the matrices with static dimension. My algorithm uses a lot of matrices which don't need to be resized, so I wanted to ...
Stéphane Laurent's user avatar
8 votes
2 answers
240 views

A misunderstanding or a bug in LAPACK's solver for generalized eigenvalue problems?

In my application, I have two general real matrices $A$,$B$ defined as follows, $$ A=\begin{bmatrix} -s I_3 & A_0 & 0 & 0 \\ A_0^T & -s I_3 & 0 & 0 \\ 0 &...
user3677630's user avatar
1 vote
0 answers
656 views

Is there any function to calculate condition number of sparse matrix in Eigen libraray?

The function JacobiSVD and BDCSVD can calcuate condtion number of a dense matrix via singular values. However I need to know condition number of a sparese matrix due to slow computation speed using ...
Jogging Song's user avatar
3 votes
0 answers
685 views

Compute Nullspace of Sparse Matrix

I am computing the nullspace of a sparse rectangular $m$ x $n$ matrix $A$, where $m$ << $n$. I do this by computing the QR decomposition of $A^T$ and extract the $n-m$ right-most columns of the ...
Charlie S's user avatar
  • 661
0 votes
1 answer
357 views

Solving a sparse linear system using transpose of lower triangular matrix without copying

I have a sparse lower-triangular matrix $L$, and a right-hand side $b$, and I'd like to solve the linear system $$L^T x = b$$ but without explicitly creating $L^T$. Ideally, I could write something ...
Samuel Fleming's user avatar
2 votes
1 answer
484 views

How to perform an eigendecomposition of a general complex matrix with arbitrary precision in C/C++

I need to obtain the Eigenvectors of a general complex matrix, but with quadruple precision. Is anyone aware of a means to do this? I currently use Tux Eigen, and I see that in their unsupported ...
AlexD's user avatar
  • 131
0 votes
1 answer
272 views

Good C, C++ library for efficient grid search / tuples, ideally with bindings to Eigen

I have a $q$-dimensional grid, known at run, not compile-time, that has $50$ points in each direction and hence $50^3$ combinations that I would like to first build and then call a function with each ...
Hirek's user avatar
  • 183
2 votes
1 answer
91 views

Dense decomposition of very non-square matrices

I have inherited code that solves Eigen::Matrix problems using the code shown on this page: ...
Ken Y-N's user avatar
  • 121
1 vote
1 answer
441 views

C++: Efficient library for dense linear algebra operations (determinant & principal minors)

I usually work with Python, but my basic knowledge of c++ allows me to switch when I need to increase the speed of my code. Currently, I have a python script that (among other things) computes the ...
Alice Schwarze's user avatar
0 votes
1 answer
414 views

How to do a Generalized Complex Schur (or QZ) Decomposition with Eigen C++? [closed]

I would like to do a Generalized Schur (or QZ) decomposition for a pair of complex matrices $A$ and $B$. I found the following class: ...
RangerBob's user avatar
  • 101
3 votes
1 answer
2k views

How can I speed up this code for sparse matrix-vector multiplication?

I've written a C++ function that multiplies a sparse matrix (stored in CSR format) by a dense vector. Here's the code: ...
littleO's user avatar
  • 181
2 votes
0 answers
195 views

What matrix criteria is "large enough" for Eigen to use a BLAS backend?

Eigen's documentation says that any BLAS back-end can be used (e.g. MKL) to perform the actual matrix calculations. It is, however, very vague when discussing the criteria as to which the ...
Damien's user avatar
  • 792
5 votes
2 answers
5k views

Eigen - Max and minimum eigenvalues of a sparse matrix

I am working with an Eigen::SparseMatrix matrix of type double. I would like to find the largest and the smallest eigenvalues. A solution of the problem is to convert it to dense and then find its ...
Galuoises's user avatar
  • 153
1 vote
1 answer
2k views

Eigen - Solving Complex Generalized Eigenvalue Problem

I've been using the Eigen C++ linear algebra library to solve various eigenvalue problems with complex matrices. I've recently had to use a generalized eigenvalue solution process, only to be ...
Stuart Barth's user avatar
0 votes
1 answer
4k views

Inversion of a matrix using c++ library armadillo or eigen [closed]

I'm trying to find inverse of a matrix using c++ library armadillo or eigen. But first row of the matrix is wrong, please note that other elements are correct. I'm unable to understand what mistake I ...
AGN's user avatar
  • 534
6 votes
1 answer
3k views

Eigen - store sparse matrix as binary

I need to store large sparse matrices in Eigen. I cannot find anything in the library except the function below, in Eigen/Unsupported. The problem with saveMarket is, that it saves in text format. Due ...
physicsGuy's user avatar
2 votes
1 answer
4k views

Solving Linear Equations using Eigen

I am trying to solve linear equations in c++ using the Eigen library. For the simple equation Ax=b, I have a sparse matrix A that is n x n, and known values for b which is n x 1, but I need to find ...
honaes's user avatar
  • 21
1 vote
0 answers
446 views

How can I efficiently solve $Ax$=$b$ given $A$ is symmetric and contains very small (even negative) eigenvalues using EIGEN

Currently I am using the EIGEN C++ library to try to solve $x$ from the equation $Ax$ = $b$. One problem I encountered is that the matrix $A$ is a correlation matrix with size > 5000 and can ...
Sam's user avatar
  • 11
0 votes
1 answer
2k views

Order of eigenvalue problem using c++ Eigen library

I have the following 6x6 matrix (taken from Google Books p. 129): For background info: All the entries depend on the momentum $k$. Getting the eigenvalues of this matrix for each $k$ corresponds to ...
DaPhil's user avatar
  • 267
1 vote
1 answer
76 views

LAPACK DGGEVX: BALANC option

I'm using DGGEVX routine from LAPACKE with BALANC option as shown below, but to my surprise changing BALANC option from 'N' to ...
Megidd's user avatar
  • 165
5 votes
1 answer
6k views

How to use TrangularView class in Eigen C++

For a nonsingular lower or upper triangular square matrix $A$, how to solve such linear system in Eigen: $$A x = b$$
LCFactorization's user avatar
1 vote
1 answer
2k views

How can I reuse the SVD of matrix A to solve LS problems for both A and its transpose via Eigen C++?

If $A\in R^{m\times n}, b\in R^m, c\in R^n$, if I need to solve the least square problems via SVD of $A$ and $A^T$, i.e. I need to solve the least square solutions to following linear systems via ...
LCFactorization's user avatar
4 votes
1 answer
412 views

What is the most efficient way to obtain the max eigenvalue of a specific symmetric matrix via Eigen C++

Suppose I have a symmetric matrix $A_{1000\times 1000}$, which can be represented by: $A = J G J^T$ where $J$ in 1000x3 is full column rank dense matrix; $G$ in 3x3 is a nonsingular dense matrix. ...
LCFactorization's user avatar
2 votes
1 answer
146 views

How can I efficiently position the different segments of a large vector in Eigen C++?

I have a very large(up to 9 000 000) VectorXi vector defined in Eigen C++ which is read from a data file. The vector consists of 0, 1, 2, ...n segments with ...
LCFactorization's user avatar
2 votes
1 answer
659 views

How to implement the spectral decomposition of a symmetric dense matrix via Eigen C++

Spectral decomposition of symmetric matrix $A_{n\times n}$, specifically, $n=3$ find the orthogonal matrix $Q$ and diagonal matrix $\Lambda$ such that: $A=Q\Lambda Q^T$ How to implement such ...
LCFactorization's user avatar
3 votes
2 answers
1k views

How to re-use the coefficient matrix decomposition result when solving linear systems by Eigen C++

My problem needs to solve dense symmetric linear systems something like: A x = b, A y = x, ...
LCFactorization's user avatar
1 vote
1 answer
347 views

Is there congruent transform implementation for dense symmetric matrix in Eigen(C++)?

I need to determine whether a real dense symmetric matrix is positive definite or not. One possible way is to obtain all the eigen values and check the sign of the minimum eigen value but requires ...
LCFactorization's user avatar
3 votes
1 answer
5k views

How to change the dimensions of an Eigen Matrix in a loop?

I have a while loop, in which I use a Matrix A, vectors B and x with varying dimensions: <...
LCFactorization's user avatar
10 votes
1 answer
1k views

Why SVD is talk about less than QR and LU for sparse matrix?

For example the C++ sparse matrix libraries I used -- Eigen and SuiteSparse, they seem not to have any SVD funcitionality for sparse matrix. So just curious, is SVD more difficult than QR/LU for ...
user5302's user avatar
  • 201
0 votes
2 answers
3k views

Symmetric Matrix Computation (Eigen & C++)

I want to compute a symmetric matrix A from a vector b by: A = b * b'. Does the Eigen library automatically take into account that it does not need to do all calculations to get A (because of the ...
Armin Meisterhirn's user avatar
4 votes
1 answer
250 views

Why do I get “estimated error” -1.#IND when doing BICGSTAB linear solver using ILUT perconditioner in eigen

I'm using Eigen (a C++ library for numerical linear algebra) to solve a linear equation with the the bi-conjugate gradient BICGSTAB algorithm with Incomplete LU preconditioner. However, the result <...
Hao Yu's user avatar
  • 159
4 votes
1 answer
454 views

$\mathbf{UDU}^\top$ decomposition routines in LAPACK/Eigen?

I would like to compute the decomposition of a real symmetric positive definite matrix $\mathbf{A} = \mathbf{UDU}^\top$. LINPACK seems to have it as DSIFA, but I ...
Damien's user avatar
  • 792