Re: [eigen] Quaternion initialization from Block/segment (Eigen 3 beta 1) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Quaternion initialization from Block/segment (Eigen 3 beta 1)
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 22 Jul 2010 20:46:54 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=gqpJ7vPk44u521wZhUrnftLUWj57EdeI2oNDZitMjvs=; b=d5lcv89XDPkTynrwOTQH5YJsCzpvsZm9vWr++BqMYa7vUtFprGi4xrn/Q3GgCf9KTJ pZfemCGhbLkckb0IpJEPzCHk7KPcuGXZUfPAqtSfOvQ/QxiQE7/QX+RlXsz/onw3OW1E CU4fssMZxIOgmubGb5OI5P9ifCPnEklHBt21o=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=KBqIr33AhEMJJcBA66Ej1hXDYZIVySmwHOo1KLwwkyEjcDWVIp6W3dbYhVqNYK+Rq+ 0SuisJP/iQHCBD+3XPRvfjRYR7HdWk3XT6OdYFbHR0Qq9IC8dHON+ew999Lwds2LHUn1 ViCwPPSbGZmUjjFZrFX4Brv+NlidOwhSKHl4c=
On Thu, Jul 22, 2010 at 6:33 PM, Jens Andersen <jens.andersen@xxxxxxxxx> wrote:
> Eigen::VectorXd myvector;
> Eigen::Quaternion q(myvector.segment(3,4));
>
> I'm not sure whether this method avoids the copy?
To make it compile you have to set the vector length at compile time:
Eigen::Quaternion q(myvector.segment<4>(3));
And indeed this copy the data to a new array. In Eigen3 you can map
external memory as a Quaternion without any copy using Map:
Map<Quaterniond> q(myvector.segment(3,4).data());
or
Map<Quaterniond> q(&myvector(3));
gael