|Re: [eigen] Quaternion and expression template|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Quaternion and expression template
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 29 Oct 2009 11:30:04 -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=sqVTVVS2VY4cakzw/UHOJa9vaG+CrQit6GPwuFy6BnE=; b=OAL0KP3kjiTyvvWlh6Z4zATgAO0RMYrGTOnvK4mw/lqvmd3a0yeyk9hFwQMe0oJaAU 08h1XYc+j/W8NgrGUMn0/lL6XyWG2hD5ChSesPl9vI+UmTcKr0abBBa8Mm7lrS2YzOLG wmGTKiJc4MzYYWVWemoaUExkxEssl5hh/WCAQ=
- 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=a4hNk1Fz/DbaDNN2apWgoOu1MD0GwFp35qXVzP7JyQpdRNb2LKTtA7dIG7CpTKrzyD y5MSAfic6TdR5q02tbRBGk0k4FujLJ1HMQXpl361TBFuHqcmDnjZW1UjTSMf5SH6Xw8u ybk1fH51OQkV3eAIY+/olBnoXaPbV607qUv+4=
2009/10/29 Gael Guennebaud
> note that both the conjugate of a quaternion, and the quaternion-quaternion
> product cannot be easily/efficiently implemented with expression template
> because they would require some "if"...
Time for some bikeshedding:
Actually this "if" doesn't matter because the loop will always be
unrolled (we'd put meta unrollers there too) so the if would evaluate
at compile time. It's like if "if" in the Minor expression that i use
to compute 3x3 determinants.
> So to conclude, don't worry, I'm pretty sure that "q = q1.conjugate() * q2"
> is already as fast as a specialized "quat_mult_conj(q, q1, q2)".
> Also, only FYI, expression template could be easily implemented for
> quaternion using the QuaternionWrapper class that I described in the other
> thread. For instance, QuaternionBase::operator+ would return an expression
> of the addition of two vector expression wrapped into a QuaternionWrapper:
> QuaternionBase<Derived>::operator+(const QuaternionBase<OtherDerived>&
> other) const
> return QuaternionWrapper<...>(coeffs() + other.coeff());
> but again, both conjugate() and the quaternion-quaternion product cannot be
> efficiently implemented using the ET mechanism.
> On Thu, Oct 29, 2009 at 11:37 AM, Mathieu Gautier <mathieu.gautier@xxxxxx>
>> I'm currently setting a prototype of our own math library with eigen2 and
>> more precisely using the Geometry part of Eigen2. In my library, I have many
>> rotation composition using quaternion, like :
>> q = q1.conjugate() * q2 which are implemented through function :
>> quat_mult_conj(q, q1, q2).
>> So we avoid any temporary elements due to inversion, multiplication and
>> assignation. But I' rather use the first notation if possible, it could also
>> remove many of our operations (mult_conj, conj_mult, etc..)
>> Actually in Eigen2, expression templates are used with MatrixBase through
>> the CWise* or productBase classes. Since Quaternion doesn't inherited from
>> MatrixBase, it doesn't seem possible to reuse the CWise* mecanism. Do I have
>> to provide a new mecanism based to the CWise* or productBase ones to use
>> expression template with the Quaternion classes?
>> If so, these classes will inherit from the new QuaternionBase, are there
>> specifics traps to avoid or part of existing code that could be reused ?
>> Mathieu Gautier