2008-06-23 13:25:22 +00:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-22 20:25:33 +02:00
|
|
|
// for linear algebra.
|
2008-06-23 13:25:22 +00:00
|
|
|
//
|
2010-06-24 23:21:58 +02:00
|
|
|
// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2008-06-23 13:25:22 +00:00
|
|
|
//
|
2012-07-13 14:42:47 -04:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2008-06-23 13:25:22 +00:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_COREITERATORS_H
|
|
|
|
|
#define EIGEN_COREITERATORS_H
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
|
|
|
|
|
*/
|
|
|
|
|
|
2011-11-28 16:36:37 +01:00
|
|
|
/** \ingroup SparseCore_Module
|
|
|
|
|
* \class InnerIterator
|
2009-01-14 14:24:10 +00:00
|
|
|
* \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression
|
|
|
|
|
*
|
|
|
|
|
* todo
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// generic version for dense matrix and expressions
|
2010-01-04 19:00:16 +01:00
|
|
|
template<typename Derived> class DenseBase<Derived>::InnerIterator
|
2008-06-23 13:25:22 +00:00
|
|
|
{
|
2010-10-14 10:19:55 +02:00
|
|
|
protected:
|
2008-06-23 13:25:22 +00:00
|
|
|
typedef typename Derived::Scalar Scalar;
|
2010-05-30 16:00:58 -04:00
|
|
|
typedef typename Derived::Index Index;
|
|
|
|
|
|
2009-01-15 14:16:41 +00:00
|
|
|
enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit };
|
2008-06-23 13:25:22 +00:00
|
|
|
public:
|
2010-05-30 16:00:58 -04:00
|
|
|
EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer)
|
2010-06-14 02:18:36 +03:00
|
|
|
: m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize())
|
2008-06-23 13:25:22 +00:00
|
|
|
{}
|
|
|
|
|
|
2009-01-07 17:01:57 +00:00
|
|
|
EIGEN_STRONG_INLINE Scalar value() const
|
2008-06-26 23:22:26 +00:00
|
|
|
{
|
2009-01-15 14:16:41 +00:00
|
|
|
return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner)
|
|
|
|
|
: m_expression.coeff(m_inner, m_outer);
|
2008-06-26 23:22:26 +00:00
|
|
|
}
|
2008-06-23 13:25:22 +00:00
|
|
|
|
2009-01-07 17:01:57 +00:00
|
|
|
EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; }
|
2008-06-23 13:25:22 +00:00
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
EIGEN_STRONG_INLINE Index index() const { return m_inner; }
|
|
|
|
|
inline Index row() const { return IsRowMajor ? m_outer : index(); }
|
|
|
|
|
inline Index col() const { return IsRowMajor ? index() : m_outer; }
|
2008-06-23 13:25:22 +00:00
|
|
|
|
2009-01-07 17:01:57 +00:00
|
|
|
EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }
|
2008-06-23 13:25:22 +00:00
|
|
|
|
|
|
|
|
protected:
|
2009-01-14 14:24:10 +00:00
|
|
|
const Derived& m_expression;
|
2010-05-30 16:00:58 -04:00
|
|
|
Index m_inner;
|
|
|
|
|
const Index m_outer;
|
|
|
|
|
const Index m_end;
|
2008-06-23 13:25:22 +00:00
|
|
|
};
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
2008-06-23 13:25:22 +00:00
|
|
|
#endif // EIGEN_COREITERATORS_H
|