Questions tagged [eigen3]

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

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. Homepage: http://eigen.tuxfamily.org

Please use eigen3 tag specifically for questions related to version 3 of the library.

1014 questions
3
votes
1 answer

Vectors do not satisfy std::ranges::contiguous_range in Eigen 3.4

Why does Eigen::VectorXd not satisfy the concept std::ranges::contiguous_range? That is, static_assert(std::ranges::contiguous_range); does not compile. Also, is there the possibility to specialize a template to make Eigen vectors…
fdev
  • 127
  • 12
3
votes
1 answer

Efficiency of Eigen::Ref compared to Eigen::VectorXd as function arguments

I have a long vector Eigen::VectorXd X;, and I would like to update it segment-by-segment using one of the following functions: void Foo1(Eigen::Ref x) { // Update x. } Eigen::VectorXd Foo2() { Eigen::VectorXd x; //…
fdev
  • 127
  • 12
3
votes
0 answers

Eigen3 Sparse solver assertion fail

I have a problem when solving a large sparse system in Eigen 3.3.7 using the SparseLU solver. I get a runtime assertion error of: void Eigen::PlainObjectBase::resize(Eigen::Index) [with Derived = Eigen::Matrix; Eigen::Index = long…
3
votes
1 answer

Read/write Eigen::Matrix with cv::Filestorage

According to the OpenCV Docs, we can use cv::FileStorage to read/write custom data structure from/to config files (XML, YAML, JSON): #include #include class MyData { }; static void read(const cv::FileNode& node,…
VictorBian
  • 675
  • 1
  • 4
  • 17
3
votes
0 answers

How to convert mutliple Matrix in Eigen to json with Jsoncpp?

I need to save my data in Eigen. I have some Matrix and other information that need to be save into json. But I cannot find any useful document. Do you have any advise? \\ here is my data, a simple example #include #include…
hey6775
  • 159
  • 3
  • 14
3
votes
1 answer

How to pass dynamic Eigen vector to GPU using Cuda?

I am going to learn how to transfer a dynamic Eigen vector to a GPU and get it back. For these purposes, I wrote a test code: using Vector = Eigen::Matrix; Vector vector; uint64_t size = 6; …
Ivanko
  • 125
  • 5
3
votes
2 answers

cmake find_package unable to find Eigen3Config.cmake spectra Windows

I am using Eigen3 with spectra (https://spectralib.org/), a library built on top of Eigen. Spectra uses find_package to find Eigen, and comes up with the error: Could not find a package configuration file provided by "Eigen3" with any of the…
JylesDigiorno
  • 45
  • 1
  • 4
3
votes
1 answer

How to improve GEMM performance on data-mapped (Eigen::Map) matrices sharing memory with an std::vector?

When multiplying two data-mapped matrices (Eigen::Map) I notice a significant performance difference depending on how the memory was allocated. When using memory coming from a custom allocation, it's almost twice as fast compared to using (also…
Tobias Hermann
  • 9,936
  • 6
  • 61
  • 134
3
votes
0 answers

Eigen lazy evaluation and temporaries: some case studies

Following the suggestions from this post Identifying temporary object creation in Eigen, I made some tests to understand when temporary Eigen objects are created. This is the code used to identify temporaries: static long int nb_temporaries; inline…
Emanuele
  • 91
  • 1
  • 2
  • 7
3
votes
1 answer

Undefined Behavior with Eigen Vector*Scalar + Vector*Scalar --> libigl/external/eigen and other eigen conflicts

I'm hunting down a weird runtime bug in my code that is consistent. I get what I think is undefined behavior on a line that looks like: Eigen::Vector3d m = d1 * cos(theta) + d2 * sin(theta) where d1 and d2 are are Vector3d and theta is a double. If…
3
votes
1 answer

Constructing Eigen::Array from Eigen::Map, how does it work?

In my project I have written the following code: Eigen::ArrayXf foo(const Eigen::ArrayXcf &src) { auto * output = new float[src.size()]; //Fill the data here return Eigen::Map(output, src.size()); } Note that the stuff…
LIU Qingyuan
  • 524
  • 5
  • 18
3
votes
2 answers

"+=" operation not working between types std::complex and __complex__ double

I'm using Eigen to perform some matrix manipulations in C++. In it, I have a line schematically of the form MatrixXcd A = MatrixXcd::Zeros(10,10); A(0,0) += 2.0*1i; Compiling this on my local computer gives no problems. However, compiling it on a…
Henry Shackleton
  • 351
  • 2
  • 11
3
votes
0 answers

Efficiently use Eigen for repeated sparse matrix assembly in nonlinear finite element code

I am trying to use Eigen to efficiently assemble a Stiffness matrix for non-linear finite element computations. From my finite element discretization I can exactly extract my sparsity pattern. Therefore I can just…
3
votes
1 answer

Virtual functions or SFINAE for template specialisation... or a better way?

I'm writing a CFD application using Eigen for a lot of the calculations. Now I want to define a field class to hold the values for each variable. My current approach is to use a template class which is either instantiated for scalars and vectors or…
RL-S
  • 734
  • 6
  • 21
3
votes
1 answer

correctly registering a plugin to use Eigen via Rcpp

I'm trying to be able to use a c++ class template in R. This was my first try at a small reproducible example. library(inline) library(Rcpp) inc <- "#include template class SillyWrapper { public: …
Taylor
  • 1,797
  • 4
  • 26
  • 51