Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to concatenate Vectors in Eigen?

Tags:

c++

eigen

I have two vectorXd in my program and I like to concatenate them into one vector, so that the second one's values goes after the first one, I found this for matrix but it doesn't seem to work on Vectors:

Eigen how to concatenate matrix along a specific dimension?

like image 731
user3178756 Avatar asked Sep 05 '14 17:09

user3178756


1 Answers

Like so, assuming you have vec1 and vec2 already:

VectorXd vec_joined(vec1.size() + vec2.size());
vec_joined << vec1, vec2;

(Note that the vector types are simply typedefs of matrix types constrained to have only one column.)

Further reading: Advanced initialization

like image 142
cdhowie Avatar answered Oct 08 '22 15:10

cdhowie