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>
121 {
return mat.template lpNorm<p>(); }
124 template <
typename BinaryOp,
typename Scalar>
129 template<
typename _Scalar,
int Size>
struct Cost 132 template<
typename Derived>
134 {
return mat.
redux(m_functor); }
156 template<
typename ExpressionType,
int Direction>
class VectorwiseOp 166 template<
template<
typename _Scalar>
class Functor,
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());
259 inline const ExpressionType&
_expression()
const {
return m_matrix; }
268 template<
typename BinaryOp>
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();
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 LpNormReturnType< p >::Type lpNorm() const
ReturnType< internal::member_sum >::Type SumReturnType
EIGEN_DEVICE_FUNC const CountReturnType count() const
EIGEN_DEVICE_FUNC const NormReturnType norm() const
ReturnType< internal::member_stableNorm, RealScalar >::Type StableNormReturnType
ReturnType< internal::member_minCoeff >::Type MinCoeffReturnType
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
internal::conditional< isVertical, typename ExpressionType::ColXpr, typename ExpressionType::RowXpr >::type SubVector
EIGEN_DEVICE_FUNC const BlueNormReturnType blueNorm() const
EIGEN_DEVICE_FUNC member_lpnorm()
result_of< BinaryOp(const Scalar &, const Scalar &) >::type result_type
ExpressionType::RealScalar RealScalar
EIGEN_DEVICE_FUNC ReverseReturnType reverse()
EIGEN_DONT_INLINE T::Scalar hypotNorm(T &v)
EIGEN_DEVICE_FUNC const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
Namespace containing all symbols from the Eigen library.
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1,!IsRowMajor > ColXpr
EIGEN_DEVICE_FUNC const MemberOp & functor() const
EIGEN_DEVICE_FUNC ResultType operator()(const XprType &mat) const
EIGEN_DEVICE_FUNC SubVector subVector(Index i)
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 const ProdReturnType prod() const
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)
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC result_type operator()(const DenseBase< Derived > &mat) const
EIGEN_DEVICE_FUNC Index subVectors() const
Pseudo expression providing partial reduction operations.
ReturnType< internal::member_any >::Type AnyReturnType
EIGEN_DEVICE_FUNC ConstColwiseReturnType colwise() 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
Point3 mean(const CONTAINER &points)
mean
internal::ref_selector< ExpressionType >::non_const_type ExpressionTypeNested
ReturnType< internal::member_all >::Type AllReturnType
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 Index rows() const
EIGEN_DEVICE_FUNC VectorwiseOp(ExpressionType &matrix)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
EIGEN_DEVICE_FUNC const SumReturnType sum() const
EIGEN_DEVICE_FUNC ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
PartialReduxExpr< ExpressionType, Functor< Scalar_ >, Direction > Type
void replicate(const MatrixType &m)
MemberOp::result_type Scalar
EIGEN_DEVICE_FUNC ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC Scalar redux(const BinaryOp &func) const
MatrixType::Nested m_matrix
EIGEN_DEVICE_FUNC const MaxCoeffReturnType maxCoeff() const
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
EIGEN_DEVICE_FUNC const ExpressionType & _expression() const
Reverse< const ExpressionType, Direction > ConstReverseReturnType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
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
EIGEN_MEMBER_FUNCTOR(squaredNorm, Size *NumTraits< Scalar >::MulCost+(Size-1)*NumTraits< Scalar >::AddCost)
Expression of the multiple replication of a matrix or vector.
ExpressionTypeNested m_matrix
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
PartialReduxExpr< ExpressionType, internal::member_count< Index >, Direction > CountReturnType
EIGEN_DONT_INLINE T::Scalar stableNorm(T &v)
EIGEN_DEVICE_FUNC const MinCoeffReturnType minCoeff() 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
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< typename ReturnType< internal::member_norm, RealScalar >::Type >::Type > normalized() const
Reverse< ExpressionType, Direction > ReverseReturnType
NumTraits< Scalar >::Real RealScalar
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > EIGEN_DEVICE_FUNC replicate(Index factor=Factor) const
#define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)
MatrixType::Scalar InputScalar
Homogeneous< ExpressionType, Direction > HomogeneousReturnType
EIGEN_DEVICE_FUNC const HypotNormReturnType hypotNorm() const
ExpressionType::Scalar Scalar
EIGEN_DEVICE_FUNC MatrixType::Nested nestedExpression() const
Expression of a fixed-size or dynamic-size block.
EIGEN_DEVICE_FUNC const AnyReturnType any() const
#define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)
traits< MatrixType >::XprKind XprKind
EIGEN_DEVICE_FUNC member_redux(const BinaryOp func)
ReturnType< internal::member_prod >::Type ProdReturnType
EIGEN_DEVICE_FUNC const AllReturnType all() const
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_DEVICE_FUNC const MeanReturnType mean() const
ReturnType< internal::member_norm, RealScalar >::Type NormReturnType
EIGEN_DEVICE_FUNC ExpressionType & operator=(const DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC OppositeExtendedType< OtherDerived >::Type extendedToOpposite(const DenseBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC const StableNormReturnType stableNorm() const
EIGEN_DEVICE_FUNC ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
EIGEN_DONT_INLINE T::Scalar blueNorm(T &v)
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
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
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.
#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
EIGEN_DEVICE_FUNC const ConstReverseReturnType reverse() const
EIGEN_DEVICE_FUNC ExtendedType< OtherDerived >::Type extendedTo(const DenseBase< OtherDerived > &other) const
Eigen::VectorBlock< Vector > SubVector
EIGEN_DEVICE_FUNC ConstRowwiseReturnType rowwise() const
Expression of one (or a set of) homogeneous vector(s)
EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm() const
const Product< Lhs, Rhs > prod(const Lhs &lhs, const Rhs &rhs)
Replicate< OtherDerived, isHorizontal?1:ExpressionType::RowsAtCompileTime, isVertical?1:ExpressionType::ColsAtCompileTime > Type