Re: [eigen] Using Eigen::Map to use eigen operations on my data

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


I guess I boiled this down too far (boiled it dry?).

I'm writing some swig bindings to pass numpy arrays to code that uses Eigen. I can unpack the data from the numpy arrays, so I have a (float *data, int nx, int ny) tuple. I'd like to pass that to my routines that expect Eigen::MatrixXf.

After Benoit's explanation, it looks as if I need to redo my interface to expect Map<MatrixXf> or (to preserve the option of passing MatrixXf) template them over the argument type --- for type safety, Benoit proposes using MatrixBase<T>.

Fine, I can do that --- although the details of the swig typedefs will be nasty as templates must be explicitly expanded. I can work on that.

I still think that the manual entry is confusing --- it maps an array and then assigns it to a Matrix2f but all the mapping is doing is initialising the memory. Note that the docs also talk about:

* This class represents a matrix or vector expression mapping an existing array of data. * It can be used to let Eigen interface without any overhead with non-Eigen data structures,
  * such as plain C arrays or structures from other libraries.

Which is true, but apparently not quite as simple as it might seem.

I'm not complaining, just explaining where the confusion comes from in the hope of avoiding more.


					R




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