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

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


2009/10/29 Robert Lupton the Good <rhl@xxxxxxxxxxxxxxxxxxx>:
> 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>.

Exactly!

>
> 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.

If you need only MatrixXf and Map<MatrixXf>, you could code these as 2
separate functions and do without templates. (They could internally
call a common template function that would be an implementation
detail).

> 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.

Indeed. I'll try to remember to clarify that.

Benoit



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