Re: [eigen] converting matrices to/from byte arrays |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] converting matrices to/from byte arrays
- From: Ricard Marxer Piñón <email@xxxxxxxxxxxxxxxx>
- Date: Tue, 20 Apr 2010 13:01:55 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:received:message-id :subject:to:content-type:content-transfer-encoding; bh=LEYI+EA6SwLIMH+1YKzSJ/rx40880uuY0BnZkUPRxLM=; b=faKrxz+pbF6kIp++hQxzeK6GfJKTLW0GJjK52fMcPS8dbqGJwIBIBnHh3YdXxs8bvB UET0V7c6XMbMc3sz+ohHaMc0OcgbMJlsAvSo4YQhPB3U8glT4OzBgqYOeODMvppiulsv B3IyZhkLSajif24jWqiFLlZzMSCUi50tvkT3E=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=eRTBAbwSTaV4twcB76Di+Ftj69ibSYCU8lW3qencvvVQ9Bh5NpNlNrXZAP373OZTgT CY5/3i27VhXm+NxQNIxGD+63trKNxh/kJ3LRkGEmCwLJ5BPzHTS8eqhj9MMFsIpGLwJp JK3SAi6CLVlhW1CHufcgSp0esqSswPCoW6N1s=
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