11 #ifndef EIGEN_PARTIAL_REDUX_H
12 #define EIGEN_PARTIAL_REDUX_H
34 template<
typename MatrixType,
typename MemberOp,
int Direction>
35 class PartialReduxExpr;
38 template<
typename MatrixType,
typename MemberOp,
int Direction>
39 struct traits<PartialReduxExpr<
MatrixType, MemberOp, Direction> >
42 typedef typename MemberOp::result_type Scalar;
43 typedef typename traits<MatrixType>::StorageKind StorageKind;
44 typedef typename traits<MatrixType>::XprKind XprKind;
47 RowsAtCompileTime = Direction==
Vertical ? 1 : MatrixType::RowsAtCompileTime,
48 ColsAtCompileTime = Direction==
Horizontal ? 1 : MatrixType::ColsAtCompileTime,
49 MaxRowsAtCompileTime = Direction==
Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
50 MaxColsAtCompileTime = Direction==
Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
52 TraversalSize = Direction==
Vertical ? MatrixType::RowsAtCompileTime : MatrixType::ColsAtCompileTime
57 template<
typename MatrixType,
typename MemberOp,
int Direction>
58 class PartialReduxExpr :
public internal::dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type,
59 internal::no_assignment_operator
63 typedef typename internal::dense_xpr_base<PartialReduxExpr>::type
Base;
88 #define EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER,COST,VECTORIZABLE,BINARYOP) \
89 template <typename ResultType,typename Scalar> \
90 struct member_##MEMBER { \
91 typedef ResultType result_type; \
92 typedef BINARYOP<Scalar,Scalar> BinaryOp; \
93 template<int Size> struct Cost { enum { value = COST }; }; \
94 enum { Vectorizable = VECTORIZABLE }; \
95 template<typename XprType> \
96 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE \
97 ResultType operator()(const XprType& mat) const \
98 { return mat.MEMBER(); } \
99 BinaryOp binaryFunc() const { return BinaryOp(); } \
102 #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
103 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER,COST,0,partial_redux_dummy_func)
120 template <
int p,
typename ResultType,
typename Scalar>
121 struct member_lpnorm {
122 typedef ResultType result_type;
123 enum { Vectorizable = 0 };
124 template<
int Size>
struct Cost
127 template<
typename XprType>
129 {
return mat.template lpNorm<p>(); }
132 template <
typename BinaryOpT,
typename Scalar>
133 struct member_redux {
135 typedef typename result_of<
136 BinaryOp(
const Scalar&,
const Scalar&)
139 enum { Vectorizable = functor_traits<BinaryOp>::PacketAccess };
140 template<
int Size>
struct Cost {
enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };
142 template<
typename Derived>
144 {
return mat.redux(m_functor); }
145 const BinaryOp& binaryFunc()
const {
return m_functor; }
191 typedef typename ExpressionType::Scalar
Scalar;
197 template<
template<
typename OutScalar,
typename InputScalar>
class Functor,
201 Functor<ReturnScalar,Scalar>,
209 internal::member_redux<BinaryOp,Scalar>,
223 isVertical ? 1 : ExpressionType::RowsAtCompileTime,
229 template<
typename OtherDerived>
235 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
237 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
252 template<
typename OtherDerived>
258 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
260 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
275 #ifdef EIGEN_PARSED_BY_DOXYGEN
285 typedef internal::subvector_stl_reverse_iterator<ExpressionType,
DirectionType(Direction)> reverse_iterator;
286 typedef internal::subvector_stl_reverse_iterator<
const ExpressionType,
DirectionType(Direction)> const_reverse_iterator;
321 const_reverse_iterator
rend()
const {
return const_reverse_iterator (
m_matrix, -1); }
323 const_reverse_iterator
crend()
const {
return const_reverse_iterator (
m_matrix, -1); }
335 template<
typename BinaryOp>
488 const MeanReturnType
mean()
const
578 template<
typename OtherDerived>
589 template<
typename OtherDerived>
599 template<
typename OtherDerived>
609 template<
typename OtherDerived>
621 template<
typename OtherDerived>
645 template<
typename OtherDerived>
674 template<
typename OtherDerived>
714 template<
typename OtherDerived>
720 : internal::traits<ExpressionType>::ColsAtCompileTime,
723 typedef Block<
const ExpressionType,
725 : int(
internal::traits<ExpressionType>::RowsAtCompileTime),
727 : int(
internal::traits<ExpressionType>::ColsAtCompileTime)>
729 typedef Block<
const ExpressionType,
730 Direction==
Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
731 Direction==
Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
743 # ifdef EIGEN_VECTORWISEOP_PLUGIN
744 # include EIGEN_VECTORWISEOP_PLUGIN
762 template<
typename Derived>
776 template<
typename Derived>
EIGEN_CONSTEXPR Index subVectors() const
IndexedView_or_Block operator()(const RowIndices &rowIndices, const ColIndices &colIndices)
#define EIGEN_DEVICE_FUNC
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)
#define EIGEN_STATIC_ASSERT(X, MSG)
#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Matrix< float, 1, Dynamic > MatrixType
Expression of a fixed-size or dynamic-size block.
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Generic expression where a coefficient-wise unary operator is applied to an expression.
Base class for all dense matrices, vectors, and arrays.
ConstColwiseReturnType colwise() const
internal::traits< Derived >::Scalar Scalar
ConstRowwiseReturnType rowwise() const
Expression of one (or a set of) homogeneous vector(s)
Base class for all dense matrices, vectors, and expressions.
The matrix class, also used for vectors and row-vectors.
Generic expression of a partially reduxed matrix.
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
MatrixType::Nested m_matrix
internal::dense_xpr_base< PartialReduxExpr >::type Base
MatrixType::Nested nestedExpression() const
PartialReduxExpr(const MatrixType &mat, const MemberOp &func=MemberOp())
const MemberOp & functor() const
Expression of the multiple replication of a matrix or vector.
Expression of the reverse of a vector or matrix.
Pseudo expression providing broadcasting and partial reduction operations.
const HypotNormReturnType hypotNorm() const
const SquaredNormReturnType squaredNorm() const
const ProdReturnType prod() const
VectorwiseOp(ExpressionType &matrix)
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
ReturnType< internal::member_maxCoeff >::Type MaxCoeffReturnType
ReturnType< internal::member_hypotNorm, RealScalar >::Type HypotNormReturnType
Reverse< ExpressionType, Direction > ReverseReturnType
OppositeExtendedType< OtherDerived >::Type extendedToOpposite(const DenseBase< OtherDerived > &other) const
ExpressionType::PlainObject CrossReturnType
ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
const_reverse_iterator crend() const
CwiseBinaryOp< internal::scalar_product_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator*(const DenseBase< OtherDerived > &other) const
Index redux_length() const
ExpressionTypeNested m_matrix
ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
Block< const ExpressionType, Direction==Vertical ? int(HNormalized_SizeMinusOne) :int(internal::traits< ExpressionType >::RowsAtCompileTime), Direction==Horizontal ? int(HNormalized_SizeMinusOne) :int(internal::traits< ExpressionType >::ColsAtCompileTime)> HNormalized_Block
ExpressionType::Scalar Scalar
const BlueNormReturnType blueNorm() const
ExtendedType< OtherDerived >::Type extendedTo(const DenseBase< OtherDerived > &other) const
ReturnType< internal::member_any, bool >::Type AnyReturnType
const_iterator cend() const
random_access_iterator_type const_iterator
const CountReturnType count() const
CwiseBinaryOp< internal::scalar_difference_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator-(const DenseBase< OtherDerived > &other) const
const ReplicateReturnType replicate(Index factor) const
const MaxCoeffReturnType maxCoeff() const
ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
const SumReturnType sum() const
ReturnType< internal::member_blueNorm, RealScalar >::Type BlueNormReturnType
CwiseBinaryOp< internal::scalar_sum_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator+(const DenseBase< OtherDerived > &other) const
typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(SumReturnType, Scalar, quotient) MeanReturnType
PartialReduxExpr< ExpressionType, internal::member_count< Index, Scalar >, Direction > CountReturnType
Reverse< const ExpressionType, Direction > ConstReverseReturnType
ExpressionType & operator=(const DenseBase< OtherDerived > &other)
const_iterator cbegin() const
const MinCoeffReturnType minCoeff() const
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > replicate(Index factor=Factor) const
@ HNormalized_SizeMinusOne
ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
internal::ref_selector< ExpressionType >::non_const_type ExpressionTypeNested
reverse_iterator rbegin()
const AnyReturnType any() const
ReturnType< internal::member_sum >::Type SumReturnType
Homogeneous< ExpressionType, Direction > HomogeneousReturnType
const AllReturnType all() const
ExpressionType & operator/=(const DenseBase< OtherDerived > &other)
random_access_iterator_type iterator
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator/(const DenseBase< OtherDerived > &other) const
const_reverse_iterator rbegin() const
const ExpressionType & _expression() const
ExpressionType::RealScalar RealScalar
const LpNormReturnType< p >::Type lpNorm() const
const MeanReturnType mean() const
const_iterator begin() const
ReturnType< internal::member_prod >::Type ProdReturnType
ReverseReturnType reverse()
Replicate< ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType
internal::remove_all_t< ExpressionTypeNested > ExpressionTypeNestedCleaned
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized() const
Block< const ExpressionType, Direction==Vertical ? 1 :int(internal::traits< ExpressionType >::RowsAtCompileTime), Direction==Horizontal ? 1 :int(internal::traits< ExpressionType >::ColsAtCompileTime)> HNormalized_Factors
ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
const_iterator end() const
ReturnType< internal::member_all, bool >::Type AllReturnType
const StableNormReturnType stableNorm() const
CwiseUnaryOp< internal::scalar_sqrt_op< RealScalar >, const SquaredNormReturnType > NormReturnType
const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
const ConstReverseReturnType reverse() const
const_reverse_iterator crbegin() const
PartialReduxExpr< const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const ExpressionTypeNestedCleaned >, internal::member_sum< RealScalar, RealScalar >, Direction > SquaredNormReturnType
const NormReturnType norm() const
const_reverse_iterator rend() const
const HNormalizedReturnType hnormalized() const
column or row-wise homogeneous normalization
const CrossReturnType cross(const MatrixBase< OtherDerived > &other) const
HomogeneousReturnType homogeneous() const
const unsigned int RowMajorBit
EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(sum,(Size-1) *NumTraits< Scalar >::AddCost, 1, internal::scalar_sum_op)
constexpr bool check_implication(bool a, bool b)
typename remove_all< T >::type remove_all_t
EIGEN_MEMBER_FUNCTOR(norm,(Size+5) *NumTraits< Scalar >::MulCost+(Size-1) *NumTraits< Scalar >::AddCost)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Replicate< OtherDerived, isVertical ? 1 :ExpressionType::RowsAtCompileTime, isHorizontal ? 1 :ExpressionType::ColsAtCompileTime > Type
PartialReduxExpr< ExpressionType, internal::member_lpnorm< p, RealScalar, Scalar >, Direction > Type
Replicate< OtherDerived, isHorizontal ? 1 :ExpressionType::RowsAtCompileTime, isVertical ? 1 :ExpressionType::ColsAtCompileTime > Type
PartialReduxExpr< ExpressionType, internal::member_redux< BinaryOp, Scalar >, Direction > Type
PartialReduxExpr< ExpressionType, Functor< ReturnScalar, Scalar >, Direction > Type