Reputation: 157
Basically how do i do this
Eigen::RowVectorXd param(2);
param << 1.0, 2.0;
double last_element = param.tail(1); // error: no suitable conversion...
I know i can use .coeff()
however in my code some vectors are being resized, thus the size is unknown a priori
Upvotes: 0
Views: 717
Reputation: 1260
Would something like this work:
Eigen::RowVectorXd param(2);
param << 1.0, 2.0;
double last_element = param(param.size() - 1);
or even better, using the Eigen provided last
value:
double last_element = param(Eigen::last);
Upvotes: 3