Re: [eigen] Eigen2: Assert failure in QR

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


This patch is due to Nick Lewycky.

      Fix C++ conformance problems in stable eigen; discovered by clang.

 * the 'template' keyword is required when the type is dependent on a
   template argument. With 'template' we treat the next identifier as
   a template method instead of a member variable and less-than
   operator.
 * ei_cache_friendly_product was never actually static. Remove the
   bogus 'static' keyword. (Adding it properly caused link errors.)
 * sink the definition of template function ei_hypot after the
   declarations of the functions it tries to call.

Clang warns on default template argument
 int StorageOrder = (unsigned)-1
so cast the whole RHS as int which appears to have been the intent.

Keir

On Thu, Jul 15, 2010 at 11:18 AM, Keir Mierle <mierle@xxxxxxxxx> wrote:
I have another set of patches for Clang compatibility we should add before 2.0.15.

Give me a few minutes to send it in.

Keir


On Thu, Jul 15, 2010 at 11:13 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
Time to release 2.0.15 ? There's been one other important fix.

As soon as someone confirms gcc 3.3 and msvc, i'm OK to release.

The flurry of 2.0 fixes in the past 2 months is rather impressive, i
guess it means that the number of users increased...

Benoit

2010/7/15 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
> oh, we probably fixed the bug at the very same time ;)
>
> indeed, it scary to have such a bug, fortunately unit test in 3.0 are
> much better ;)
>
> gael
>
> On Thu, Jul 15, 2010 at 7:58 PM, Keir Mierle <mierle@xxxxxxxxx> wrote:
>> Fix attached. How did this ever work before?
>> Keir
>>
>> On Thu, Jul 15, 2010 at 9:55 AM, Sameer Agarwal <sameeragarwal@xxxxxxxxxx>
>> wrote:
>>>
>>> Hi Guys,
>>> Maps and QR in Eigen2 triggers an assert error, depending on whether
>>> -DNDEBUG is used or not.
>>>
>>> eigen# g++ qr_test.cc -o qr1
>>>
>>> eigen# ./qr1
>>> Assertion failed: (rows == this->rows()), function resize, file
>>> Eigen/src/Core/Map.h, line 84.
>>> Abort trap
>>>
>>> eigen# g++ qr_test.cc -DNDEBUG -o qr2
>>> eigen# ./qr2
>>>
>>> This is against Eigen 2.0.14.
>>> Sameer
>>
>>
>
>
>




diff --git a/eigen/Eigen/src/Array/BooleanRedux.h b/eigen/Eigen/src/Array/BooleanRedux.h
index 4e82183..cd59eb0 100644
--- a/eigen/Eigen/src/Array/BooleanRedux.h
+++ b/eigen/Eigen/src/Array/BooleanRedux.h
@@ -139,7 +139,7 @@ inline bool MatrixBase<Derived>::any() const
 template<typename Derived>
 inline int MatrixBase<Derived>::count() const
 {
-  return this->cast<bool>().cast<int>().sum();
+  return this->cast<bool>().template cast<int>().sum();
 }
 
 #endif // EIGEN_ALLANDANY_H
diff --git a/eigen/Eigen/src/Core/CoreInstantiations.cpp b/eigen/Eigen/src/Core/CoreInstantiations.cpp
index 56a9448..e72b705 100644
--- a/eigen/Eigen/src/Core/CoreInstantiations.cpp
+++ b/eigen/Eigen/src/Core/CoreInstantiations.cpp
@@ -32,7 +32,7 @@ namespace Eigen
 {
 
 #define EIGEN_INSTANTIATE_PRODUCT(TYPE) \
-template static void ei_cache_friendly_product<TYPE>( \
+template void ei_cache_friendly_product<TYPE>( \
   int _rows, int _cols, int depth, \
   bool _lhsRowMajor, const TYPE* _lhs, int _lhsStride, \
   bool _rhsRowMajor, const TYPE* _rhs, int _rhsStride, \
diff --git a/eigen/Eigen/src/Core/MathFunctions.h b/eigen/Eigen/src/Core/MathFunctions.h
index f2f2a1b..35be925 100644
--- a/eigen/Eigen/src/Core/MathFunctions.h
+++ b/eigen/Eigen/src/Core/MathFunctions.h
@@ -35,16 +35,6 @@ template<typename T> inline T ei_random_amplitude()
   else return static_cast<T>(10);
 }
 
-template<typename T> inline T ei_hypot(T x, T y)
-{
-  T _x = ei_abs(x);
-  T _y = ei_abs(y);
-  T p = std::max(_x, _y);
-  T q = std::min(_x, _y);
-  T qp = q/p;
-  return p * ei_sqrt(T(1) + qp*qp);
-}
-
 /**************
 ***   int   ***
 **************/
@@ -292,4 +282,16 @@ inline bool ei_isApproxOrLessThan(long double a, long double b, long double prec
   return a <= b || ei_isApprox(a, b, prec);
 }
 
+// Templates that make use of all of the above
+
+template<typename T> inline T ei_hypot(T x, T y)
+{
+  T _x = ei_abs(x);
+  T _y = ei_abs(y);
+  T p = std::max(_x, _y);
+  T q = std::min(_x, _y);
+  T qp = q/p;
+  return p * ei_sqrt(T(1) + qp*qp);
+}
+
 #endif // EIGEN_MATHFUNCTIONS_H
diff --git a/eigen/Eigen/src/Core/SolveTriangular.h b/eigen/Eigen/src/Core/SolveTriangular.h
index 12fb0e1..4934ef3 100644
--- a/eigen/Eigen/src/Core/SolveTriangular.h
+++ b/eigen/Eigen/src/Core/SolveTriangular.h
@@ -35,7 +35,7 @@ template<typename Lhs, typename Rhs,
                      ? UpperTriangular
                      : -1,
   int StorageOrder = ei_is_part<Lhs>::value ? -1  // this is to solve ambiguous specializations
-                   : int(Lhs::Flags) & (RowMajorBit|SparseBit)
+                   : int(Lhs::Flags & (RowMajorBit|SparseBit))
   >
 struct ei_solve_triangular_selector;
 


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