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
4
votes
0 answers

Eigen3 colwise cross product with another matrix

I'm trying to to write the following piece of code as one eigen expression: Eigen::Matrix a, b, c(3,2); a << 1,2,3,4,5,6; b << 7,8,9,10,11,12; for(int i=0; i<2; ++i) c.col(i) = a.col(i).cross(b.col(i)); i.e. I would like to write…
craffael
  • 373
  • 1
  • 10
4
votes
2 answers

Extracting blocks/ROIs from Eigen::SparseMatrix without copying

I wonder is there any good way to extract blocks/ROIs from Eigen::SparseMatrix? More precisely, what I want to extract is inner vectors. What I want to do is like: typedef Eigen::SparseMatrix SpMat; // Prepare some sparse…
4
votes
2 answers

eigen vectorization with arrays

I am processing point cloud data (150k points per cloud). I would like, for each (x,y) point, to compute the distance to a reference point O, and azimuth: for each point p in points dx = p.x - ox dy = p.y - oy d = hypot(dx, dy) az =…
brice rebsamen
  • 664
  • 6
  • 11
4
votes
3 answers

How do I write a function that has optional Eigen::Ref output args?

I'm writing a function that has 1 input and 3 outputs like the following: void ComputeABC(const Eigen::Vector2d& x, Eigen::Matrix2d& a, Eigen::Matrix2d& b, Eigen::Matrix2d& c) However, I need my…
vpradeep
  • 746
  • 1
  • 6
  • 14
4
votes
2 answers

Eigen Spline interpolation - How to get spline y value at arbitray point x?

I am try to use the Eigen library to create splines. However once I create a spline, I don't know how to get what the value would be at a given point x. See example below with explanations of my intentions: #include #include…
windenergy
  • 361
  • 1
  • 4
  • 13
4
votes
2 answers

Eigen 3 - Slicing a MatrixXd to reverse the columns order

I need to reverse the order of the columns of a MatrixXd using RcppEigen. In R I would simply do > M = matrix(1:9, ncol = 3) > M [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > M = M[, 3:1] > M [,1] [,2]…
Marco Stamazza
  • 836
  • 9
  • 15
4
votes
2 answers

eigen auto type deduction in general product

I have the following piece of code (I apologize for the slightly larger code snippet, this is the minimal example I was able to reduce my problem to): #include #include #include #include // Dynamic…
vsoftco
  • 55,410
  • 12
  • 139
  • 252
4
votes
2 answers

Eigen3 replicate() for a matrix-vector cwiseProduct operation

I have the following code: Eigen::MatrixXf aMatrix( 3, 5 ); aMatrix << 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1; Eigen::VectorXf aVector( 5 ); aVector << 3, 4, 5, 6, 7; cout << aMatrix.cwiseProduct( aVector.replicate( 1, aMatrix.rows()…
pt3dNyc
  • 369
  • 1
  • 16
4
votes
1 answer

Construct Eigen::Transform from Eigen::Translation

I have following code: void mySetTransform(const Eigen::Affine3d& T); ... mySetTransform(Eigen::Translation3d(1.0,2.0,3.0)); This doesn't compile, it can't convert the Eigen::Translation3d to Eigen::Affine3d. Following line causes the same…
jcm
  • 947
  • 7
  • 16
4
votes
1 answer

Get matrix views/blocks from a Eigen::VectorXd without copying (shared memory)

Does anyone know a good way how i can extract blocks from an Eigen::VectorXf that can be interpreted as a specific Eigen::MatrixXf without copying data? (the vector should contains several flatten matrices) e.g. something like that…
Ruun
  • 521
  • 1
  • 7
  • 12
4
votes
3 answers

How to use Eigen FFT with MatrixXf?

I am new to the Eigen library. I would like to compute FFT of Eigen Matrices. However, my attempts to do so indicate that the unsupported Eigen FFT module can't be used with MatrixXf. I want to pull off something like: #include…
John Doe
  • 423
  • 3
  • 10
3
votes
0 answers

Eigen efficiency of Matrix-Matrix multiplication vs several Matrix-Vector multiplication

Assuming the following relations a = M u b = M v c = M w Where a, b and c are three [6x1] vectors, M is a [6x15] matrix and u, v and w are three [15x1] . These operations are done for a set of several different M matrices. I thus have a stack of M…
3
votes
1 answer

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 int main() { std::vector<…
camelCase
  • 187
  • 1
  • 12
3
votes
1 answer

Eigen tensor reshape then broadcast results in gibberish numbers when going from rank 0 to rank 1 tensor

I have the following code that seeks to find the maximum element of a rank 1 tensor, which shrinks to a rank 0 tensor, and then broadcast it back out to the full length of the rank 1 tensor so I can use it in further computations involving the…
3
votes
1 answer

`std::move` an Eigen object in a constructor?

The Eigen3 documentation warns against passing Eigen objects by value, but they only refer to objects being used as function arguments. Suppose I'm using Eigen 3.4.0 and C++20. If I have a struct with an Eigen member, does this mean I can't…
NickFP
  • 177
  • 7