Questions tagged [eigen]
Eigen is a C++ template library for linear algebra: matrices, vectors, and related algorithms.
3,344
questions
1
vote
0
answers
26
views
How to configure the nvcc compiler for using Eigen library?
I had an absolutely working project containing the Eigen 3.4.0. After installing Сuda 12.0, Visual Studio began to issue an error at the compilation stage on the script in the Eigen library itself in ...
1
vote
3
answers
51
views
Eigen array shift gives strange result
I'm almost sure it's a trivial problem, but I can't understand what wrong is going on.
I have a simple array in Eigen that I need to right-shift, so that I can always insert new sample at position 0:
#...
4
votes
1
answer
45
views
Eigen very slow when chaining operations
While trying to compute the variance of row vectors in large matrices I've noticed an odd behavior with Eigen. If I chain all the required operations I get extremely slow performance, meanwhile ...
1
vote
0
answers
39
views
Difference in Matrix operations with very small values on Eigen (C++) vs Fortran 90
Why am I getting slightly different results when I do the inverse of a matrix and multiply it by the original matrix? C++ (Eigen Library) vs Fortran (Using old Microsoft Developer Studio, Fortran ...
-1
votes
0
answers
34
views
Eigen values in Python versus Matlab [duplicate]
np.linalg.eig in Python
eig in Matlab
I found that the eigen values in Matlab come in ascending order (??) of norms.
In Python they sometime come in ascending and other times come in descending order....
0
votes
2
answers
44
views
C++/Eigen - How to pass a general vector as parameter?
Using Eigen 3.4.0
I want to write a function general for any Eigen::Vector. e.g.
Eigen provides MatrixBase for any Eigen object, but I want to be explicit that this is a vector only function.
For ...
0
votes
1
answer
32
views
Why is my RcppEigen code almost 40 times slower than R's base LAPACK implementation?
I'm trying to implement efficient matrix LLT (or LU, whatever) decomposition for some covariance matrix shenanigans.
I've been using the Eigen library (through RcppEigen) for a while and, just for fun,...
0
votes
1
answer
22
views
Error when compiling R packages : Eigen/Core : new: no file or directory
This is my first question on stack ! Hope I follow correctly the guidelines...
Device
Thinkpad series
Manjaro KDE (kernel 5.13)
Fresh R install (4.2)
Fresh Rstudio install
Several packages installed ...
1
vote
2
answers
61
views
How to improve cwiseProduct operations?
I have this function that is called several times in my code:
void Grid::computeFVarsSigma(const int DFAType,
const Matrix& D_sigma,
...
5
votes
2
answers
198
views
Write numpy einsum operation as eigen tensors
I want to write the following numpy einsum as a an Eigen Tensor op
import numpy as np
L = np.random.rand(2, 2, 136)
U = np.random.rand(2, 2, 136)
result = np.einsum('ijl,jkl->ikl', U, L)
I can ...
0
votes
0
answers
36
views
g2o: How to optimize camera intrinsic (fx,fy,cx,cy) during Bundle Adjustment
Some pre-defined edges, such as EdgeProjectXYZ2UV, EdgeSE3ProjectXYZ, are widely used during BA. However, they can only set unchangeable camera parameters. I'm wondering if I can set optimizable ...
0
votes
1
answer
49
views
Error in calculating general lpNorm with Eigen
I am trying to calculate the lpNorm of a vector with the Eigen library.
As it can be seen in the example below, with explicit values, such as v.lpNorm<1>(), it works. But it doesn't work inside ...
0
votes
0
answers
42
views
How to use Eigen::Ref with STL Vector?
currently, I'm working on a specific problem where I have an STL vector with several mapped Eigen vectors of different sizes which I would like to keep.
When writing a function to accept my stl vector ...
0
votes
1
answer
45
views
Loop vectorising of vector3d products using Eigen
Hi I'm using Eigen to roll or vectorise a number of loop operations in a particle filter.
In essence I have two matricies
Eigen::Matrix<N, 3> A;
Eigen::Matrix<3, N> B;
Where N is a large ...
0
votes
1
answer
51
views
How to use mult-Threads in Eigen‘s cwise operations
There are many operations similar to dot multiplication in my code.but it seems that Eigen's cwise operation does not use use mult-Threads.I tried to perform similar operations with openmp, and found ...
-1
votes
1
answer
50
views
Performing Matrix Vector Product using Eigen library in C++
How do I perform a matrix vector product using the Eigen library in C++ with a "for loop", when the date type of my variables are in the form Eigen::MatrixXd and Eigen::VectorXd?
NOTE: I don'...
0
votes
1
answer
41
views
Eigen - calculate PCA: is this method the most efficient?
Using Eigen3,
Is there a more efficient way to calculate PCA? mat is the matrix of raw data:
MatrixXd centered = mat.rowwise() - mat.colwise().mean();
MatrixXd cov = centered.adjoint() * centered;
...
0
votes
0
answers
54
views
How can I deal with the following : "error: the value of 'foo' is not usable in a constant expression."?
I am using Yaml-cpp and Eigen in my small project.
For example, in cfg_.yaml
foo:
bar: 15
In constants.h
#pragma once
#include "yaml-cpp/yaml.h"
#include <iostream>
#ifndef ...
0
votes
1
answer
36
views
C++ Eigen - function to accept Map/Matrix and return Matrix of same type
I need a function that is capable of accepting both an Eigen::Map or Eigen::Matrix as input and output an Eigen::Matrix of the same type.
Using Eigen 3.4.0
My current implementation is as follows:
...
0
votes
1
answer
50
views
Eigen find set difference between two matrices
I'd like to obtain the set difference between two Eigen matrices. The code:
void diffMatrix(
MatrixXi &M1, // First Matrix
MatrixXi &M2, // Second Matrix
MatrixXi &M3, // ...
-2
votes
0
answers
31
views
How to use index matrix like matlab in Eigen [duplicate]
In matlab, I have a vector y.
Now, I have a matrix x, which stores the index pointing to the element in y.
In matlab, I just need to call result=y(), then I can get a new matrix result.
like this
K>...
0
votes
1
answer
79
views
Eigen::Map alignment of raw buffer
In using the Eigen library, I have a templated C++ class comprising a raw buffer and an Eigen::Map instance as a member. In the constructor of the class, I initialize the map as follows:
template<...
0
votes
1
answer
53
views
How can be OpenMP used with the class and Eigen?
I am trying to make code using OpenMP, some class and Eigen.
The overall code is at the bottom.
The code is a simplified version of what I want to do in my project.
The simplified code is just a ...
0
votes
1
answer
45
views
Convert std::vector<double> to Eigen::ArrayXd in c++?
how can I convert a vector to an eigen arrayxd in c++?
The only way I found involve doing:
Eigen::ArrayXd newEigen = Eigen::ArrayXd::Zero(oldVector.size());
and then making a loop to replace each ...
0
votes
1
answer
28
views
Template to compute size of Eigen matrix or tuple type object
I am trying to write some generic code which can compute the size of some data. This size is basically the number of elements in an array/tuple like structure or in an Eigen matrix.
I have tried the ...
0
votes
0
answers
28
views
what is assertion error with eigen meaning?
When I compute generalized eigen,I write this following code ,and the part of code :
Eigen::MatrixXcf get_Generalized_eigen(const Eigen::MatrixXf &A, const Eigen::MatrixXf &B){
Eigen::...
3
votes
2
answers
89
views
Structures Having Eigen Members in C++20
The Eigen documentation mentions that structures having fixed-size vectorizable Eigen types can cause problems with allocation. They mention:
If you're compiling in [c++17] mode only with a ...
1
vote
0
answers
21
views
Eigen matrices of boost rationals failing only in dimension 4
I'm trying to evaluate the determinants of certain small matrices exactly by using rational numbers with big integers for the numerator and denominator.
The boost multiprecision package provides a ...
1
vote
1
answer
33
views
Why is Eigen not making a copy when I return by value if copy elision is deactivated?
I currently have the very simple program. I deactivated copy elision in my compiler and as far as I understand it shouldn't even apply here because the compiler doesn't know what I will input. Now, ...
0
votes
1
answer
33
views
Eigen MatrixXi to VectorXi conversion
I have a MatrixXi, say
[0, 1, 2]
[0, 2, 3]
[4, 7, 6]
[4, 6, 5]
[0, 4, 5]
[0, 5, 1]
[1, 5, 6]
I get a part of it by doing:
MatrixXi MR = F.middleRows(first, last);
with first and last at will. ...
0
votes
3
answers
79
views
Using omp atomic operation in OpenMP for class members with Eigen Array
I doing simulations of N particles that interact between each other in a given range. To avoid a N^2 computation over the particle, I sort (spatially) the particles in an array in which I stored the ...
0
votes
0
answers
36
views
Compiler issues "__builtin_ia32_foo" not declared in scope when importing headers from PCL installed using vcpkg (likely related to Eigen)
Problem 1) Very new to C++ and compiling in general, being mostly experienced in Python
Problem 2) I have installed Point Cloud Library (PCL) as per PCL's recommendations using vcpkg - specifically ...
0
votes
0
answers
32
views
eigen custom type expression template type issue
I want to use Eigen with a custom type, which happens to be implementing the expression template pradigm itself:
Basically, I got my base class:
namespace NS
{
template<class Expr>
class ...
1
vote
1
answer
92
views
Why my matrix inverse implementation is less accurate? C++
I have a transformation matrix of type Eigen::Matrix4d. And I would like to get its inverse. I write a function my self to compute it by the following formular.
.
And here is my code:
Eigen::Matrix4d ...
0
votes
1
answer
30
views
Create an orientated Quad in Eigen C++ library
I'm a newbie that is driving nuts with a really simple problem :\ How to define a quad that has its center at position x=10 y=11 z=12 with side 5 and it is facing at camera.
My naive implementation:
...
0
votes
0
answers
54
views
How to choose specific row and column indices in C++ Eigen Array?
I wonder how it is possible to choose specific elements in Eigen Array given lists of indices for rows and columns. For example:
array = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
rowIndices =...
3
votes
1
answer
62
views
Eigen: vector of linear system solver
I'm working with the Eigen linear algebra library and need a vector of BiCGSTAB-solvers. Unfortunately, extending this vector is extremely difficult. The minimal (not) working example is
#include <...
0
votes
0
answers
17
views
how to overload std::ceil() in my program [duplicate]
I use my own data type in Eigen lib by template,and I realize +-*/ overload , but Eigen use std::ceil() function, I don't know how to overload this.
thanks for every suggestion.
just tell me How to ...
1
vote
0
answers
112
views
Eigen3 : How to verify if AVX2 or AVX512F code is being generated? [duplicate]
I am developing an program that involves a lot of low latency hard-real time matrix operations. I am using Eigen 3 library for the same.
I wish to use AVX-512F SIMD vectorization in production for ...
0
votes
1
answer
39
views
Using the Eigen library, can I get the kernel of a matrix which only has one "approximately"?
I need to find the kernel (a.k.a. null space) of a 3*3 matrix
which is of full rank 3, but very close to being singular and thus
of rank 2. This means it has no null space unless you look for it
with ...
0
votes
0
answers
41
views
define temporary c++ Eigen variables for convenience
I have some Eigen vectors which are concatenated from parts which I want to access. For this I use the block method. However, I need to access the same part over and over in different parts of the ...
0
votes
1
answer
25
views
Eigen::placeholders::all for Eigen array/matrix with pybind11
I am building a c++ program linked to python code, using pybind11.
I use Eigen for the matrix operations.
I am having issues with the slicing of an Eigen array.
According to Eigen documentation, it is ...
0
votes
1
answer
33
views
Converting a row from Eigen::Matrix to float array
I have a variable of type Eigen::Matrix<float, 2, 3> &state and I would like to take the first row and convert it to a float *array_state.
The matrix is
2.59586 2.49855 37
-1....
2
votes
1
answer
69
views
C++ Function Template is not deducing Eigen vector sizes
I have written a function
template <int N>
bool checkColinear(const std::array<Eigen::Vector<double, N>, 3>& points) noexcept;
which takes three N-D points and returns true if ...
0
votes
1
answer
35
views
How to efficiently store matmul results into another matrix in Eigen
I would like to store multiple matmul results as row vector into another matrix, but my current code seems to take a lot of memory space. Here is my pseudo code:
for (int i = 0; i < C_row; ++i) {
...
0
votes
1
answer
79
views
Inverting a sparse matrix using eigen
I'm trying to use a sparse solver as SimplicialLLT to inverse a symmetric positive-definite matrix and return it.
I get a matrix from R using Rcpp to connect R and cpp, I take this matrix as an ...
0
votes
1
answer
42
views
Why do Eigen values not show the correct type?
I currently have a project I am working on and for some reason every time I have this function being called the eigen value type shown in my debugger will be shown as a Matrix when it was declared as ...
0
votes
1
answer
41
views
C++: Copy the vector of pointers to arrays, to Eigen::ArrayXd
I have std::vector<double *> x, in which each elements points to C-style double array. The values of double arrays are changing with each iteration of my program. I would like to create a copy ...
0
votes
1
answer
58
views
How can I print a diagonal matrix in Eigen
I was reading this post and when I was replicating it using
#include <iostream>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Dense>
int main(){
Eigen::DiagonalMatrix<...
0
votes
1
answer
40
views
Using Eigen matrices with a custom type
I have a type of numbers named lazyScalar and I want, using Eigen, to deal with matrices of such numbers. Arithmetic operators are not defined for these numbers, so I defined them, e.g. the ...