Questions tagged [eigen]

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

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

Despite its name, this tag should not be mistaken with the and ones.

Eigen covers a large set of features through an easy to use unified API. Here is quick and incomplete overview:

  • Dense algebra:
    • array/matrix manipulation
    • linear solvers and factorizations (Cholesky, LU, QR, SVD, EVD)
  • Sparse algebra:
    • compressed sparse representation
    • direct solvers and factorizations (Cholesky, LU, QR)
    • Krylov subspace methods (CG, BiCGSTAB, GMRES) with preconditioners (Jacobi, ILLT, ILUT)
  • Geometry:
    • space transformation and subspace primitives

Find more on Eigen's home page and its online documentation.

3438 questions
1
vote
2 answers

Eigen: map non-continous data in an arra with stride

I have a data array (double *) in memory which looks like: [x0,y0,z0,junk,x1,y1,z1,junk,...] I would like to map it to an Eigen vector and virtually remove the junk values by doing something like: Eigen::Map< Eigen::Matrix
janou195
  • 1,175
  • 2
  • 10
  • 25
1
vote
1 answer

Efficient way to initialize Eigen Matrix or Vector with random numbers from a specific range?

I am trying to initialise an Eigen vector of integers with random numbers from a specific range. My approach so far has been to create a functor and calling it, it is however problematic in the sense that I need to initialise the random generation…
Jon Lachmann
  • 381
  • 1
  • 3
  • 10
1
vote
0 answers

How can I enable eigen multithreading while matrix multiplication?

Is there any way to improve the performance of Eigen matrix multiplication using OpenMP or any other approach to enable multithreading? Currently, switching on OpenMP gives nothing. inline void multiply1( Eigen::MatrixXd &m, …
1
vote
0 answers

Eigen trivially_copyable and CUDA

I have a struct which contains some Eigen::Vector3d values. I have a vector of that struct and I want to upload it to the GPU using thrust. When I did that, I got an error saying that the copy was undefined. I've been trying to understand why it…
jjcasmar
  • 1,387
  • 1
  • 18
  • 30
1
vote
1 answer

auto reference to Eigen block not behaving as expected

I want to use an auto reference to a block of an eigen matrix: #include using namespace Eigen; void foo(MatrixXf& a) { auto& a_block = a.block(2, 3, 4, 5); a_block = MatrixXf::Random(4,5); } This does not compile with GCC,…
yar
  • 1,855
  • 13
  • 26
1
vote
1 answer

Convert Eigen::ArrayXXd to Eigen::MatrixXd

How do you convert an ArrayXXd array to a MatrixXd? So far I've done MatrixXd temp_mat = my_array; and the implicit conversion seems to work fine, but is this the way it is supposed to be done? Or is there some explicit conversion operation I…
Juan Carlos Ramirez
  • 2,054
  • 1
  • 7
  • 22
1
vote
0 answers

Iterating over rows or columns of 2D array with Eigen

I need to iterate over the rows of an Eigen 2D array. The documentation indicates that this is be possible and provides a code snippet: ArrayXXi A = ArrayXXi::Random(4,4).abs(); for(auto row : A.rowwise()) std::sort(row.begin(),…
Oreille
  • 375
  • 3
  • 11
1
vote
2 answers

How to use cv::Mat and Eigen::Matrix correctly? (OpenCV + Eigen)

I am able to convert an OpenCV mat object to an Eigen object, and back. However when I try to display the Eigen->Mat on the screen I get a blank window, and I do not know why. I can save the image to a file so I know its converting correctly. Any…
user2840470
  • 919
  • 1
  • 11
  • 23
1
vote
1 answer

Tensor-contraction, how do i choose the indexes which should be contracted over?

I would like to perform simple Tensorcontractions with the Eigen::Tensor module, but so far, i dont understand the way you adress the right dimensions. Here is my current code: Eigen::Tensor B(3,4,3); B.setRandom(); Eigen::Tensor
Clebo Sevic
  • 581
  • 1
  • 7
  • 17
1
vote
1 answer

Eigen middleCols() penalty

if I use the member function of Eigen Matrix3Xf matrices myMatrix.middleCols(a, b) with a = 0, b = myMatrix.cols()-1, I get a performance penalty. Of course I usually use other values for a and b, but with these values, it's easiest to compare to…
yar
  • 1,855
  • 13
  • 26
1
vote
1 answer

Eigen: Obtain the kernel of a sparse matrix

Given a sparse matrix A and a vector b, I would like to obtain a solution x to the equation A * x = b as well as the kernel of A. One possibility is to convert A to a dense representation. #include #include #include…
Dominik Mokriš
  • 1,118
  • 1
  • 8
  • 29
1
vote
2 answers

Eigen::Map'd matrix from raw buffer gives OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG

Recently I have been working with Eigen matrices derived from raw buffers and I noticed this curious case: #include int main(int argc, char const *argv[]) { /* code */ const int M = 320; const int N = 640; const…
XapaJIaMnu
  • 1,408
  • 3
  • 12
  • 28
1
vote
0 answers

Eigen.natvis addition for Eigen::Map

I am trying to add to the Eigen.natvis, found here, so that Eigen::Map objects can also be read in the Visual Studio debugger, Eigen library found here. Here is what I put together:
AOK
  • 493
  • 5
  • 16
1
vote
2 answers

Eigen Matrix + Boost::Serialization / C++17

I'm trying to enable C++17 for our code base which is strongly based on boost - and boost::serialization for intermediate data storage and pre-transmission serialization. Overall, everything looks fine and seems to be working, except when we're…
nightsparc
  • 130
  • 1
  • 9
1
vote
1 answer

Solving linear systems in Eigen3 with GMP types

[I know there are two questions related to Eigen3 and GMP, but they are not addressing my problem.] I'm trying to do arbitrary-precision linear algebra in Eigen3. Therefore, I'd like to use GMP's mpq_class as scalar type in Eigen's matrix class.…
1 2 3
99
100