Re: [eigen] Using Eigen::Map to use eigen operations on my data |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Using Eigen::Map to use eigen operations on my data
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 29 Oct 2009 18:21:02 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=0p/0udGfPT21oShX1NsPPEXjNgZLz3mdETKNaF2t8Uo=; b=H53NdKU7+MLABdgZEv5i6RfB1rrxySnljnum5UiAwyNKoESvh7Hh8OE/we9lEkljRT 7DQcuY/fLpC5gmqbqpCSmG0nyuAd617CifwJQG98GdpByBpKnjFIa4cgtX5o+lCn8hcO /CD0iVAKPD4drdZTVqYAcZB/nVeNd+2KLSUZQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Rp7hFFma+HmtrFIOMPCjnIBh0NItnXlUZGorM8kLvvLQRvhfqhKaZn1E/5+zQSGN7g tWntzjhSyPqoxKGoiKXB8IhKJveBwO7XKlhT1YQlnOSFwzAaF2815ErYkaPqGNFZe8Fx BhwBiJzI63j5N0Gqluc3CjjAuyTzafYEEIxsE=
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