11 #ifndef EIGEN_PARTIAL_REDUX_H    12 #define EIGEN_PARTIAL_REDUX_H    32 template< 
typename MatrixType, 
typename MemberOp, 
int Direction>
    33 class PartialReduxExpr;
    36 template<
typename MatrixType, 
typename MemberOp, 
int Direction>
    40   typedef typename MemberOp::result_type 
Scalar;
    45     RowsAtCompileTime = Direction==
Vertical   ? 1 : MatrixType::RowsAtCompileTime,
    46     ColsAtCompileTime = Direction==
Horizontal ? 1 : MatrixType::ColsAtCompileTime,
    47     MaxRowsAtCompileTime = Direction==
Vertical   ? 1 : MatrixType::MaxRowsAtCompileTime,
    48     MaxColsAtCompileTime = Direction==
Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
    50     TraversalSize = Direction==
Vertical ? MatrixType::RowsAtCompileTime :  MatrixType::ColsAtCompileTime
    55 template< 
typename MatrixType, 
typename MemberOp, 
int Direction>
    66       : m_matrix(mat), m_functor(func) {}
    77     const MemberOp& 
functor()
 const { 
return m_functor; }
    84 #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST)                               \    85   template <typename ResultType>                                        \    86   struct member_##MEMBER {                                              \    87     EIGEN_EMPTY_STRUCT_CTOR(member_##MEMBER)                            \    88     typedef ResultType result_type;                                     \    89     template<typename Scalar, int Size> struct Cost                     \    90     { enum { value = COST }; };                                         \    91     template<typename XprType>                                          \    92     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE                               \    93     ResultType operator()(const XprType& mat) const                     \    94     { return mat.MEMBER(); } \   113 template <
int p, 
typename ResultType>
   116   template<
typename Scalar, 
int Size> 
struct Cost   119   template<
typename XprType>
   120   EIGEN_DEVICE_FUNC 
inline ResultType 
operator()(
const XprType& mat)
 const   121   { 
return mat.template lpNorm<p>(); }
   124 template <
typename BinaryOp, 
typename Scalar>
   127                      BinaryOp(
const Scalar&,
const Scalar&)
   129   template<
typename _Scalar, 
int Size> 
struct Cost   131   EIGEN_DEVICE_FUNC 
explicit member_redux(
const BinaryOp func) : m_functor(func) {}
   132   template<
typename Derived>
   134   { 
return mat.
redux(m_functor); }
   156 template<
typename ExpressionType, 
int Direction> 
class VectorwiseOp   160     typedef typename ExpressionType::Scalar 
Scalar;
   166     template<
template<
typename _Scalar> 
class Functor,
   198       return SubVector(m_matrix.derived(),i);
   205     { 
return isVertical?m_matrix.cols():m_matrix.rows(); }
   209                         isVertical   ? 1 : ExpressionType::RowsAtCompileTime,
   210                         isHorizontal ? 1 : ExpressionType::ColsAtCompileTime> 
Type;
   215     template<
typename OtherDerived>
   221                           YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
   223                           YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
   226                        isVertical   ? 1 : m_matrix.rows(),
   227                        isHorizontal ? 1 : m_matrix.cols());
   232                         isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,
   233                         isVertical   ? 1 : ExpressionType::ColsAtCompileTime> 
Type;
   238     template<
typename OtherDerived>
   244                           YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
   246                           YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
   249                        isHorizontal  ? 1 : m_matrix.rows(),
   250                        isVertical    ? 1 : m_matrix.cols());
   255     explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
   259     inline const ExpressionType& 
_expression()
 const { 
return m_matrix; }
   268     template<
typename BinaryOp>
   271     redux(
const BinaryOp& func = BinaryOp())
 const   305     { 
return MinCoeffReturnType(_expression()); }
   318     { 
return MaxCoeffReturnType(_expression()); }
   330     { 
return SquaredNormReturnType(_expression()); }
   341     const NormReturnType 
norm()
 const   342     { 
return NormReturnType(_expression()); }
   366     { 
return BlueNormReturnType(_expression()); }
   377     { 
return StableNormReturnType(_expression()); }
   388     { 
return HypotNormReturnType(_expression()); }
   398     const SumReturnType 
sum()
 const   399     { 
return SumReturnType(_expression()); }
   406     const MeanReturnType 
mean()
 const   407     { 
return MeanReturnType(_expression()); }
   415     const AllReturnType 
all()
 const   416     { 
return AllReturnType(_expression()); }
   424     const AnyReturnType 
any()
 const   425     { 
return AnyReturnType(_expression()); }
   438     { 
return CountReturnType(_expression()); }
   448     const ProdReturnType 
prod()
 const   449     { 
return ProdReturnType(_expression()); }
   461     { 
return ConstReverseReturnType( _expression() ); }
   469     { 
return ReverseReturnType( _expression() ); }
   473     const ReplicateReturnType replicate(Index factor) 
const;
   490           (_expression(),isVertical?factor:1,isHorizontal?factor:1);
   496     template<
typename OtherDerived>
   503       return const_cast<ExpressionType&
>(m_matrix = extendedTo(other.derived()));
   507     template<
typename OtherDerived>
   513       return const_cast<ExpressionType&
>(m_matrix += extendedTo(other.derived()));
   517     template<
typename OtherDerived>
   523       return const_cast<ExpressionType&
>(m_matrix -= extendedTo(other.derived()));
   527     template<
typename OtherDerived>
   534       m_matrix *= extendedTo(other.derived());
   535       return const_cast<ExpressionType&
>(m_matrix);
   539     template<
typename OtherDerived>
   546       m_matrix /= extendedTo(other.derived());
   547       return const_cast<ExpressionType&
>(m_matrix);
   553                   const ExpressionTypeNestedCleaned,
   559       return m_matrix + extendedTo(other.derived());
   563     template<
typename OtherDerived>
   566                   const ExpressionTypeNestedCleaned,
   572       return m_matrix - extendedTo(other.derived());
   579                   const ExpressionTypeNestedCleaned,
   587       return m_matrix * extendedTo(other.derived());
   592     template<
typename OtherDerived>
   595                   const ExpressionTypeNestedCleaned,
   602       return m_matrix / extendedTo(other.derived());
   610     CwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
   611                   const ExpressionTypeNestedCleaned,
   613     normalized()
 const { 
return m_matrix.cwiseQuotient(extendedToOpposite(this->norm())); }
   620       m_matrix = this->normalized();
   623     EIGEN_DEVICE_FUNC 
inline void reverseInPlace();
   629     HomogeneousReturnType homogeneous() 
const;
   632     template<
typename OtherDerived>
   639       HNormalized_SizeMinusOne = HNormalized_Size==
Dynamic ? 
Dynamic : HNormalized_Size-1
   641     typedef Block<
const ExpressionType,
   642                   Direction==
Vertical   ? int(HNormalized_SizeMinusOne)
   643                                         : int(
internal::traits<ExpressionType>::RowsAtCompileTime),
   644                   Direction==
Horizontal ? int(HNormalized_SizeMinusOne)
   645                                         : int(
internal::traits<ExpressionType>::ColsAtCompileTime)>
   647     typedef Block<
const ExpressionType,
   654                   Direction==
Vertical   ? HNormalized_SizeMinusOne : 1,
   655                   Direction==
Horizontal ? HNormalized_SizeMinusOne : 1> >
   672 template<
typename Derived>
   686 template<
typename Derived>
   695 #endif // EIGEN_PARTIAL_REDUX_H Block< Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowXpr
internal::remove_all< ExpressionTypeNested >::type ExpressionTypeNestedCleaned
EIGEN_DEVICE_FUNC ExpressionType & operator/=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC void normalize()
#define EIGEN_STRONG_INLINE
PartialReduxExpr< ExpressionType, internal::member_lpnorm< p, RealScalar >, Direction > Type
EIGEN_DEVICE_FUNC const ConstReverseReturnType reverse() const
EIGEN_MEMBER_FUNCTOR(squaredNorm, Size *NumTraits< Scalar >::MulCost+(Size-1) *NumTraits< Scalar >::AddCost)
ReturnType< internal::member_sum >::Type SumReturnType
EIGEN_DEVICE_FUNC PartialReduxExpr(const MatrixType &mat, const MemberOp &func=MemberOp())
EIGEN_DEVICE_FUNC const SumReturnType sum() const
EIGEN_DEVICE_FUNC Index rows() const
ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
EIGEN_DEVICE_FUNC const MaxCoeffReturnType maxCoeff() const
ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
EIGEN_DEVICE_FUNC ConstColwiseReturnType colwise() const
internal::conditional< isVertical, typename ExpressionType::ColXpr, typename ExpressionType::RowXpr >::type SubVector
EIGEN_DEVICE_FUNC member_lpnorm()
result_of< BinaryOp(const Scalar &, const Scalar &) >::type result_type
ExpressionType::RealScalar RealScalar
EIGEN_DEVICE_FUNC ReverseReturnType reverse()
EIGEN_DEVICE_FUNC const LpNormReturnType< p >::Type lpNorm() const
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
EIGEN_DEVICE_FUNC const StableNormReturnType stableNorm() const
EIGEN_DEVICE_FUNC SubVector subVector(Index i)
Generic expression of a partially reduxed matrix. 
Replicate< ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Pseudo expression providing partial reduction operations. 
EIGEN_DEVICE_FUNC const HypotNormReturnType hypotNorm() const
EIGEN_DEVICE_FUNC const ExpressionType & _expression() const
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< typename ReturnType< internal::member_norm, RealScalar >::Type >::Type > normalized() const
ReturnType< internal::member_any >::Type AnyReturnType
EIGEN_DEVICE_FUNC Scalar redux(const BinaryOp &func) const
EIGEN_DEVICE_FUNC ExtendedType< OtherDerived >::Type extendedTo(const DenseBase< OtherDerived > &other) const
const unsigned int RowMajorBit
Base class for all dense matrices, vectors, and arrays. 
#define EIGEN_IMPLIES(a, b)
ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
internal::ref_selector< ExpressionType >::non_const_type ExpressionTypeNested
EIGEN_DEVICE_FUNC const MeanReturnType mean() const
ReturnType< internal::member_all >::Type AllReturnType
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator/(const DenseBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC VectorwiseOp(ExpressionType &matrix)
Generic expression where a coefficient-wise binary operator is applied to two expressions. 
EIGEN_DEVICE_FUNC ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC const CountReturnType count() const
PartialReduxExpr< ExpressionType, Functor< Scalar_ >, Direction > Type
MemberOp::result_type Scalar
EIGEN_DEVICE_FUNC ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC const AnyReturnType any() const
MatrixType::Nested m_matrix
EIGEN_DEVICE_FUNC OppositeExtendedType< OtherDerived >::Type extendedToOpposite(const DenseBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm() const
Reverse< const ExpressionType, Direction > ConstReverseReturnType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API. 
EIGEN_DEVICE_FUNC result_type operator()(const DenseBase< Derived > &mat) const
Expression of the multiple replication of a matrix or vector. 
EIGEN_DEVICE_FUNC ConstRowwiseReturnType rowwise() const
ExpressionTypeNested m_matrix
EIGEN_DEVICE_FUNC const BlueNormReturnType blueNorm() const
PartialReduxExpr< ExpressionType, internal::member_count< Index >, Direction > CountReturnType
EIGEN_DEVICE_FUNC ResultType operator()(const XprType &mat) const
traits< MatrixType >::StorageKind StorageKind
CwiseBinaryOp< internal::scalar_quotient_op< typename internal::traits< ExpressionType >::Scalar >, const HNormalized_Block, const Replicate< HNormalized_Factors, Direction==Vertical ? HNormalized_SizeMinusOne :1, Direction==Horizontal ? HNormalized_SizeMinusOne :1 > > HNormalizedReturnType
Reverse< ExpressionType, Direction > ReverseReturnType
#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)
MatrixType::Scalar InputScalar
EIGEN_DEVICE_FUNC MatrixType::Nested nestedExpression() const
Homogeneous< ExpressionType, Direction > HomogeneousReturnType
EIGEN_DEVICE_FUNC const MemberOp & functor() const
EIGEN_DEVICE_FUNC const ProdReturnType prod() const
ExpressionType::Scalar Scalar
EIGEN_DEVICE_FUNC const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
Expression of a fixed-size or dynamic-size block. 
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_sum_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator+(const DenseBase< OtherDerived > &other) const
#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)
traits< MatrixType >::XprKind XprKind
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_product_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > EIGEN_DEVICE_FUNC operator*(const DenseBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC member_redux(const BinaryOp func)
ReturnType< internal::member_prod >::Type ProdReturnType
EIGEN_DEVICE_FUNC const MinCoeffReturnType minCoeff() const
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
ReturnType< internal::member_norm, RealScalar >::Type NormReturnType
EIGEN_DEVICE_FUNC ExpressionType & operator=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC const AllReturnType all() const
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_difference_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator-(const DenseBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
Replicate< OtherDerived, isVertical ? 1 :ExpressionType::RowsAtCompileTime, isHorizontal ? 1 :ExpressionType::ColsAtCompileTime > Type
Block< const ExpressionType, Direction==Vertical ? 1 :int(internal::traits< ExpressionType >::RowsAtCompileTime), Direction==Horizontal ? 1 :int(internal::traits< ExpressionType >::ColsAtCompileTime)> HNormalized_Factors
PartialReduxExpr< ExpressionType, internal::member_redux< BinaryOp, Scalar >, Direction > Type
ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
Expression of the reverse of a vector or matrix. 
EIGEN_DEVICE_FUNC Index subVectors() const
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC const NormReturnType norm() const
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
ReturnType< internal::member_squaredNorm, RealScalar >::Type SquaredNormReturnType
ExpressionType::PlainObject CrossReturnType
ReturnType< internal::member_mean >::Type MeanReturnType
Base class for all dense matrices, vectors, and expressions. 
ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
internal::dense_xpr_base< PartialReduxExpr >::type Base
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > EIGEN_DEVICE_FUNC replicate(Index factor=Factor) const
Expression of one (or a set of) homogeneous vector(s) 
Replicate< OtherDerived, isHorizontal ? 1 :ExpressionType::RowsAtCompileTime, isVertical ? 1 :ExpressionType::ColsAtCompileTime > Type