diff options
Diffstat (limited to 'Eigen/src/Core/BooleanRedux.h')
-rw-r--r-- | Eigen/src/Core/BooleanRedux.h | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/Eigen/src/Core/BooleanRedux.h b/Eigen/src/Core/BooleanRedux.h index 8409d8749..852de8b90 100644 --- a/Eigen/src/Core/BooleanRedux.h +++ b/Eigen/src/Core/BooleanRedux.h @@ -14,58 +14,56 @@ namespace Eigen { namespace internal { -template<typename Derived, int UnrollCount> +template<typename Derived, int UnrollCount, int Rows> struct all_unroller { - typedef typename Derived::ExpressionTraits Traits; enum { - col = (UnrollCount-1) / Traits::RowsAtCompileTime, - row = (UnrollCount-1) % Traits::RowsAtCompileTime + col = (UnrollCount-1) / Rows, + row = (UnrollCount-1) % Rows }; - static inline bool run(const Derived &mat) + EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat) { - return all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col); + return all_unroller<Derived, UnrollCount-1, Rows>::run(mat) && mat.coeff(row, col); } }; -template<typename Derived> -struct all_unroller<Derived, 0> +template<typename Derived, int Rows> +struct all_unroller<Derived, 0, Rows> { - static inline bool run(const Derived &/*mat*/) { return true; } + EIGEN_DEVICE_FUNC static inline bool run(const Derived &/*mat*/) { return true; } }; -template<typename Derived> -struct all_unroller<Derived, Dynamic> +template<typename Derived, int Rows> +struct all_unroller<Derived, Dynamic, Rows> { - static inline bool run(const Derived &) { return false; } + EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; } }; -template<typename Derived, int UnrollCount> +template<typename Derived, int UnrollCount, int Rows> struct any_unroller { - typedef typename Derived::ExpressionTraits Traits; enum { - col = (UnrollCount-1) / Traits::RowsAtCompileTime, - row = (UnrollCount-1) % Traits::RowsAtCompileTime + col = (UnrollCount-1) / Rows, + row = (UnrollCount-1) % Rows }; - static inline bool run(const Derived &mat) + EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat) { - return any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col); + return any_unroller<Derived, UnrollCount-1, Rows>::run(mat) || mat.coeff(row, col); } }; -template<typename Derived> -struct any_unroller<Derived, 0> +template<typename Derived, int Rows> +struct any_unroller<Derived, 0, Rows> { - static inline bool run(const Derived & /*mat*/) { return false; } + EIGEN_DEVICE_FUNC static inline bool run(const Derived & /*mat*/) { return false; } }; -template<typename Derived> -struct any_unroller<Derived, Dynamic> +template<typename Derived, int Rows> +struct any_unroller<Derived, Dynamic, Rows> { - static inline bool run(const Derived &) { return false; } + EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; } }; } // end namespace internal @@ -78,16 +76,16 @@ struct any_unroller<Derived, Dynamic> * \sa any(), Cwise::operator<() */ template<typename Derived> -inline bool DenseBase<Derived>::all() const +EIGEN_DEVICE_FUNC inline bool DenseBase<Derived>::all() const { typedef internal::evaluator<Derived> Evaluator; enum { unroll = SizeAtCompileTime != Dynamic - && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT + && SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT }; Evaluator evaluator(derived()); if(unroll) - return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator); + return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator); else { for(Index j = 0; j < cols(); ++j) @@ -102,16 +100,16 @@ inline bool DenseBase<Derived>::all() const * \sa all() */ template<typename Derived> -inline bool DenseBase<Derived>::any() const +EIGEN_DEVICE_FUNC inline bool DenseBase<Derived>::any() const { typedef internal::evaluator<Derived> Evaluator; enum { unroll = SizeAtCompileTime != Dynamic - && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT + && SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT }; Evaluator evaluator(derived()); if(unroll) - return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator); + return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator); else { for(Index j = 0; j < cols(); ++j) @@ -126,7 +124,7 @@ inline bool DenseBase<Derived>::any() const * \sa all(), any() */ template<typename Derived> -inline Eigen::Index DenseBase<Derived>::count() const +EIGEN_DEVICE_FUNC inline Eigen::Index DenseBase<Derived>::count() const { return derived().template cast<bool>().template cast<Index>().sum(); } |