I have seen it done before but I cannot remember how to efficiently initialize an Eigen::Vector
of known length with a std::vector
of the same length. Here is a good example:
std::vector<double> v1 = {1.0, 2.0, 3.0};
Eigen::Vector3d v2; // Do I put it like this in here: v2(v1) ?
v2 << v1[0], v1[1], v1[2]; // I know you can do it like this but
// I am sure i have seen a one liner.
I have perused this page about advanced matrix initialization but there is not a clear explanation of the method to perform this action.
Eigen::Vector3d v2(v1.data());
. – WhiteflyMap<ArrayXf> v2(v1.data(), 3)
– Scrubby