typecasting Eigen::VectorXd to std::vector

前端 未结 3 1896
滥情空心
滥情空心 2020-12-13 13:37

Their are many links to go the other way round but I am unable to find to get a std::vector from a Eigen::Matrix or Eigen::VectorXd in my specific case.

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 14:30

    You cannot typecast, but you can easily copy the data:

    VectorXd v1;
    v1 = ...;
    vector v2;
    v2.resize(v1.size());
    VectorXd::Map(&v2[0], v1.size()) = v1;
    

提交回复
热议问题