aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-20 11:41:22 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-10-20 11:41:22 -0700
commiteaf4b98180d7606abba69133e39e23537ced79e5 (patch)
treea9f9adc1fc6dfa452e3dc1393371096b5c668c6b /unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
parentf5c1587e4e7d9e3e5a57deedff8d27b866a0a47b (diff)
Added support for boolean reductions (ie 'and' & 'or' reductions)
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h b/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
index ed259399b..a98c6a2e3 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
@@ -219,6 +219,33 @@ template <typename T> struct ProdReducer
};
+struct AndReducer
+{
+ static const bool PacketAccess = false;
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void reduce(bool t, bool* accum) const {
+ *accum = *accum && t;
+ }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool initialize() const {
+ return true;
+ }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool finalize(bool accum) const {
+ return accum;
+ }
+};
+
+struct OrReducer {
+ static const bool PacketAccess = false;
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void reduce(bool t, bool* accum) const {
+ *accum = *accum || t;
+ }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool initialize() const {
+ return false;
+ }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool finalize(bool accum) const {
+ return accum;
+ }
+};
+
// Argmin/Argmax reducers
template <typename T> struct ArgMaxTupleReducer
{