diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2017-03-25 14:17:07 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-03-25 14:17:07 +0100 |
| commit | 35f7829af10c61e33dd2e2a7a015058e11a11ea0 (patch) | |
| tree | 7135010dcf8fd0a49f3020d52112709bcb883bd6 /eigen/Eigen/src/Core/BooleanRedux.h | |
| parent | 6e8724193e40a932faf9064b664b529e7301c578 (diff) | |
update
Diffstat (limited to 'eigen/Eigen/src/Core/BooleanRedux.h')
| -rw-r--r-- | eigen/Eigen/src/Core/BooleanRedux.h | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/eigen/Eigen/src/Core/BooleanRedux.h b/eigen/Eigen/src/Core/BooleanRedux.h index be9f48a..ccf5190 100644 --- a/eigen/Eigen/src/Core/BooleanRedux.h +++ b/eigen/Eigen/src/Core/BooleanRedux.h @@ -14,54 +14,54 @@ namespace Eigen { namespace internal { -template<typename Derived, int UnrollCount> +template<typename Derived, int UnrollCount, int Rows> struct all_unroller { enum { - col = (UnrollCount-1) / Derived::RowsAtCompileTime, - row = (UnrollCount-1) % Derived::RowsAtCompileTime + col = (UnrollCount-1) / Rows, + row = (UnrollCount-1) % Rows }; 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; } }; -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; } }; -template<typename Derived, int UnrollCount> +template<typename Derived, int UnrollCount, int Rows> struct any_unroller { enum { - col = (UnrollCount-1) / Derived::RowsAtCompileTime, - row = (UnrollCount-1) % Derived::RowsAtCompileTime + col = (UnrollCount-1) / Rows, + row = (UnrollCount-1) % Rows }; - + 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; } }; -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; } }; @@ -76,21 +76,21 @@ 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 - && CoeffReadCost != Dynamic - && NumTraits<Scalar>::AddCost != Dynamic - && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT + && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT }; + Evaluator evaluator(derived()); if(unroll) - return internal::all_unroller<Derived, unroll ? int(SizeAtCompileTime) : Dynamic>::run(derived()); + return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator); else { for(Index j = 0; j < cols(); ++j) for(Index i = 0; i < rows(); ++i) - if (!coeff(i, j)) return false; + if (!evaluator.coeff(i, j)) return false; return true; } } @@ -100,21 +100,21 @@ 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 - && CoeffReadCost != Dynamic - && NumTraits<Scalar>::AddCost != Dynamic - && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT + && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT }; + Evaluator evaluator(derived()); if(unroll) - return internal::any_unroller<Derived, unroll ? int(SizeAtCompileTime) : Dynamic>::run(derived()); + return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator); else { for(Index j = 0; j < cols(); ++j) for(Index i = 0; i < rows(); ++i) - if (coeff(i, j)) return true; + if (evaluator.coeff(i, j)) return true; return false; } } @@ -124,7 +124,7 @@ inline bool DenseBase<Derived>::any() const * \sa all(), any() */ template<typename Derived> -inline typename DenseBase<Derived>::Index DenseBase<Derived>::count() const +EIGEN_DEVICE_FUNC inline Eigen::Index DenseBase<Derived>::count() const { return derived().template cast<bool>().template cast<Index>().sum(); } @@ -136,7 +136,11 @@ inline typename DenseBase<Derived>::Index DenseBase<Derived>::count() const template<typename Derived> inline bool DenseBase<Derived>::hasNaN() const { +#if EIGEN_COMP_MSVC || (defined __FAST_MATH__) + return derived().array().isNaN().any(); +#else return !((derived().array()==derived().array()).all()); +#endif } /** \returns true if \c *this contains only finite numbers, i.e., no NaN and no +/-INF values. @@ -146,7 +150,11 @@ inline bool DenseBase<Derived>::hasNaN() const template<typename Derived> inline bool DenseBase<Derived>::allFinite() const { +#if EIGEN_COMP_MSVC || (defined __FAST_MATH__) + return derived().array().isFinite().all(); +#else return !((derived()-derived()).hasNaN()); +#endif } } // end namespace Eigen |
