11#ifndef EIGEN_COREITERATORS_H
12#define EIGEN_COREITERATORS_H
15#include "./InternalHeaderCheck.h"
24template <
typename XprType,
typename EvaluatorKind>
25class inner_iterator_selector;
37template <
typename XprType>
40 using IteratorType = internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind>;
41 using EvaluatorType = internal::evaluator<XprType>;
42 using Scalar =
typename internal::traits<XprType>::Scalar;
46 InnerIterator(
const XprType &xpr,
const Index &outerId) : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize()) {}
49 EIGEN_STRONG_INLINE Scalar
value()
const {
return m_iter.value(); }
68 EIGEN_STRONG_INLINE Index
index()
const {
return m_iter.index(); }
70 EIGEN_STRONG_INLINE Index
row()
const {
return m_iter.row(); }
72 EIGEN_STRONG_INLINE Index
col()
const {
return m_iter.col(); }
74 EIGEN_STRONG_INLINE
operator bool()
const {
return m_iter; }
91template <
typename XprType>
92class inner_iterator_selector<XprType, IndexBased> {
94 using EvaluatorType = evaluator<XprType>;
95 using Scalar =
typename traits<XprType>::Scalar;
99 EIGEN_STRONG_INLINE inner_iterator_selector(
const EvaluatorType &eval,
const Index &outerId,
const Index &innerSize)
100 : m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize) {}
102 EIGEN_STRONG_INLINE Scalar value()
const {
103 return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner) : m_eval.coeff(m_inner, m_outer);
106 EIGEN_STRONG_INLINE inner_iterator_selector &operator++() {
111 EIGEN_STRONG_INLINE Index index()
const {
return m_inner; }
112 inline Index row()
const {
return IsRowMajor ? m_outer : index(); }
113 inline Index col()
const {
return IsRowMajor ? index() : m_outer; }
115 EIGEN_STRONG_INLINE
operator bool()
const {
return m_inner < m_end && m_inner >= 0; }
118 const EvaluatorType &m_eval;
126template <
typename XprType>
127class inner_iterator_selector<XprType, IteratorBased> :
public evaluator<XprType>::InnerIterator {
129 using Base =
typename evaluator<XprType>::InnerIterator;
130 using EvaluatorType = evaluator<XprType>;
133 EIGEN_STRONG_INLINE inner_iterator_selector(
const EvaluatorType &eval,
const Index &outerId,
135 : Base(eval, outerId) {}
An InnerIterator allows to loop over the element of any matrix expression.
Definition CoreIterators.h:38
InnerIterator & operator++()
Definition CoreIterators.h:53
Index index() const
Definition CoreIterators.h:68
Scalar value() const
Definition CoreIterators.h:49
Index col() const
Definition CoreIterators.h:72
Index row() const
Definition CoreIterators.h:70
InnerIterator(const XprType &xpr, const Index &outerId)
Definition CoreIterators.h:46
constexpr unsigned int RowMajorBit
Definition Constants.h:71
Definition EigenBase.h:34