Re: [eigen] converting matrices to/from byte arrays

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


In order to get a pointer to the memory underlying a matrix just do.

myMatrix.data();

However this will give you a pointer of the type of the scalar.

float* f = myFloatMatrix.data();

Have a look here:

http://eigen.tuxfamily.org/dox/classEigen_1_1Matrix.html#a4663159a1450fa89214b1ab71f7ef5bf

Of course in your communication application you will need to send
through some more data such as the shape of your matrix and the type
of the data if you don't want to assume it.

Ricard



On Tue, Apr 20, 2010 at 12:39 PM, Sidney Cadot <sidney.cadot@xxxxxxxxx> wrote:
> Hi all,
>
> Newbie question:
>
> In order to use Eigen with a communication library I need to be able to do do reliable conversion of Eigen-matrices from and to byte arrays. The Map functionality will aid in the conversion from byte arrays (although I am a bit unsure about possible alignment issues and strides), but I am curious how I can reliably get a pointer to the memory underlying a matrix in order to push it into a communication buffer (given that the data can be strided).
>
> I /am/ willing to assume equivalent hardware at the sender and receiver (i.e., alignment constraints and endianness).
>
> I would appreciate it if someone could provide a pointer to a place where things of relevance to this are documented (if they are), or perhaps to an example that does something similar. The user documentation seems a bit terse on this particular issue.
>
> Best regards, Sidney
>
>
>
>



-- 
ricard
http://www.ricardmarxer.com
http://www.caligraft.com



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