0

I have a pointer to some floating point data that I'd like to copy in to an Eigen::ArrayXf. Is there a simple way of doing this other than looping through the memory and assigning values to the Eigen::ArrayXf?

Something along the lines of:

float* someData = new float[64];
...
Eigen::ArrayXf newArary( 64 );
newArray.data() = someData;
Olly
  • 11
  • 1
  • See this doc [page](http://eigen.tuxfamily.org/dox/group__TutorialMapClass.html) on `Eigen::Map`, and this similar [question](http://stackoverflow.com/questions/17036818/initialise-eigenvector-with-stdvector/17037695#17037695). – ggael Sep 22 '16 at 20:59

2 Answers2

0

This should do the job:

Eigen::ArrayXf newArary(Eigen::ArrayXf::Map(someData, 64));

You can also just use the mapped data directly. Check the map tutorial for more details and alternative syntax: http://eigen.tuxfamily.org/dox/group__TutorialMapClass.html

chtz
  • 17,329
  • 4
  • 26
  • 56
0

If you are looking to copy from and std::vector, then see the assignment operator in the Eigen Do Better library.