BooleanRedux.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_ALLANDANY_H
11 #define EIGEN_ALLANDANY_H
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
17 template<typename Derived, int UnrollCount, int Rows>
19 {
20  enum {
21  col = (UnrollCount-1) / Rows,
22  row = (UnrollCount-1) % Rows
23  };
24 
25  EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
26  {
28  }
29 };
30 
31 template<typename Derived, int Rows>
32 struct all_unroller<Derived, 0, Rows>
33 {
34  EIGEN_DEVICE_FUNC static inline bool run(const Derived &/*mat*/) { return true; }
35 };
36 
37 template<typename Derived, int Rows>
38 struct all_unroller<Derived, Dynamic, Rows>
39 {
40  EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
41 };
42 
43 template<typename Derived, int UnrollCount, int Rows>
45 {
46  enum {
47  col = (UnrollCount-1) / Rows,
48  row = (UnrollCount-1) % Rows
49  };
50 
51  EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
52  {
54  }
55 };
56 
57 template<typename Derived, int Rows>
58 struct any_unroller<Derived, 0, Rows>
59 {
60  EIGEN_DEVICE_FUNC static inline bool run(const Derived & /*mat*/) { return false; }
61 };
62 
63 template<typename Derived, int Rows>
64 struct any_unroller<Derived, Dynamic, Rows>
65 {
66  EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
67 };
68 
69 } // end namespace internal
70 
78 template<typename Derived>
80 {
81  typedef internal::evaluator<Derived> Evaluator;
82  enum {
83  unroll = SizeAtCompileTime != Dynamic
84  && SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT
85  };
86  Evaluator evaluator(derived());
87  if(unroll)
88  return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator);
89  else
90  {
91  for(Index j = 0; j < cols(); ++j)
92  for(Index i = 0; i < rows(); ++i)
93  if (!evaluator.coeff(i, j)) return false;
94  return true;
95  }
96 }
97 
102 template<typename Derived>
104 {
105  typedef internal::evaluator<Derived> Evaluator;
106  enum {
107  unroll = SizeAtCompileTime != Dynamic
108  && SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT
109  };
110  Evaluator evaluator(derived());
111  if(unroll)
112  return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator);
113  else
114  {
115  for(Index j = 0; j < cols(); ++j)
116  for(Index i = 0; i < rows(); ++i)
117  if (evaluator.coeff(i, j)) return true;
118  return false;
119  }
120 }
121 
126 template<typename Derived>
128 {
129  return derived().template cast<bool>().template cast<Index>().sum();
130 }
131 
136 template<typename Derived>
137 inline bool DenseBase<Derived>::hasNaN() const
138 {
139 #if EIGEN_COMP_MSVC || (defined __FAST_MATH__)
140  return derived().array().isNaN().any();
141 #else
142  return !((derived().array()==derived().array()).all());
143 #endif
144 }
145 
150 template<typename Derived>
151 inline bool DenseBase<Derived>::allFinite() const
152 {
153 #if EIGEN_COMP_MSVC || (defined __FAST_MATH__)
154  return derived().array().isFinite().all();
155 #else
156  return !((derived()-derived()).hasNaN());
157 #endif
158 }
159 
160 } // end namespace Eigen
161 
162 #endif // EIGEN_ALLANDANY_H
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
Eigen::internal::all_unroller< Derived, Dynamic, Rows >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &)
Definition: BooleanRedux.h:40
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen::internal::all_unroller::col
@ col
Definition: BooleanRedux.h:21
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
EIGEN_UNROLLING_LIMIT
#define EIGEN_UNROLLING_LIMIT
Definition: Settings.h:24
Eigen::internal::all_unroller< Derived, 0, Rows >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &)
Definition: BooleanRedux.h:34
Eigen::internal::any_unroller::run
static EIGEN_DEVICE_FUNC bool run(const Derived &mat)
Definition: BooleanRedux.h:51
Eigen::internal::any_unroller< Derived, Dynamic, Rows >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &)
Definition: BooleanRedux.h:66
Eigen::internal::any_unroller::col
@ col
Definition: BooleanRedux.h:47
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
Eigen::DenseBase::hasNaN
bool hasNaN() const
Definition: BooleanRedux.h:137
Eigen::internal::all_unroller::run
static EIGEN_DEVICE_FUNC bool run(const Derived &mat)
Definition: BooleanRedux.h:25
Eigen::DenseBase::all
EIGEN_DEVICE_FUNC bool all() const
Definition: BooleanRedux.h:79
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
Eigen::internal::any_unroller< Derived, 0, Rows >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &)
Definition: BooleanRedux.h:60
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::all
static const Eigen::internal::all_t all
Definition: IndexedViewHelper.h:171
Eigen::internal::all_unroller
Definition: BooleanRedux.h:18
gtsam.examples.DogLegOptimizerExample.run
def run(args)
Definition: DogLegOptimizerExample.py:21
Eigen::internal::any_unroller
Definition: BooleanRedux.h:44
Eigen::internal::evaluator
Definition: CoreEvaluators.h:90
Eigen::internal::any_unroller::row
@ row
Definition: BooleanRedux.h:48
Eigen::DenseBase::any
EIGEN_DEVICE_FUNC bool any() const
Definition: BooleanRedux.h:103
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::DenseBase::count
EIGEN_DEVICE_FUNC Index count() const
Definition: BooleanRedux.h:127
Eigen::internal::all_unroller::row
@ row
Definition: BooleanRedux.h:22
internal
Definition: BandTriangularSolver.h:13
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::DenseBase::allFinite
bool allFinite() const
Definition: BooleanRedux.h:151


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:01:50