0

I am looking for a direct, fast method to convert a list<VectorXd> to MatrixXd. How can I do that?

Map<Eigen::MatrixXd> listV(list<VectorXd>)

Doesn't compile.

I am also thinking about iterating over the list<VectorXd> and fill in the MatrixXd necessarily, but that could be slow and unnecessary.

Although I agree that this answer is helpful to me in resolving my question, but I don't agree that the parent question is a duplicate for this one. The way to access list and vector can be different, so the question should remain open because the answer is different.

Community
  • 1
  • 1
Graviton
  • 81,782
  • 146
  • 424
  • 602

1 Answers1

1

No that's not possible because the elements of the std::list are not sequentially stored in memory. So you'll have to process it one column at once, using Map on the std::vector. So only one loop over the elements of the std::list.

ggael
  • 28,425
  • 2
  • 65
  • 71