Re: [eigen] What's the best way to copy an Eigen::Vector into a std::vector?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


IIRC, start(int) and end(int) (don't even know whether the signature is correct) are used to retrieve subvectors. Try the following code. It should be working.

#include <algorithm>
#include <vector>
#include "Eigen/Core"

int main() {
   Eigen::VectorXd evec(10);
   std::vector<double> stdvec(10);
   std::copy(&evec(0), &evec(0)+evec.size(), stdvec.begin());
}

- Hauke

On Wed, Nov 4, 2009 at 7:00 PM, Robert Lupton the Good <rhl@xxxxxxxxxxxxxxxxxxx> wrote:
Dear Mr. Eigen,

What's the best way to copy an Eigen::Vector into a std::vector?

I'd use
       std::copy(evec.begin(), evec.end(), stdvec.begin());
if Eigen supported begin and and, but it doesn't seem to.  I don't know what Eigen's start() and end() are supposed to do, but the following doesn't compile:

#include <algorithm>
#include <vector>
#include "Eigen/Core"

int main() {
   Eigen::VectorXd evec(10);
   std::vector<double> stdvec(10);
   std::copy(evec.start(), evec.end(), stdvec.begin());
}

although the doxygen docs refer to start(void).

I see the headers Eigen/StdVec and Eigen/NewStdVec, but they don't seem to do what I want.                            


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/