diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-10-06 17:18:06 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-10-06 17:18:06 +0200 |
commit | 26cde4db3c600f3f1ef635305be76547ab032189 (patch) | |
tree | 7fea21ecde67cc6f3a26bedd860311045370e701 | |
parent | fb51bab27295faa1b9ec98bbdcee667f22465c92 (diff) |
Define Permutation*<>::Scalar to 'void', re-enable scalar type compatibility check in assignment while relaxing this test for void types.
-rw-r--r-- | Eigen/src/Core/AssignEvaluator.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/PermutationMatrix.h | 5 | ||||
-rw-r--r-- | Eigen/src/Core/util/XprHelper.h | 7 |
3 files changed, 11 insertions, 7 deletions
diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index f94539094..a02104bb0 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -751,11 +751,7 @@ EIGEN_DEVICE_FUNC void call_assignment_no_alias(Dst& dst, const Src& src, const // TODO check whether this is the right place to perform these checks: EIGEN_STATIC_ASSERT_LVALUE(Dst) EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ActualDstTypeCleaned,Src) - - // TODO this line is commented to allow matrix = permutation - // Actually, the "Scalar" type for a permutation matrix does not really make sense, - // perhaps it could be void, and EIGEN_CHECK_BINARY_COMPATIBILIY could allow micing void with anything...? -// EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar); + EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar); Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func); } diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index bfe6f899a..b5f7e4a54 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -69,6 +69,7 @@ class PermutationBase : public EigenBase<Derived> PlainPermutationType; using Base::derived; typedef Transpose<PermutationBase> TransposeReturnType; + typedef void Scalar; #endif /** Copies the other permutation into *this */ @@ -303,6 +304,7 @@ struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _Storag typedef PermutationStorage StorageKind; typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; typedef _StorageIndex StorageIndex; + typedef void Scalar; }; } @@ -426,6 +428,7 @@ struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _St typedef PermutationStorage StorageKind; typedef Map<const Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType; typedef _StorageIndex StorageIndex; + typedef void Scalar; }; } @@ -499,7 +502,7 @@ template<typename _IndicesType> struct traits<PermutationWrapper<_IndicesType> > { typedef PermutationStorage StorageKind; - typedef typename _IndicesType::Scalar Scalar; + typedef void Scalar; typedef typename _IndicesType::Scalar StorageIndex; typedef _IndicesType IndicesType; enum { diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index c31cd4801..052f824ae 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -654,6 +654,11 @@ bool is_same_dense(const T1 &, const T2 &, typename enable_if<!(has_direct_acces return false; } +template<typename T, typename U> struct is_same_or_void { enum { value = is_same<T,U>::value }; }; +template<typename T> struct is_same_or_void<void,T> { enum { value = 1 }; }; +template<typename T> struct is_same_or_void<T,void> { enum { value = 1 }; }; +template<> struct is_same_or_void<void,void> { enum { value = 1 }; }; + } // end namespace internal // we require Lhs and Rhs to have the same scalar type. Currently there is no example of a binary functor @@ -666,7 +671,7 @@ bool is_same_dense(const T1 &, const T2 &, typename enable_if<!(has_direct_acces #define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \ EIGEN_STATIC_ASSERT((internal::functor_is_product_like<BINOP>::ret \ ? int(internal::scalar_product_traits<LHS, RHS>::Defined) \ - : int(internal::is_same<LHS, RHS>::value)), \ + : int(internal::is_same_or_void<LHS, RHS>::value)), \ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) } // end namespace Eigen |