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-01-04 19:00:16 +01:00
|
|
|
// Copyright (C) 2008-2010 Gael Guennebaud <g.gael@free.fr>
|
2008-06-23 13:25:22 +00:00
|
|
|
//
|
|
|
|
|
// Eigen is free software; you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
|
// version 3 of the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Alternatively, you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2 of
|
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License and a copy of the GNU General Public License along with
|
|
|
|
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_COREITERATORS_H
|
|
|
|
|
#define EIGEN_COREITERATORS_H
|
|
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
|
|
|
|
|
*/
|
|
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \class InnerIterator
|
|
|
|
|
* \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
|
|
|
{
|
|
|
|
|
typedef typename Derived::Scalar Scalar;
|
2009-01-15 14:16:41 +00:00
|
|
|
enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit };
|
2008-06-23 13:25:22 +00:00
|
|
|
public:
|
2009-01-14 14:24:10 +00:00
|
|
|
EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, int outer)
|
|
|
|
|
: m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.rows())
|
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
|
|
|
|
2009-01-07 17:01:57 +00:00
|
|
|
EIGEN_STRONG_INLINE int index() const { return m_inner; }
|
2009-01-15 14:16:41 +00:00
|
|
|
inline int row() const { return IsRowMajor ? m_outer : index(); }
|
|
|
|
|
inline int 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;
|
2008-06-26 23:22:26 +00:00
|
|
|
int m_inner;
|
|
|
|
|
const int m_outer;
|
2008-06-23 13:25:22 +00:00
|
|
|
const int m_end;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // EIGEN_COREITERATORS_H
|