CoreIterators.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_COREITERATORS_H
00026 #define EIGEN_COREITERATORS_H
00027 
00028 /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
00029  */
00030 
00037 // generic version for dense matrix and expressions
00038 template<typename Derived> class DenseBase<Derived>::InnerIterator
00039 {
00040   protected:
00041     typedef typename Derived::Scalar Scalar;
00042     typedef typename Derived::Index Index;
00043 
00044     enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit };
00045   public:
00046     EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer)
00047       : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize())
00048     {}
00049 
00050     EIGEN_STRONG_INLINE Scalar value() const
00051     {
00052       return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner)
00053                           : m_expression.coeff(m_inner, m_outer);
00054     }
00055 
00056     EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; }
00057 
00058     EIGEN_STRONG_INLINE Index index() const { return m_inner; }
00059     inline Index row() const { return IsRowMajor ? m_outer : index(); }
00060     inline Index col() const { return IsRowMajor ? index() : m_outer; }
00061 
00062     EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }
00063 
00064   protected:
00065     const Derived& m_expression;
00066     Index m_inner;
00067     const Index m_outer;
00068     const Index m_end;
00069 };
00070 
00071 #endif // EIGEN_COREITERATORS_H


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:36