3,543
questions
-5
votes
0
answers
22
views
Allocated memory leak when using Eigen [closed]
I have been struggling with a memory leak issue while using the Eigen library. I have the following function:
Eigen::Matrix<complex<double>, Dynamic, Dynamic> func(){
Eigen::Matrix<...
0
votes
0
answers
84
views
Improving the performance of dynamically allocated matrices
I am writing a program to do some linear algebra calculations on 300 x 300 complex matrices using the eigen library. I have a family of matrices, which can be thought of as a function of some ...
0
votes
0
answers
24
views
Eigen linear algebra compile errors
I have adapted the Ax=b example in the eigen documentation to use a complex double matrix. The actual problem requires a 16x16 matrix with a 1x16 vector and I expect a 1x16 vector output (I've tried ...
0
votes
2
answers
65
views
Constructing a matrix whose elements are the differences between elements of a vector using the Eigen library in c++
Consider a vector initialized as:
Eigen::Vector<double> A ={a1, a2}
I would like to efficiently construct a matrix like:
A =
{{a11, a12},
{a21, a22}}
where aij = ai - aj
In other ...
0
votes
1
answer
21
views
Update Slices of Dynamic Eigen Matrix
I have an Eigen dynamically sized matrix that I'd like to update columnwise using another dynamic matrix (of the same shape), but I get a compile-time error. Is there a correct way to do this?
This is ...
11
votes
1
answer
516
views
Why is 4x4 Matrix Multiplication in Eigen More Than Twice as Fast as 3x3?
I compared the performance of 3x3 and 4x4 matrix multiplication using Eigen with the -O3 optimization flag, and surprisingly, I found that the 4x4 case is more than twice as fast as the 3x3 case! This ...
0
votes
1
answer
73
views
How to subtract mean vector from matrix
I'm having trouble figuring out: How to do a broadcast vector subtraction from a matrix using the C++ lib Eigen?
When I try something like this:
Vector3d mean;
mean << 2, 3, -1;
MatrixXd ...
0
votes
0
answers
51
views
SEGV using Eigen on Apple Silicon
I am using the Eigen library in a project of mine. On various architectures and OS this works perfectly (Windows x86, Ubuntu x86, Ubuntu ARM). However, on Apple Silicon using the Clang compiler, I get ...
0
votes
1
answer
20
views
How can i find eigen's system path in conda's setup?
I need to provide it as the "cmake prefix path". The build fails if i don't provide the correct path. I can't edit the cmake file directly in this case due to restrictions. I need to do it ...
0
votes
2
answers
43
views
Elementwise operation between Eigen Matrix and Vector
The following code conduct subtraction between a Matrix and a Vector. The vector is automatically broadcast to shape (30, 7) at runtime. But if num and sub_value are declared as dynamic-shaped Matrix/...
0
votes
1
answer
62
views
C++, Eigen library, #include does not see the file/directory [duplicate]
My #include <Eigen/Dense> gives the error: No such file or directory.
I followed tutorials on how to include it, my outcome appears to be different.
My tasks.json is:
{
"tasks": [
...
0
votes
0
answers
62
views
Error using Eigen: "mismatched types" with scalar vector multiplication [duplicate]
I am trying to perform the following operation from MATLAB using Eigen matrices in C++.
Given an example in MATLAB:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/...
0
votes
0
answers
11
views
Building a constrained linear sparse system
Eigen provides convenient operators similar to matlab for dense matrices. However, sparse matrices have less capabilities. For example, how would you convert the following matlab code to eigen:
...
0
votes
2
answers
35
views
Strange results while trying to make matris symmetric in Eigen
In my project i work with covariance matrices and during many repetitive operation i have noticed that they gradually loose their symmetry. I put it down to numerical problems and when loss of ...
-1
votes
1
answer
62
views
Eigen stack-use-after-scope storing an expression of a returned Ref
Consider this Eigen example:
#include <Eigen/Core>
using namespace Eigen;
struct Z {
MatrixXd q;
Ref<VectorXd> foo() { return q.col(0); }
auto faa() { return q.col(0); }
};
...
1
vote
0
answers
85
views
C++ Eigen svd.singularValues() returns only the nonzero ones. How do I get the zero ones as well?
I'm trying to compute the nullspace of a matrix (in this case, a matrix with one row, i.e. a vector).
To do so I compute its SVD using the Eigen::JacobiSvd class (Edit: passing ComputeFullV as a ...
0
votes
0
answers
91
views
Issues with Eigen Library Setup in VS Code for C++ Projects
I am encountering difficulties in including the Eigen library in my C++ project using Visual Studio Code and MinGW. Despite following multiple tutorials, I am still receiving the error: Eigen/Dense: ...
0
votes
0
answers
59
views
Matrix dimension assignment error encountered when solving matrix equation
I am trying to solve the equation T_SpSq=THS^-1·TPQ·THS.
I wrote a class to keep adding TPQ as a solution parameter.
But the compiler reports an error: C2338: YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES.
I ...
0
votes
0
answers
43
views
How can I use multithreaded BLAS from a single threaded EIgen C++ application?
I'm trying to speed up Eigen dense matrix * matrix operation by using multihreaded BLAS library calls.
I've achieved 100% speed increase using AMD AOCL-BLAS library from within Eigen. But I seem ...
0
votes
1
answer
69
views
How to sort the Eigen::Matrix that have std::pair<int, int> and delete the duplicates of indices
I need a way to sort and delete the duplicates of row and column indices of a sparse matrix.
But at first I need to sort indices and later find a method to delete the duplicates.
Eigen::Matrix<std::...
0
votes
0
answers
78
views
BiCGSTAB does not speed up with OpenMP
I want to use OpenMP with Eigen BiCGSTAB solver.
The documentation of Eigen says it is supported, but I cannot figure out why it's not reducing the time of solving linear equations.
This is the ...
0
votes
1
answer
61
views
What would be the stride and offset of this user defined point in PCL?
I want to use the PCL function, getMatrixXfMap, but I don't know what the stride of my point type is.
struct My_Point
{
PCL_ADD_POINT4D;
uint8_t direction;
uint8_t type;
uint8_t ...
0
votes
0
answers
46
views
Is writing to a sparse matrix thread-safe in eigen?
Using Eigen::SparseMatrix<double> Aij datatype, is assignment/update by Aij.coeffRef( row, column ) += val; thread-safe?
I'm constructing a very large, very sparse matrix, and doing it serially ...
0
votes
0
answers
68
views
Returning an Eigen SparseMatrix from another function
I am writing a function to return a subset of the columns of a sparse matrix. The returned matrix is also sparse. For my first attempt, I first initialized a sparse matrix
Eigen::SparseMatrix<...
1
vote
1
answer
47
views
Calculate damping matrice
I need help understanding the dfdv matrix and how to calculate it. I need to compute the dfdv matrix for the springs. I'm trying to follow these notes here but I still don't understand, why it's ...
0
votes
1
answer
62
views
Eigen: subtract two vectors of unequal length, implicitly padding the shorter vector with zeros
I'm using Eigen 3.4. I'd like to subtract two vectors of unequal length, padding the shorter one with zeros along the bottom, while avoiding reallocation of memory. Rough example:
VectorXd A (4), B (2)...
1
vote
1
answer
80
views
Using a list of linear indices to map between an input and output matrix in Eigen
Say I have 3 2D matrices:
shiftedData - Complex double of size [tSize*TXSize,xSize]
Data - Complex double of size [tSize*TXSize,xSize]
indices - integer of size [tSize,xSize]
I want to map every sub-...
1
vote
1
answer
46
views
Copying a MatrixXf causes Eigen math to fail. Release and Debug versions provide different results
I encountered an error when creating a copy of a matrixxf which I used to get the rowwise average. It seems to generate exceedingly large values in debug, and a value of zero in release. In both cases,...
-1
votes
1
answer
29
views
Error when trying to extract scalar out of chained Eigen::Tensor operation ending with .sum()
I have the following script
#include <iostream>
#include <unsupported/Eigen/CXX11/Tensor>
int main() {
using namespace Eigen;
// fill the tensor with arbitrary data
Tensor<...
1
vote
1
answer
49
views
Trying to compile eigen example on IAR
I have been tasked with pulling in Eigen into an embedded project built using IAR that will run on an STM32 MCU.
Due to the various compiler checks in the cmake files in Eigen version 3.4 - which ...
2
votes
1
answer
76
views
g++ "ignoring nonexistant directory" that does in fact exist (only with CLion + Ninja)
I have some C++ source which includes the line:
#include <Eigen/Core>
The compilation fails at this line, with the error: (my source file names/paths redacted for brevity.)
In file included ...
0
votes
1
answer
154
views
CMake fails to build eigen on Windows github actions
Well, I'm working on a C++ project where I am using linear algebra from Eigen.
This is how I fetch the Eigen library from my root CmakeLists.txt:
message([STATUS] "Fetching eigen.")
block(...
-2
votes
1
answer
124
views
Transform elements in an Eigen Vector to some constant to the power of the corresponding element
I am new to the Eigen library. I want to transform each element in a vector (or matrix) to some constant to the power of the corresponding element from the vector.
I want to do this operation ...
0
votes
0
answers
46
views
How to use template of Eigen::Vector?
Is there a base type of vector as MatrixBase in eigen?
template <typename Derived>
void test(Eigen::MatrixBase<Derived>& R, const double deg, const Vector3d& u) {
R = Eigen::...
0
votes
1
answer
48
views
How to get parameter value from a templated class
Out of convenience I defined 1d, 2d, 3d and 4d vectors using Eigen::Matrix.
namespace MyNamespace {
template <class scalar_t, int dim>
using Vec = Eigen::Matrix<scalar_t, dim, 1, ...
0
votes
1
answer
144
views
Performance Discrepancy between GPU and CPU for Matrix Multiplication: Eigen vs. ViennaCL
I'm facing a performance issue when performing matrix multiplication operations using the Eigen and ViennaCL libraries in C++. I'm comparing the performance between executing these operations on the ...
0
votes
0
answers
61
views
Reorder points in vector according to their proximity to the points in another vector
I have two vectors of points in 2D/3D space:
std::vector<Eigen::Vector3d> points_to_sort;
std::vector<Eigen::Vector3d> reference_points;
assert(points_to_sort.size() == reference_points....
0
votes
1
answer
40
views
Eigen C++ divide operation on columns
I have a matrix df, and I am trying to fill my last columns by the ratio of 2 other columns like this:
df.col(0) = df.col(1).rowwise() / (df.col(1) + df.col(2));
Bu I get an error:
error: no type ...
1
vote
1
answer
28
views
Eigen::Vector2f not initialized correctly when compiled with -O2
I faced an issue that a Eigen::Vector2f is not correctly initialized if it is initialized in line with other operations and is compiled e.g. with -O2 flag.
main.cpp
#include <Eigen/Core>
#...
1
vote
1
answer
54
views
Eigen::Ref calls copy constructor on matrix multiplication
I have the following code:
#include <Eigen/Eigen>
#include <iostream>
int main(int argc, char **argv) {
std::cout << EIGEN_WORLD_VERSION << "." << ...
1
vote
0
answers
40
views
What are the dimensions of the tensor which Eigen's extract_image_patches returns?
I am using Eigen's extract_image_patches but I am unclear about the tensor which it returns. The documentation is not particularly helpful (at least to me):
returns a tensor of coefficient image ...
-2
votes
1
answer
141
views
cuda::std::complex in Eigen::Matrix causing error
The code below causes the following error when compiled with nvcc eigen_complex.cu -I [path to eigen] where nvcc is at version 12.4 and Eigen is at the latest version. Is there a way for me to define ...
0
votes
0
answers
77
views
Using Eigen to perform a convolution with stride
I am trying to get Eigen to perform a convolution operation with a stride (for a convolutional neural network). I know that Eigen has a convolve function which you can perform on a tensor:
input....
-2
votes
1
answer
46
views
comparing two meshes c++ "libigl"
I would like to compare the similarity of Nodes and Faces from the first mesh with the second mesh by using libel and Eigen
how could I do it?
I do not have any Idea how to start
please if you know of ...
0
votes
0
answers
42
views
Why is this custom Eigen expression allocating?
I need to sum two vectors together, where the first vector stays the same, and the second vector is added at a changing offset and possibly length. I then need to find the maximum of the result. It ...
0
votes
1
answer
79
views
When is it recommented NOT to use Eigen::Ref for parameters?
I'm currently writing a lot of functions that accept blocks and expressions as input. I generally find it much easier to work with Refs, as they are simple, lightweight, and it's also easy to ensure ...
0
votes
1
answer
64
views
Eigen: evaluate operations from constant matrix to a new matrix/array
Let's say I have a function templated according to Eigen's documentation, in order to use it both from C++ and Python using pybind11.
The main goal of that function if to perform a cartesian -> ...
1
vote
0
answers
62
views
Dynamic linking of SIMD wrapper library for different architectures?
This stackoverflow hints that the Eigen vector library will need to know the targeted ISA at compile time to compile the SIMD intrinsics. As we are running our application on different servers using ...
1
vote
1
answer
83
views
How to accelerate the intersection test between triangles and AABB
I am learning the algorithm for voxelization of triangular meshes, which involves testing the intersection between triangles and AABB. I found the Separating Axis Theorem or SAT algorithm online, ...
1
vote
1
answer
239
views
Interpolate eigen splines with derivatives
I'm trying to interpolate a cubic spline with start&end derivative prescribed.
For that I created a wrapper for Eigen splines:
/**
* Cubic Spline.
* @tparam vec_t point type. Example: Eigen::...