[eigen-commits] commit/eigen: bjacob: Bug 369 - Quaternion alignment is broken

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


1 new commit in eigen:


https://bitbucket.org/eigen/eigen/changeset/f78e89cc992e/
changeset:   f78e89cc992e
branch:      3.0
user:        bjacob
date:        2011-10-31 14:23:41
summary:     Bug 369 - Quaternion alignment is broken

The problem was two-fold:
 * missing aligned operator new
 * Flags were mis-computed, the Aligned constant was misused
affected #:  2 files

diff -r 9c5248ab7ac1a1b4194ba44f05d0a5d962c32cf5 -r f78e89cc992edc91c639fb48ef9918335265581f Eigen/src/Geometry/Quaternion.h
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -185,7 +185,7 @@
     return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(
       coeffs().template cast<NewScalarType>());
   }
-  
+
 #ifdef EIGEN_QUATERNIONBASE_PLUGIN
 # include EIGEN_QUATERNIONBASE_PLUGIN
 #endif
@@ -225,22 +225,25 @@
   typedef _Scalar Scalar;
   typedef Matrix<_Scalar,4,1,_Options> Coefficients;
   enum{
-    IsAligned = bool(EIGEN_ALIGN) && ((int(_Options)&Aligned)==Aligned),
+    IsAligned = internal::traits<Coefficients>::Flags & AlignedBit,
     Flags = IsAligned ? (AlignedBit | LvalueBit) : LvalueBit
   };
 };
 }
 
 template<typename _Scalar, int _Options>
-class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >{
+class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
+{
   typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;
+  enum { IsAligned = internal::traits<Quaternion>::IsAligned };
+
 public:
   typedef _Scalar Scalar;
 
   EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion)
   using Base::operator*=;
 
-  typedef typename internal::traits<Quaternion<Scalar,_Options> >::Coefficients Coefficients;
+  typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
   typedef typename Base::AngleAxisType AngleAxisType;
 
   /** Default constructor leaving the quaternion uninitialized. */
@@ -274,6 +277,8 @@
   inline Coefficients& coeffs() { return m_coeffs;}
   inline const Coefficients& coeffs() const { return m_coeffs;}
 
+  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(IsAligned)
+
 protected:
   Coefficients m_coeffs;
   


diff -r 9c5248ab7ac1a1b4194ba44f05d0a5d962c32cf5 -r f78e89cc992edc91c639fb48ef9918335265581f test/geo_quaternion.cpp
--- a/test/geo_quaternion.cpp
+++ b/test/geo_quaternion.cpp
@@ -120,6 +120,10 @@
   VERIFY_IS_APPROX(q1f.template cast<Scalar>(),q1);
   Quaternion<double> q1d = q1.template cast<double>();
   VERIFY_IS_APPROX(q1d.template cast<Scalar>(),q1);
+
+  // test bug 369 - improper alignment.
+  Quaternionx *q = new Quaternionx;
+  delete q;
 }
 
 template<typename Scalar> void mapQuaternion(void){
@@ -191,7 +195,6 @@
   VERIFY( !(Map<ConstPlainObjectType, Aligned>::Flags & LvalueBit) );
 }
 
-
 void test_geo_quaternion()
 {
   for(int i = 0; i < g_repeat; i++) {

Repository URL: https://bitbucket.org/eigen/eigen/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



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