Re: [eigen] abs/maxCoeff/sum is not a member of EigenCwiseBinaryOp

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


It turns out this was a new issue (again only MSVC 2010), introduced in the following commit:

Gael Guennebaud
 committed bccae23 4 days ago

Introduce a NumTraits<T>::Literal type to be used for literals, and
improve mixing type support in operations between arrays and scalars:
- 2 * ArrayXcf is now optimized in the sense that the integer 2 is properly promoted to a float instead of a complex<float> (fix a regression)
- 2.1 * ArrayXi is now forbiden (previously, 2.1 was converted to 2)
- This mechanism should be applicable to any custom scalar type, assuming NumTraits<T>::Literal is properly defined (it defaults to T)



It compiles with MSVC 2010, if I apply the following changes (basically just a revert of the critical part):

$ hg diff
diff -r 255869aaeacf Eigen/src/Core/util/Macros.h
--- a/Eigen/src/Core/util/Macros.h      Fri Jun 24 11:48:17 2016 +0200
+++ b/Eigen/src/Core/util/Macros.h      Mon Jun 27 22:12:27 2016 +0100
@@ -905,6 +905,39 @@
   CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \
                 const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR>

+#if 1
+#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \
+  EIGEN_DEVICE_FUNC inline \
+  const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,Scalar,OPNAME) \
+  (METHOD)(const Scalar& scalar) const { \
+    return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,Scalar,OPNAME)(derived(), \
+           typename internal::plain_constant_type<Derived,Scalar>::type(derived().rows(), derived().cols(), scalar)); \
+  } \
+  \
+  template <typename T> EIGEN_DEVICE_FUNC inline \
+  typename internal::enable_if<ScalarBinaryOpTraits<Scalar,T,EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<Scalar,T> >::Defined, \
+                               const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,T,OPNAME) >::type \
+  (METHOD)(const T& scalar) const { \
+    return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,T,OPNAME)(derived(), \
+           typename internal::plain_constant_type<Derived,T>::type(derived().rows(), derived().cols(), scalar)); \
+  }
+
+#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
+  EIGEN_DEVICE_FUNC inline friend \
+  const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,OPNAME) \
+  (METHOD)(const Scalar& scalar, const StorageBaseType& matrix) { \
+    return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,OPNAME)( \
+           typename internal::plain_constant_type<Derived,Scalar>::type(matrix.derived().rows(), matrix.derived().cols(), scalar), matrix.derived()); \
+  } \
+  \
+  template <typename T> EIGEN_DEVICE_FUNC inline friend \
+  typename internal::enable_if<ScalarBinaryOpTraits<T,Scalar,EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<T,Scalar> >::Defined, \
+                               const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(T,Derived,OPNAME) >::type \
+  (METHOD)(const T& scalar, const StorageBaseType& matrix) { \
+    return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(T,Derived,OPNAME)( \
+           typename internal::plain_constant_type<Derived,T>::type(matrix.derived().rows(), matrix.derived().cols(), scalar), matrix.derived()); \
+  }
+#else
 #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \
   template <typename T> EIGEN_DEVICE_FUNC inline \
   const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA ScalarBinaryOpTraits<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<Scalar EIGEN_COMMA T> >::Defined>::type,OPNAME) \
@@ -922,6 +955,7 @@
     return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \
            typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \
   }
+#endif

 #define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \
   EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \



On Sat, Jun 25, 2016 at 12:02 PM, Thomas Klimpel <jacques.gentzen@xxxxxxxxx> wrote:
Thanks for the quick answer. Your fix was already included in the version tested by me. Before your fix, the error message said something different. The only additional details I can tell you right now is that even "operator +=" is not found with a similar error message referring to EigenCwiseBinaryOp.

I will try on Monday to get it compiled with MSVC 2010 (good to know that it is "just" a technical issue and probably not laborious to fix).



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