10#ifndef EIGEN_COREITERATORS_H
11#define EIGEN_COREITERATORS_H
14#include "./InternalHeaderCheck.h"
23template <
typename XprType,
typename EvaluatorKind>
24class inner_iterator_selector;
36template <
typename XprType>
39 typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType;
40 typedef internal::evaluator<XprType> EvaluatorType;
41 typedef typename internal::traits<XprType>::Scalar Scalar;
45 InnerIterator(
const XprType &xpr,
const Index &outerId) : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize()) {}
48 EIGEN_STRONG_INLINE Scalar
value()
const {
return m_iter.value(); }
67 EIGEN_STRONG_INLINE
Index index()
const {
return m_iter.index(); }
69 EIGEN_STRONG_INLINE
Index row()
const {
return m_iter.row(); }
71 EIGEN_STRONG_INLINE
Index col()
const {
return m_iter.col(); }
73 EIGEN_STRONG_INLINE
operator bool()
const {
return m_iter; }
90template <
typename XprType>
91class inner_iterator_selector<XprType, IndexBased> {
93 typedef evaluator<XprType> EvaluatorType;
94 typedef typename traits<XprType>::Scalar Scalar;
98 EIGEN_STRONG_INLINE inner_iterator_selector(
const EvaluatorType &eval,
const Index &outerId,
const Index &innerSize)
99 : m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize) {}
101 EIGEN_STRONG_INLINE Scalar value()
const {
102 return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner) : m_eval.coeff(m_inner, m_outer);
105 EIGEN_STRONG_INLINE inner_iterator_selector &operator++() {
110 EIGEN_STRONG_INLINE
Index index()
const {
return m_inner; }
111 inline Index row()
const {
return IsRowMajor ? m_outer : index(); }
112 inline Index col()
const {
return IsRowMajor ? index() : m_outer; }
114 EIGEN_STRONG_INLINE
operator bool()
const {
return m_inner < m_end && m_inner >= 0; }
117 const EvaluatorType &m_eval;
125template <
typename XprType>
126class inner_iterator_selector<XprType, IteratorBased> :
public evaluator<XprType>::InnerIterator {
128 typedef typename evaluator<XprType>::InnerIterator Base;
129 typedef evaluator<XprType> EvaluatorType;
132 EIGEN_STRONG_INLINE inner_iterator_selector(
const EvaluatorType &eval,
const Index &outerId,
134 : Base(eval, outerId) {}
An InnerIterator allows to loop over the element of any matrix expression.
Definition CoreIterators.h:37
InnerIterator & operator++()
Definition CoreIterators.h:52
Index index() const
Definition CoreIterators.h:67
Scalar value() const
Definition CoreIterators.h:48
Index col() const
Definition CoreIterators.h:71
Index row() const
Definition CoreIterators.h:69
InnerIterator(const XprType &xpr, const Index &outerId)
Definition CoreIterators.h:45
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
Definition EigenBase.h:33