CoreIterators.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-2014 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_COREITERATORS_H
11 #define EIGEN_COREITERATORS_H
12 
13 namespace Eigen {
14 
15 /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
16  */
17 
18 namespace internal {
19 
20 template<typename XprType, typename EvaluatorKind>
22 
23 }
24 
32 template<typename XprType>
34 {
35 protected:
39 public:
41  InnerIterator(const XprType &xpr, const Index &outerId)
42  : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize())
43  {}
44 
46  EIGEN_STRONG_INLINE Scalar value() const { return m_iter.value(); }
50  EIGEN_STRONG_INLINE InnerIterator& operator++() { m_iter.operator++(); return *this; }
51  EIGEN_STRONG_INLINE InnerIterator& operator+=(Index i) { m_iter.operator+=(i); return *this; }
53  { InnerIterator result(*this); result+=i; return result; }
54 
55 
57  EIGEN_STRONG_INLINE Index index() const { return m_iter.index(); }
59  EIGEN_STRONG_INLINE Index row() const { return m_iter.row(); }
61  EIGEN_STRONG_INLINE Index col() const { return m_iter.col(); }
63  EIGEN_STRONG_INLINE operator bool() const { return m_iter; }
64 
65 protected:
68 private:
69  // If you get here, then you're not using the right InnerIterator type, e.g.:
70  // SparseMatrix<double,RowMajor> A;
71  // SparseMatrix<double>::InnerIterator it(A,0);
72  template<typename T> InnerIterator(const EigenBase<T>&,Index outer);
73 };
74 
75 namespace internal {
76 
77 // Generic inner iterator implementation for dense objects
78 template<typename XprType>
80 {
81 protected:
83  typedef typename traits<XprType>::Scalar Scalar;
84  enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit };
85 
86 public:
87  EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)
88  : m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize)
89  {}
90 
92  {
93  return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner)
94  : m_eval.coeff(m_inner, m_outer);
95  }
96 
97  EIGEN_STRONG_INLINE inner_iterator_selector& operator++() { m_inner++; return *this; }
98 
99  EIGEN_STRONG_INLINE Index index() const { return m_inner; }
100  inline Index row() const { return IsRowMajor ? m_outer : index(); }
101  inline Index col() const { return IsRowMajor ? index() : m_outer; }
102 
103  EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }
104 
105 protected:
108  const Index m_outer;
109  const Index m_end;
110 };
111 
112 // For iterator-based evaluator, inner-iterator is already implemented as
113 // evaluator<>::InnerIterator
114 template<typename XprType>
116  : public evaluator<XprType>::InnerIterator
117 {
118 protected:
121 
122 public:
123  EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &/*innerSize*/)
124  : Base(eval, outerId)
125  {}
126 };
127 
128 } // end namespace internal
129 
130 } // end namespace Eigen
131 
132 #endif // EIGEN_COREITERATORS_H
Eigen::InnerIterator::operator+
EIGEN_STRONG_INLINE InnerIterator operator+(Index i)
Definition: CoreIterators.h:52
Eigen::InnerIterator::operator+=
EIGEN_STRONG_INLINE InnerIterator & operator+=(Index i)
Definition: CoreIterators.h:51
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::InnerIterator::row
EIGEN_STRONG_INLINE Index row() const
Definition: CoreIterators.h:59
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::EvaluatorType
evaluator< XprType > EvaluatorType
Definition: CoreIterators.h:82
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::row
Index row() const
Definition: CoreIterators.h:100
Eigen::internal::inner_iterator_selector
Definition: CoreIterators.h:21
Eigen::EigenBase
Definition: EigenBase.h:29
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
Eigen::InnerIterator::operator++
EIGEN_STRONG_INLINE InnerIterator & operator++()
Definition: CoreIterators.h:50
result
Values result
Definition: OdometryOptimize.cpp:8
Eigen::internal::inner_iterator_selector< XprType, IteratorBased >::EvaluatorType
evaluator< XprType > EvaluatorType
Definition: CoreIterators.h:120
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::m_eval
const EvaluatorType & m_eval
Definition: CoreIterators.h:106
Eigen::internal::inner_iterator_selector< XprType, IteratorBased >::Base
evaluator< XprType >::InnerIterator Base
Definition: CoreIterators.h:119
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::index
EIGEN_STRONG_INLINE Index index() const
Definition: CoreIterators.h:99
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::Scalar
traits< XprType >::Scalar Scalar
Definition: CoreIterators.h:83
Eigen::InnerIterator::m_eval
EvaluatorType m_eval
Definition: CoreIterators.h:66
Eigen::InnerIterator::value
EIGEN_STRONG_INLINE Scalar value() const
Definition: CoreIterators.h:46
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
Eigen::internal::IteratorBased
Definition: Constants.h:545
Eigen::internal::evaluator< XprType >
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::m_outer
const Index m_outer
Definition: CoreIterators.h:108
Eigen::InnerIterator
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:33
Eigen::InnerIterator::col
EIGEN_STRONG_INLINE Index col() const
Definition: CoreIterators.h:61
XprType
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition: nestbyvalue.cpp:15
Eigen::internal::inner_iterator_selector< XprType, IteratorBased >::inner_iterator_selector
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &)
Definition: CoreIterators.h:123
Eigen::InnerIterator::InnerIterator
InnerIterator(const XprType &xpr, const Index &outerId)
Definition: CoreIterators.h:41
Eigen::InnerIterator::m_iter
IteratorType m_iter
Definition: CoreIterators.h:67
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::value
EIGEN_STRONG_INLINE Scalar value() const
Definition: CoreIterators.h:91
Eigen::InnerIterator::EvaluatorType
internal::evaluator< XprType > EvaluatorType
Definition: CoreIterators.h:37
Eigen::InnerIterator::index
EIGEN_STRONG_INLINE Index index() const
Definition: CoreIterators.h:57
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::m_end
const Index m_end
Definition: CoreIterators.h:109
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::operator++
EIGEN_STRONG_INLINE inner_iterator_selector & operator++()
Definition: CoreIterators.h:97
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::col
Index col() const
Definition: CoreIterators.h:101
internal
Definition: BandTriangularSolver.h:13
Eigen::InnerIterator::IteratorType
internal::inner_iterator_selector< XprType, typename internal::evaluator_traits< XprType >::Kind > IteratorType
Definition: CoreIterators.h:36
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::inner_iterator_selector
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)
Definition: CoreIterators.h:87
Base
Definition: test_virtual_functions.cpp:156
Eigen::internal::eval
Definition: XprHelper.h:332
Eigen::internal::IndexBased
Definition: Constants.h:542
Eigen::internal::inner_iterator_selector< XprType, IndexBased >::m_inner
Index m_inner
Definition: CoreIterators.h:107
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::InnerIterator::Scalar
internal::traits< XprType >::Scalar Scalar
Definition: CoreIterators.h:38
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:02:04