Main MRPT website > C++ reference
MRPT logo

Flagged.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 Benoit Jacob <jacob.benoit.1@gmail.com>
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_FLAGGED_H
00026 #define EIGEN_FLAGGED_H
00027 
00028 /** \class Flagged
00029   * \ingroup Core_Module
00030   *
00031   * \brief Expression with modified flags
00032   *
00033   * \param ExpressionType the type of the object of which we are modifying the flags
00034   * \param Added the flags added to the expression
00035   * \param Removed the flags removed from the expression (has priority over Added).
00036   *
00037   * This class represents an expression whose flags have been modified.
00038   * It is the return type of MatrixBase::flagged()
00039   * and most of the time this is the only way it is used.
00040   *
00041   * \sa MatrixBase::flagged()
00042   */
00043 
00044 namespace internal {
00045 template<typename ExpressionType, unsigned int Added, unsigned int Removed>
00046 struct traits<Flagged<ExpressionType, Added, Removed> > : traits<ExpressionType>
00047 {
00048   enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
00049 };
00050 }
00051 
00052 template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged
00053   : public MatrixBase<Flagged<ExpressionType, Added, Removed> >
00054 {
00055   public:
00056 
00057     typedef MatrixBase<Flagged> Base;
00058     EIGEN_DENSE_PUBLIC_INTERFACE(Flagged)
00059     typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
00060         ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
00061     typedef typename ExpressionType::InnerIterator InnerIterator;
00062 
00063     inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {}
00064 
00065     inline Index rows() const { return m_matrix.rows(); }
00066     inline Index cols() const { return m_matrix.cols(); }
00067     inline Index outerStride() const { return m_matrix.outerStride(); }
00068     inline Index innerStride() const { return m_matrix.innerStride(); }
00069 
00070     inline const Scalar coeff(Index row, Index col) const
00071     {
00072       return m_matrix.coeff(row, col);
00073     }
00074 
00075     inline Scalar& coeffRef(Index row, Index col)
00076     {
00077       return m_matrix.const_cast_derived().coeffRef(row, col);
00078     }
00079 
00080     inline const Scalar coeff(Index index) const
00081     {
00082       return m_matrix.coeff(index);
00083     }
00084 
00085     inline Scalar& coeffRef(Index index)
00086     {
00087       return m_matrix.const_cast_derived().coeffRef(index);
00088     }
00089 
00090     template<int LoadMode>
00091     inline const PacketScalar packet(Index row, Index col) const
00092     {
00093       return m_matrix.template packet<LoadMode>(row, col);
00094     }
00095 
00096     template<int LoadMode>
00097     inline void writePacket(Index row, Index col, const PacketScalar& x)
00098     {
00099       m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00100     }
00101 
00102     template<int LoadMode>
00103     inline const PacketScalar packet(Index index) const
00104     {
00105       return m_matrix.template packet<LoadMode>(index);
00106     }
00107 
00108     template<int LoadMode>
00109     inline void writePacket(Index index, const PacketScalar& x)
00110     {
00111       m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
00112     }
00113 
00114     const ExpressionType& _expression() const { return m_matrix; }
00115 
00116     template<typename OtherDerived>
00117     typename ExpressionType::PlainObject solveTriangular(const MatrixBase<OtherDerived>& other) const;
00118 
00119     template<typename OtherDerived>
00120     void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
00121 
00122   protected:
00123     ExpressionTypeNested m_matrix;
00124 };
00125 
00126 /** \returns an expression of *this with added and removed flags
00127   *
00128   * This is mostly for internal use.
00129   *
00130   * \sa class Flagged
00131   */
00132 template<typename Derived>
00133 template<unsigned int Added,unsigned int Removed>
00134 inline const Flagged<Derived, Added, Removed>
00135 DenseBase<Derived>::flagged() const
00136 {
00137   return derived();
00138 }
00139 
00140 #endif // EIGEN_FLAGGED_H



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011