This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 405 | Differences between
and this patch

Collapse All | Expand All

(-)a/Eigen/src/Core/Functors.h (+40 lines)
Lines 964-974 struct functor_traits<std::binary_compos Link Here
964
#endif // EIGEN_STDEXT_SUPPORT
964
#endif // EIGEN_STDEXT_SUPPORT
965
965
966
// allow to add new functors and specializations of functor_traits from outside Eigen.
966
// allow to add new functors and specializations of functor_traits from outside Eigen.
967
// this macro is really needed because functor_traits must be specialized after it is declared but before it is used...
967
// this macro is really needed because functor_traits must be specialized after it is declared but before it is used...
968
#ifdef EIGEN_FUNCTORS_PLUGIN
968
#ifdef EIGEN_FUNCTORS_PLUGIN
969
#include EIGEN_FUNCTORS_PLUGIN
969
#include EIGEN_FUNCTORS_PLUGIN
970
#endif
970
#endif
971
971
972
#define EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(OP,NAME) 				\
973
template<typename Scalar>							\
974
struct NAME {									\
975
  typedef typename packet_traits<Scalar>::type Packet;				\
976
  inline NAME(const NAME& other) : m_other(other.m_other) { }			\
977
  inline NAME(const Scalar& other) : m_other(other) { }				\
978
  inline Scalar operator() (const Scalar& a) const { return a OP m_other; }	\
979
  const Scalar m_other;								\
980
};										\
981
template<typename Scalar>							\
982
struct functor_traits<NAME<Scalar> >						\
983
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false }; };
984
985
EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(^ , scalar_bitxor_op)
986
EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(& , scalar_bitand_op)
987
EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(| , scalar_bitor_op)
988
989
#ifdef EIGEN_INCLUDE_ARRAY_BIT_SHIFT
990
  EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(>>, scalar_bitshr_op)
991
  EIGEN_MAKE_SCALAR_CWISE_UNARY_FUNCTOR(<<, scalar_bitshl_op)
992
#endif
993
994
#define EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(OP, NAME) 				\
995
template<typename Scalar>								\
996
struct NAME {										\
997
  EIGEN_EMPTY_STRUCT_CTOR(NAME)								\
998
  EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a, const Scalar& b) const { return a OP b; }	\
999
};											\
1000
template<typename Scalar>								\
1001
struct functor_traits<NAME<Scalar> > { enum { Cost = NumTraits<NAME<Scalar> >::AddCost, PacketAccess = false }; };
1002
1003
EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(|, scalar_bitor_binary_op)
1004
EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(&, scalar_bitand_binary_op)
1005
EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(^, scalar_bitxor_binary_op)
1006
1007
#ifdef EIGEN_INCLUDE_ARRAY_BIT_SHIFT
1008
  EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(>>, scalar_bitshr_binary_op)
1009
  EIGEN_MAKE_SCALAR_CWISE_BINARY_FUNCTOR(<<, scalar_bitshl_binary_op)
1010
#endif
1011
972
} // end namespace internal
1012
} // end namespace internal
973
1013
974
#endif // EIGEN_FUNCTORS_H
1014
#endif // EIGEN_FUNCTORS_H
(-)a/Eigen/src/plugins/ArrayCwiseBinaryOps.h (+16 lines)
Lines 172-179 operator&&(const EIGEN_CURRENT_STORAGE_B Link Here
172
template<typename OtherDerived>
172
template<typename OtherDerived>
173
inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
173
inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
174
operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
174
operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
175
{
175
{
176
  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
176
  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
177
                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
177
                      THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
178
  return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
178
  return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
179
}
179
}
180
181
#define EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(OP,FUNCTOR) 				\
182
template<typename OtherDerived>								\
183
  inline const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>	\
184
  operator OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const	\
185
  { return CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived>(derived(),other.derived()); }
186
187
EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(| ,  internal::scalar_bitor_binary_op)
188
EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(& ,  internal::scalar_bitand_binary_op)
189
EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(^ ,  internal::scalar_bitxor_binary_op)
190
191
#ifdef EIGEN_INCLUDE_ARRAY_BIT_SHIFT
192
  EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(>>,  internal::scalar_bitshr_binary_op)
193
  EIGEN_MAKE_SCALAR_CWISE_BINARY_BITOP(<<,  internal::scalar_bitshl_binary_op)
194
#endif
195
(-)a/Eigen/src/plugins/ArrayCwiseUnaryOps.h (+21 lines)
Lines 195-202 cube() const Link Here
195
195
196
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator==,  std::equal_to)
196
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator==,  std::equal_to)
197
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator!=,  std::not_equal_to)
197
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator!=,  std::not_equal_to)
198
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<,   std::less)
198
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<,   std::less)
199
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<=,  std::less_equal)
199
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator<=,  std::less_equal)
200
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>,   std::greater)
200
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>,   std::greater)
201
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>=,  std::greater_equal)
201
EIGEN_MAKE_SCALAR_CWISE_UNARY_OP(operator>=,  std::greater_equal)
202
202
203
#define EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP(OP,FUNCTOR) 	\
204
  inline const CwiseUnaryOp<FUNCTOR<Scalar>, const Derived>	\
205
    operator OP(const Scalar& scalar) const {			\
206
      return CwiseUnaryOp<FUNCTOR<Scalar>, const Derived>(derived(), FUNCTOR<Scalar>(scalar)); }
207
208
#define EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP_COMMUTATIVE(OP,FUNCTOR)	\
209
  EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP(OP,FUNCTOR) 			\
210
  friend inline const CwiseUnaryOp<FUNCTOR<Scalar>, const Derived>	\
211
  operator OP(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)\
212
  { return other OP scalar; }
213
214
215
EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP_COMMUTATIVE(^, internal::scalar_bitxor_op)
216
EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP_COMMUTATIVE(&, internal::scalar_bitand_op)
217
EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP_COMMUTATIVE(|, internal::scalar_bitor_op)
218
219
#ifdef EIGEN_INCLUDE_ARRAY_BIT_SHIFT
220
  EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP(>>,  internal::scalar_bitshr_op)
221
  EIGEN_MAKE_SCALAR_CWISE_UNARY_BITOP(<<,  internal::scalar_bitshl_op)
222
#endif
223
(-)a/test/CMakeLists.txt (+1 lines)
Lines 95-110 ei_add_test(adjoint) Link Here
95
ei_add_test(diagonal)
95
ei_add_test(diagonal)
96
ei_add_test(miscmatrices)
96
ei_add_test(miscmatrices)
97
ei_add_test(commainitializer)
97
ei_add_test(commainitializer)
98
ei_add_test(smallvectors)
98
ei_add_test(smallvectors)
99
ei_add_test(map)
99
ei_add_test(map)
100
ei_add_test(mapstride)
100
ei_add_test(mapstride)
101
ei_add_test(mapstaticmethods)
101
ei_add_test(mapstaticmethods)
102
ei_add_test(array)
102
ei_add_test(array)
103
ei_add_test(array_bit_ops)
103
ei_add_test(array_for_matrix)
104
ei_add_test(array_for_matrix)
104
ei_add_test(array_replicate)
105
ei_add_test(array_replicate)
105
ei_add_test(array_reverse)
106
ei_add_test(array_reverse)
106
ei_add_test(triangular)
107
ei_add_test(triangular)
107
ei_add_test(selfadjoint)
108
ei_add_test(selfadjoint)
108
ei_add_test(product_selfadjoint)
109
ei_add_test(product_selfadjoint)
109
ei_add_test(product_symm)
110
ei_add_test(product_symm)
110
ei_add_test(product_syrk)
111
ei_add_test(product_syrk)

Return to bug 405