10 #ifndef EIGEN_ALLANDANY_H
11 #define EIGEN_ALLANDANY_H
17 template<
typename Derived,
int UnrollCount>
20 typedef typename Derived::ExpressionTraits Traits;
22 col = (UnrollCount-1) / Traits::RowsAtCompileTime,
23 row = (UnrollCount-1) % Traits::RowsAtCompileTime
26 static inline bool run(
const Derived &mat)
28 return all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col);
32 template<
typename Derived>
33 struct all_unroller<Derived, 0>
35 static inline bool run(
const Derived &) {
return true; }
38 template<
typename Derived>
39 struct all_unroller<Derived, Dynamic>
41 static inline bool run(
const Derived &) {
return false; }
44 template<
typename Derived,
int UnrollCount>
47 typedef typename Derived::ExpressionTraits Traits;
49 col = (UnrollCount-1) / Traits::RowsAtCompileTime,
50 row = (UnrollCount-1) % Traits::RowsAtCompileTime
53 static inline bool run(
const Derived &mat)
55 return any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col);
59 template<
typename Derived>
60 struct any_unroller<Derived, 0>
62 static inline bool run(
const Derived & ) {
return false; }
65 template<
typename Derived>
66 struct any_unroller<Derived, Dynamic>
68 static inline bool run(
const Derived &) {
return false; }
80 template<
typename Derived>
83 typedef internal::evaluator<Derived> Evaluator;
85 unroll = SizeAtCompileTime != Dynamic
86 && Evaluator::CoeffReadCost != Dynamic
90 Evaluator evaluator(derived());
92 return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator);
95 for(Index j = 0; j < cols(); ++j)
96 for(Index i = 0; i < rows(); ++i)
97 if (!evaluator.coeff(i, j))
return false;
106 template<
typename Derived>
109 typedef internal::evaluator<Derived> Evaluator;
111 unroll = SizeAtCompileTime != Dynamic
112 && Evaluator::CoeffReadCost != Dynamic
116 Evaluator evaluator(derived());
118 return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(evaluator);
121 for(Index j = 0; j < cols(); ++j)
122 for(Index i = 0; i < rows(); ++i)
123 if (evaluator.coeff(i, j))
return true;
132 template<
typename Derived>
135 return derived().template cast<bool>().
template cast<Index>().sum();
142 template<
typename Derived>
145 return !((derived().array()==derived().array()).all());
152 template<
typename Derived>
155 return !((derived()-derived()).hasNaN());
160 #endif // EIGEN_ALLANDANY_H
bool any() const
Definition: BooleanRedux.h:107
bool allFinite() const
Definition: BooleanRedux.h:153
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:107
bool all() const
Definition: BooleanRedux.h:81
bool hasNaN() const
Definition: BooleanRedux.h:143
Definition: Eigen_Colamd.h:54
Index count() const
Definition: BooleanRedux.h:133