Main MRPT website > C++ reference
MRPT logo

VectorwiseOp.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 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
00006 //
00007 // Eigen is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public
00009 // License as published by the Free Software Foundation; either
00010 // version 3 of the License, or (at your option) any later version.
00011 //
00012 // Alternatively, you can redistribute it and/or
00013 // modify it under the terms of the GNU General Public License as
00014 // published by the Free Software Foundation; either version 2 of
00015 // the License, or (at your option) any later version.
00016 //
00017 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00018 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00019 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License and a copy of the GNU General Public License along with
00024 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00025 
00026 #ifndef EIGEN_PARTIAL_REDUX_H
00027 #define EIGEN_PARTIAL_REDUX_H
00028 
00029 /** \class PartialReduxExpr
00030   * \ingroup Core_Module
00031   *
00032   * \brief Generic expression of a partially reduxed matrix
00033   *
00034   * \param MatrixType the type of the matrix we are applying the redux operation
00035   * \param MemberOp type of the member functor
00036   * \param Direction indicates the direction of the redux (Vertical or Horizontal)
00037   *
00038   * This class represents an expression of a partial redux operator of a matrix.
00039   * It is the return type of some VectorwiseOp functions,
00040   * and most of the time this is the only way it is used.
00041   *
00042   * \sa class VectorwiseOp
00043   */
00044 
00045 template< typename MatrixType, typename MemberOp, int Direction>
00046 class PartialReduxExpr;
00047 
00048 namespace internal {
00049 template<typename MatrixType, typename MemberOp, int Direction>
00050 struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
00051  : traits<MatrixType>
00052 {
00053   typedef typename MemberOp::result_type Scalar;
00054   typedef typename traits<MatrixType>::StorageKind StorageKind;
00055   typedef typename traits<MatrixType>::XprKind XprKind;
00056   typedef typename MatrixType::Scalar InputScalar;
00057   typedef typename nested<MatrixType>::type MatrixTypeNested;
00058   typedef typename remove_all<MatrixTypeNested>::type _MatrixTypeNested;
00059   enum {
00060     RowsAtCompileTime = Direction==Vertical   ? 1 : MatrixType::RowsAtCompileTime,
00061     ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
00062     MaxRowsAtCompileTime = Direction==Vertical   ? 1 : MatrixType::MaxRowsAtCompileTime,
00063     MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
00064     Flags0 = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits,
00065     Flags = (Flags0 & ~RowMajorBit) | (RowsAtCompileTime == 1 ? RowMajorBit : 0),
00066     TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime
00067   };
00068   #if EIGEN_GNUC_AT_LEAST(3,4)
00069   typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
00070   #else
00071   typedef typename MemberOp::template Cost<InputScalar,TraversalSize> CostOpType;
00072   #endif
00073   enum {
00074     CoeffReadCost = TraversalSize * traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value)
00075   };
00076 };
00077 }
00078 
00079 template< typename MatrixType, typename MemberOp, int Direction>
00080 class PartialReduxExpr : internal::no_assignment_operator,
00081   public internal::dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type
00082 {
00083   public:
00084 
00085     typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;
00086     EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
00087     typedef typename internal::traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
00088     typedef typename internal::traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;
00089 
00090     PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
00091       : m_matrix(mat), m_functor(func) {}
00092 
00093     Index rows() const { return (Direction==Vertical   ? 1 : m_matrix.rows()); }
00094     Index cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
00095 
00096     EIGEN_STRONG_INLINE const Scalar coeff(Index i, Index j) const
00097     {
00098       if (Direction==Vertical)
00099         return m_functor(m_matrix.col(j));
00100       else
00101         return m_functor(m_matrix.row(i));
00102     }
00103 
00104     const Scalar coeff(Index index) const
00105     {
00106       if (Direction==Vertical)
00107         return m_functor(m_matrix.col(index));
00108       else
00109         return m_functor(m_matrix.row(index));
00110     }
00111 
00112   protected:
00113     const MatrixTypeNested m_matrix;
00114     const MemberOp m_functor;
00115 };
00116 
00117 #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST)                               \
00118   template <typename ResultType>                                        \
00119   struct member_##MEMBER {                                           \
00120     EIGEN_EMPTY_STRUCT_CTOR(member_##MEMBER)                         \
00121     typedef ResultType result_type;                                     \
00122     template<typename Scalar, int Size> struct Cost                     \
00123     { enum { value = COST }; };                                         \
00124     template<typename XprType>                                          \
00125     EIGEN_STRONG_INLINE ResultType operator()(const XprType& mat) const \
00126     { return mat.MEMBER(); } \
00127   }
00128 
00129 namespace internal {
00130 
00131 EIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
00132 EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
00133 EIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
00134 EIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
00135 EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * functor_traits<scalar_hypot_op<Scalar> >::Cost );
00136 EIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost);
00137 EIGEN_MEMBER_FUNCTOR(mean, (Size-1)*NumTraits<Scalar>::AddCost + NumTraits<Scalar>::MulCost);
00138 EIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
00139 EIGEN_MEMBER_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
00140 EIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);
00141 EIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);
00142 EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);
00143 EIGEN_MEMBER_FUNCTOR(prod, (Size-1)*NumTraits<Scalar>::MulCost);
00144 
00145 
00146 template <typename BinaryOp, typename Scalar>
00147 struct member_redux {
00148   typedef typename result_of<
00149                      BinaryOp(Scalar)
00150                    >::type  result_type;
00151   template<typename _Scalar, int Size> struct Cost
00152   { enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };
00153   member_redux(const BinaryOp func) : m_functor(func) {}
00154   template<typename Derived>
00155   inline result_type operator()(const DenseBase<Derived>& mat) const
00156   { return mat.redux(m_functor); }
00157   const BinaryOp m_functor;
00158 };
00159 }
00160 
00161 /** \class VectorwiseOp
00162   * \ingroup Core_Module
00163   *
00164   * \brief Pseudo expression providing partial reduction operations
00165   *
00166   * \param ExpressionType the type of the object on which to do partial reductions
00167   * \param Direction indicates the direction of the redux (Vertical or Horizontal)
00168   *
00169   * This class represents a pseudo expression with partial reduction features.
00170   * It is the return type of DenseBase::colwise() and DenseBase::rowwise()
00171   * and most of the time this is the only way it is used.
00172   *
00173   * Example: \include MatrixBase_colwise.cpp
00174   * Output: \verbinclude MatrixBase_colwise.out
00175   *
00176   * \sa DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr
00177   */
00178 template<typename ExpressionType, int Direction> class VectorwiseOp
00179 {
00180   public:
00181 
00182     typedef typename ExpressionType::Scalar Scalar;
00183     typedef typename ExpressionType::RealScalar RealScalar;
00184     typedef typename ExpressionType::Index Index;
00185     typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
00186         ExpressionType, ExpressionType&>::type ExpressionTypeNested;
00187     typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned;
00188 
00189     template<template<typename _Scalar> class Functor,
00190                       typename Scalar=typename internal::traits<ExpressionType>::Scalar> struct ReturnType
00191     {
00192       typedef PartialReduxExpr<ExpressionType,
00193                                Functor<Scalar>,
00194                                Direction
00195                               > Type;
00196     };
00197 
00198     template<typename BinaryOp> struct ReduxReturnType
00199     {
00200       typedef PartialReduxExpr<ExpressionType,
00201                                internal::member_redux<BinaryOp,typename internal::traits<ExpressionType>::Scalar>,
00202                                Direction
00203                               > Type;
00204     };
00205 
00206     enum {
00207       IsVertical   = (Direction==Vertical) ? 1 : 0,
00208       IsHorizontal = (Direction==Horizontal) ? 1 : 0
00209     };
00210 
00211   protected:
00212 
00213     /** \internal
00214       * \returns the i-th subvector according to the \c Direction */
00215     typedef typename internal::conditional<Direction==Vertical,
00216                                typename ExpressionType::ColXpr,
00217                                typename ExpressionType::RowXpr>::type SubVector;
00218     SubVector subVector(Index i)
00219     {
00220       return SubVector(m_matrix.derived(),i);
00221     }
00222 
00223     /** \internal
00224       * \returns the number of subvectors in the direction \c Direction */
00225     Index subVectors() const
00226     { return Direction==Vertical?m_matrix.cols():m_matrix.rows(); }
00227 
00228     template<typename OtherDerived> struct ExtendedType {
00229       typedef Replicate<OtherDerived,
00230                         Direction==Vertical   ? 1 : ExpressionType::RowsAtCompileTime,
00231                         Direction==Horizontal ? 1 : ExpressionType::ColsAtCompileTime> Type;
00232     };
00233 
00234     /** \internal
00235       * Replicates a vector to match the size of \c *this */
00236     template<typename OtherDerived>
00237     typename ExtendedType<OtherDerived>::Type
00238     extendedTo(const DenseBase<OtherDerived>& other) const
00239     {
00240       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
00241       return typename ExtendedType<OtherDerived>::Type
00242                       (other.derived(),
00243                        Direction==Vertical   ? 1 : m_matrix.rows(),
00244                        Direction==Horizontal ? 1 : m_matrix.cols());
00245     }
00246 
00247   public:
00248 
00249     inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
00250 
00251     /** \internal */
00252     inline const ExpressionType& _expression() const { return m_matrix; }
00253 
00254     /** \returns a row or column vector expression of \c *this reduxed by \a func
00255       *
00256       * The template parameter \a BinaryOp is the type of the functor
00257       * of the custom redux operator. Note that func must be an associative operator.
00258       *
00259       * \sa class VectorwiseOp, DenseBase::colwise(), DenseBase::rowwise()
00260       */
00261     template<typename BinaryOp>
00262     const typename ReduxReturnType<BinaryOp>::Type
00263     redux(const BinaryOp& func = BinaryOp()) const
00264     { return typename ReduxReturnType<BinaryOp>::Type(_expression(), func); }
00265 
00266     /** \returns a row (or column) vector expression of the smallest coefficient
00267       * of each column (or row) of the referenced expression.
00268       *
00269       * Example: \include PartialRedux_minCoeff.cpp
00270       * Output: \verbinclude PartialRedux_minCoeff.out
00271       *
00272       * \sa DenseBase::minCoeff() */
00273     const typename ReturnType<internal::member_minCoeff>::Type minCoeff() const
00274     { return _expression(); }
00275 
00276     /** \returns a row (or column) vector expression of the largest coefficient
00277       * of each column (or row) of the referenced expression.
00278       *
00279       * Example: \include PartialRedux_maxCoeff.cpp
00280       * Output: \verbinclude PartialRedux_maxCoeff.out
00281       *
00282       * \sa DenseBase::maxCoeff() */
00283     const typename ReturnType<internal::member_maxCoeff>::Type maxCoeff() const
00284     { return _expression(); }
00285 
00286     /** \returns a row (or column) vector expression of the squared norm
00287       * of each column (or row) of the referenced expression.
00288       *
00289       * Example: \include PartialRedux_squaredNorm.cpp
00290       * Output: \verbinclude PartialRedux_squaredNorm.out
00291       *
00292       * \sa DenseBase::squaredNorm() */
00293     const typename ReturnType<internal::member_squaredNorm,RealScalar>::Type squaredNorm() const
00294     { return _expression(); }
00295 
00296     /** \returns a row (or column) vector expression of the norm
00297       * of each column (or row) of the referenced expression.
00298       *
00299       * Example: \include PartialRedux_norm.cpp
00300       * Output: \verbinclude PartialRedux_norm.out
00301       *
00302       * \sa DenseBase::norm() */
00303     const typename ReturnType<internal::member_norm,RealScalar>::Type norm() const
00304     { return _expression(); }
00305 
00306 
00307     /** \returns a row (or column) vector expression of the norm
00308       * of each column (or row) of the referenced expression, using
00309       * blue's algorithm.
00310       *
00311       * \sa DenseBase::blueNorm() */
00312     const typename ReturnType<internal::member_blueNorm,RealScalar>::Type blueNorm() const
00313     { return _expression(); }
00314 
00315 
00316     /** \returns a row (or column) vector expression of the norm
00317       * of each column (or row) of the referenced expression, avoiding
00318       * underflow and overflow.
00319       *
00320       * \sa DenseBase::stableNorm() */
00321     const typename ReturnType<internal::member_stableNorm,RealScalar>::Type stableNorm() const
00322     { return _expression(); }
00323 
00324 
00325     /** \returns a row (or column) vector expression of the norm
00326       * of each column (or row) of the referenced expression, avoiding
00327       * underflow and overflow using a concatenation of hypot() calls.
00328       *
00329       * \sa DenseBase::hypotNorm() */
00330     const typename ReturnType<internal::member_hypotNorm,RealScalar>::Type hypotNorm() const
00331     { return _expression(); }
00332 
00333     /** \returns a row (or column) vector expression of the sum
00334       * of each column (or row) of the referenced expression.
00335       *
00336       * Example: \include PartialRedux_sum.cpp
00337       * Output: \verbinclude PartialRedux_sum.out
00338       *
00339       * \sa DenseBase::sum() */
00340     const typename ReturnType<internal::member_sum>::Type sum() const
00341     { return _expression(); }
00342 
00343     /** \returns a row (or column) vector expression of the mean
00344     * of each column (or row) of the referenced expression.
00345     *
00346     * \sa DenseBase::mean() */
00347     const typename ReturnType<internal::member_mean>::Type mean() const
00348     { return _expression(); }
00349 
00350     /** \returns a row (or column) vector expression representing
00351       * whether \b all coefficients of each respective column (or row) are \c true.
00352       *
00353       * \sa DenseBase::all() */
00354     const typename ReturnType<internal::member_all>::Type all() const
00355     { return _expression(); }
00356 
00357     /** \returns a row (or column) vector expression representing
00358       * whether \b at \b least one coefficient of each respective column (or row) is \c true.
00359       *
00360       * \sa DenseBase::any() */
00361     const typename ReturnType<internal::member_any>::Type any() const
00362     { return _expression(); }
00363 
00364     /** \returns a row (or column) vector expression representing
00365       * the number of \c true coefficients of each respective column (or row).
00366       *
00367       * Example: \include PartialRedux_count.cpp
00368       * Output: \verbinclude PartialRedux_count.out
00369       *
00370       * \sa DenseBase::count() */
00371     const PartialReduxExpr<ExpressionType, internal::member_count<Index>, Direction> count() const
00372     { return _expression(); }
00373 
00374     /** \returns a row (or column) vector expression of the product
00375       * of each column (or row) of the referenced expression.
00376       *
00377       * Example: \include PartialRedux_prod.cpp
00378       * Output: \verbinclude PartialRedux_prod.out
00379       *
00380       * \sa DenseBase::prod() */
00381     const typename ReturnType<internal::member_prod>::Type prod() const
00382     { return _expression(); }
00383 
00384 
00385     /** \returns a matrix expression
00386       * where each column (or row) are reversed.
00387       *
00388       * Example: \include Vectorwise_reverse.cpp
00389       * Output: \verbinclude Vectorwise_reverse.out
00390       *
00391       * \sa DenseBase::reverse() */
00392     const Reverse<ExpressionType, Direction> reverse() const
00393     { return Reverse<ExpressionType, Direction>( _expression() ); }
00394 
00395     typedef Replicate<ExpressionType,Direction==Vertical?Dynamic:1,Direction==Horizontal?Dynamic:1> ReplicateReturnType;
00396     const ReplicateReturnType replicate(Index factor) const;
00397 
00398     /**
00399       * \return an expression of the replication of each column (or row) of \c *this
00400       *
00401       * Example: \include DirectionWise_replicate.cpp
00402       * Output: \verbinclude DirectionWise_replicate.out
00403       *
00404       * \sa VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate
00405       */
00406     // NOTE implemented here because of sunstudio's compilation errors
00407     template<int Factor> const Replicate<ExpressionType,(IsVertical?Factor:1),(IsHorizontal?Factor:1)>
00408     replicate(Index factor = Factor) const
00409     {
00410       return Replicate<ExpressionType,Direction==Vertical?Factor:1,Direction==Horizontal?Factor:1>
00411           (_expression(),Direction==Vertical?factor:1,Direction==Horizontal?factor:1);
00412     }
00413 
00414 /////////// Artithmetic operators ///////////
00415 
00416     /** Copies the vector \a other to each subvector of \c *this */
00417     template<typename OtherDerived>
00418     ExpressionType& operator=(const DenseBase<OtherDerived>& other)
00419     {
00420       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
00421       //eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
00422       for(Index j=0; j<subVectors(); ++j)
00423         subVector(j) = other;
00424       return const_cast<ExpressionType&>(m_matrix);
00425     }
00426 
00427     /** Adds the vector \a other to each subvector of \c *this */
00428     template<typename OtherDerived>
00429     ExpressionType& operator+=(const DenseBase<OtherDerived>& other)
00430     {
00431       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
00432       for(Index j=0; j<subVectors(); ++j)
00433         subVector(j) += other.derived();
00434       return const_cast<ExpressionType&>(m_matrix);
00435     }
00436 
00437     /** Substracts the vector \a other to each subvector of \c *this */
00438     template<typename OtherDerived>
00439     ExpressionType& operator-=(const DenseBase<OtherDerived>& other)
00440     {
00441       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
00442       for(Index j=0; j<subVectors(); ++j)
00443         subVector(j) -= other.derived();
00444       return const_cast<ExpressionType&>(m_matrix);
00445     }
00446 
00447     /** Returns the expression of the sum of the vector \a other to each subvector of \c *this */
00448     template<typename OtherDerived> EIGEN_STRONG_INLINE
00449     CwiseBinaryOp<internal::scalar_sum_op<Scalar>,
00450                   ExpressionTypeNestedCleaned,
00451                   typename ExtendedType<OtherDerived>::Type>
00452     operator+(const DenseBase<OtherDerived>& other) const
00453     {
00454       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
00455       return m_matrix + extendedTo(other.derived());
00456     }
00457 
00458     /** Returns the expression of the difference between each subvector of \c *this and the vector \a other */
00459     template<typename OtherDerived>
00460     CwiseBinaryOp<internal::scalar_difference_op<Scalar>,
00461                   ExpressionTypeNestedCleaned,
00462                   typename ExtendedType<OtherDerived>::Type>
00463     operator-(const DenseBase<OtherDerived>& other) const
00464     {
00465       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
00466       return m_matrix - extendedTo(other.derived());
00467     }
00468 
00469 /////////// Geometry module ///////////
00470 
00471     Homogeneous<ExpressionType,Direction> homogeneous() const;
00472 
00473     typedef typename ExpressionType::PlainObject CrossReturnType;
00474     template<typename OtherDerived>
00475     const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;
00476 
00477     enum {
00478       HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
00479                                              : internal::traits<ExpressionType>::ColsAtCompileTime,
00480       HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1
00481     };
00482     typedef Block<const ExpressionType,
00483                   Direction==Vertical   ? int(HNormalized_SizeMinusOne)
00484                                         : int(internal::traits<ExpressionType>::RowsAtCompileTime),
00485                   Direction==Horizontal ? int(HNormalized_SizeMinusOne)
00486                                         : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
00487             HNormalized_Block;
00488     typedef Block<const ExpressionType,
00489                   Direction==Vertical   ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
00490                   Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
00491             HNormalized_Factors;
00492     typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>,
00493                 HNormalized_Block,
00494                 Replicate<HNormalized_Factors,
00495                   Direction==Vertical   ? HNormalized_SizeMinusOne : 1,
00496                   Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >
00497             HNormalizedReturnType;
00498 
00499     const HNormalizedReturnType hnormalized() const;
00500 
00501   protected:
00502     ExpressionTypeNested m_matrix;
00503 };
00504 
00505 /** \returns a VectorwiseOp wrapper of *this providing additional partial reduction operations
00506   *
00507   * Example: \include MatrixBase_colwise.cpp
00508   * Output: \verbinclude MatrixBase_colwise.out
00509   *
00510   * \sa rowwise(), class VectorwiseOp
00511   */
00512 template<typename Derived>
00513 inline const typename DenseBase<Derived>::ConstColwiseReturnType
00514 DenseBase<Derived>::colwise() const
00515 {
00516   return derived();
00517 }
00518 
00519 /** \returns a writable VectorwiseOp wrapper of *this providing additional partial reduction operations
00520   *
00521   * \sa rowwise(), class VectorwiseOp
00522   */
00523 template<typename Derived>
00524 inline typename DenseBase<Derived>::ColwiseReturnType
00525 DenseBase<Derived>::colwise()
00526 {
00527   return derived();
00528 }
00529 
00530 /** \returns a VectorwiseOp wrapper of *this providing additional partial reduction operations
00531   *
00532   * Example: \include MatrixBase_rowwise.cpp
00533   * Output: \verbinclude MatrixBase_rowwise.out
00534   *
00535   * \sa colwise(), class VectorwiseOp
00536   */
00537 template<typename Derived>
00538 inline const typename DenseBase<Derived>::ConstRowwiseReturnType
00539 DenseBase<Derived>::rowwise() const
00540 {
00541   return derived();
00542 }
00543 
00544 /** \returns a writable VectorwiseOp wrapper of *this providing additional partial reduction operations
00545   *
00546   * \sa colwise(), class VectorwiseOp
00547   */
00548 template<typename Derived>
00549 inline typename DenseBase<Derived>::RowwiseReturnType
00550 DenseBase<Derived>::rowwise()
00551 {
00552   return derived();
00553 }
00554 
00555 #endif // EIGEN_PARTIAL_REDUX_H



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