mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-30 15:54:13 +08:00
Added support for exclusive or
This commit is contained in:
parent
9624a1ea3d
commit
18e6f67426
@ -344,6 +344,22 @@ template<> struct functor_traits<scalar_boolean_or_op> {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \internal
|
||||||
|
* \brief Template functor to compute the xor of two booleans
|
||||||
|
*
|
||||||
|
* \sa class CwiseBinaryOp, ArrayBase::operator^
|
||||||
|
*/
|
||||||
|
struct scalar_boolean_xor_op {
|
||||||
|
EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_xor_op)
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a ^ b; }
|
||||||
|
};
|
||||||
|
template<> struct functor_traits<scalar_boolean_xor_op> {
|
||||||
|
enum {
|
||||||
|
Cost = NumTraits<bool>::AddCost,
|
||||||
|
PacketAccess = false
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* \brief Template functor to compute the incomplete gamma function igamma(a, x)
|
* \brief Template functor to compute the incomplete gamma function igamma(a, x)
|
||||||
*
|
*
|
||||||
|
@ -280,3 +280,21 @@ operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
|||||||
return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
|
return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \returns an expression of the coefficient-wise ^ operator of *this and \a other
|
||||||
|
*
|
||||||
|
* \warning this operator is for expression of bool only.
|
||||||
|
*
|
||||||
|
* Example: \include Cwise_boolean_xor.cpp
|
||||||
|
* Output: \verbinclude Cwise_boolean_xor.out
|
||||||
|
*
|
||||||
|
* \sa operator&&(), select()
|
||||||
|
*/
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
|
||||||
|
operator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
|
||||||
|
THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
|
||||||
|
return CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>(derived(),other.derived());
|
||||||
|
}
|
||||||
|
@ -334,6 +334,12 @@ class TensorBase<Derived, ReadOnlyAccessors>
|
|||||||
return binaryExpr(other.derived(), internal::scalar_boolean_or_op());
|
return binaryExpr(other.derived(), internal::scalar_boolean_or_op());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
const TensorCwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
|
||||||
|
operator^(const OtherDerived& other) const {
|
||||||
|
return binaryExpr(other.derived(), internal::scalar_boolean_xor_op());
|
||||||
|
}
|
||||||
|
|
||||||
// Comparisons and tests.
|
// Comparisons and tests.
|
||||||
template<typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
template<typename OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_LT>, const Derived, const OtherDerived>
|
const TensorCwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_LT>, const Derived, const OtherDerived>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user