Questions tagged [eigen]
Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
47
questions
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. ...
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 ...
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 ...
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 ...
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 ...
-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 ...
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.
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 ...
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 ...
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....
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 ...
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 :
...
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, ...
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. ...
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++...
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 ...
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 &...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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:
...
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:
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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$$
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 ...
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.
...
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 ...
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 ...
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,
...
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 ...
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:
<...
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 ...
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 ...
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 <...
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 ...