Re: [eigen] Issues regarding Quaternion-alignment and const Maps

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


Gael Guennebaud wrote:
On Wed, Jul 7, 2010 at 9:56 AM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi,

first of all great work, everyone!

I have two issues with Eigen2, which I'm not sure Eigen3 has solved/will
solve (I did look at the new source, but might have overlooked something).

First, I guess there is no (easy) possibility to have an not-aligned
quaternion (without disabling alignment globally).
For ordanary matrices there is a Eigen::DontAlign option, which I haven't
found for Quaternions. And currently I don't see a very lot of gain in
vectorization of Quaternions, especially (quaternion * vector3) is not
vectorized, and (quaternion * quaternion) only for float (at least in
Eigen2).

With Eigen3 you can map unaligned data as a Quaternion, but that's
less convenient. So you would like a DontAlign option, e.g.:

Quaternion<double,DontAlign>

Then we should also add such an option to Translation and Transform.

Why not.

I implemented it for Quaternions. Once I dug through all the code it wasn't even that hard ...

I'm not entirely sure if

  typedef Quaternion<_Scalar, PacketAccess> PlainObject;

in struct ei_traits<Quaternion<_Scalar, _PacketAccess> >

actually needs to have the same PacketAccess (as far as I looked, it was not used anywhere ...)


Patch is attached.

Christoph



--
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252
----------------------------------------------
# HG changeset patch
# User Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
# Date 1279831261 -7200
# Node ID 15df9e7ace95c9d4afe9d50c1579986f39b35c30
# Parent  ccb721fed1d6a440160e8f8f93f4770d9f07a134
Support for unaligned Quaternions

diff -r ccb721fed1d6 -r 15df9e7ace95 Eigen/src/Core/util/ForwardDeclarations.h
--- a/Eigen/src/Core/util/ForwardDeclarations.h	Thu Jul 22 17:23:11 2010 +0200
+++ b/Eigen/src/Core/util/ForwardDeclarations.h	Thu Jul 22 22:41:01 2010 +0200
@@ -177,7 +177,7 @@
 template<typename Derived, int _Dim> class RotationBase;
 template<typename Lhs, typename Rhs> class Cross;
 template<typename Derived> class QuaternionBase;
-template<typename Scalar> class Quaternion;
+template<typename Scalar, int _PacketAccess = AutoAlign> class Quaternion;
 template<typename Scalar> class Rotation2D;
 template<typename Scalar> class AngleAxis;
 template<typename Scalar,int Dim,int Mode=Affine> class Transform;
diff -r ccb721fed1d6 -r 15df9e7ace95 Eigen/src/Geometry/Quaternion.h
--- a/Eigen/src/Geometry/Quaternion.h	Thu Jul 22 17:23:11 2010 +0200
+++ b/Eigen/src/Geometry/Quaternion.h	Thu Jul 22 22:41:01 2010 +0200
@@ -208,27 +208,27 @@
   * \sa  class AngleAxis, class Transform
   */
 
-template<typename _Scalar>
-struct ei_traits<Quaternion<_Scalar> >
+template<typename _Scalar, int _PacketAccess>
+struct ei_traits<Quaternion<_Scalar, _PacketAccess> >
 {
-  typedef Quaternion<_Scalar> PlainObject;
+  enum{
+    PacketAccess = _PacketAccess
+  };
+  typedef Quaternion<_Scalar, PacketAccess> PlainObject;
   typedef _Scalar Scalar;
-  typedef Matrix<_Scalar,4,1> Coefficients;
-  enum{
-    PacketAccess = Aligned
-  };
+  typedef Matrix<_Scalar,4,1, PacketAccess> Coefficients;
 };
 
-template<typename _Scalar>
-class Quaternion : public QuaternionBase<Quaternion<_Scalar> >{
-  typedef QuaternionBase<Quaternion<_Scalar> > Base;
+template<typename _Scalar, int _PacketAccess>
+class Quaternion : public QuaternionBase<Quaternion<_Scalar, _PacketAccess> >{
+  typedef QuaternionBase<Quaternion<_Scalar, _PacketAccess> > Base;
 public:
   typedef _Scalar Scalar;
 
   EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion<Scalar>)
   using Base::operator*=;
 
-  typedef typename ei_traits<Quaternion<Scalar> >::Coefficients Coefficients;
+  typedef typename ei_traits<Quaternion<Scalar, _PacketAccess> >::Coefficients Coefficients;
   typedef typename Base::AngleAxisType AngleAxisType;
 
   /** Default constructor leaving the quaternion uninitialized. */


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