Reputation: 157
I have a defined Eigen vector1
and an undefined Eigen vector2
, how do i fill vector2
with values of vector1
and subsequent data (doubles) like:
Eigen::RowVectorXd vector1 = Eigen::RowVectorXd::Ones(1);
Eigen::RowVectorXd vector2;
vector2 << vector1, 2.0, 3.4 // Gives AssertionError
Upvotes: 2
Views: 754
Reputation: 23788
The <<
operator can only be used to fill an Eigen::Vector if its size corresponds to that of the supplied data.
You could either declare the vector with the correct dimension
Eigen::RowVectorXd vector2(vector1.size() + 2);
or resize it
vector2.resize(vector1.size() + 2);
before using the <<
operator to fill in the values.
Upvotes: 2