Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
VectorwiseOp.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2019 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_PARTIAL_REDUX_H
12 #define EIGEN_PARTIAL_REDUX_H
13 
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
34 template< typename MatrixType, typename MemberOp, int Direction>
35 class PartialReduxExpr;
36 
37 namespace internal {
38 template<typename MatrixType, typename MemberOp, int Direction>
39 struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
40  : traits<MatrixType>
41 {
42  typedef typename MemberOp::result_type Scalar;
43  typedef typename traits<MatrixType>::StorageKind StorageKind;
44  typedef typename traits<MatrixType>::XprKind XprKind;
45  typedef typename MatrixType::Scalar InputScalar;
46  enum {
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,
51  Flags = RowsAtCompileTime == 1 ? RowMajorBit : 0,
52  TraversalSize = Direction==Vertical ? MatrixType::RowsAtCompileTime : MatrixType::ColsAtCompileTime
53  };
54 };
55 }
56 
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
60 {
61  public:
62 
63  typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;
64  EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
65 
66  EIGEN_DEVICE_FUNC
67  explicit PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
68  : m_matrix(mat), m_functor(func) {}
69 
70  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
71  Index rows() const EIGEN_NOEXCEPT { return (Direction==Vertical ? 1 : m_matrix.rows()); }
72  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
73  Index cols() const EIGEN_NOEXCEPT { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
74 
75  EIGEN_DEVICE_FUNC
76  typename MatrixType::Nested nestedExpression() const { return m_matrix; }
77 
78  EIGEN_DEVICE_FUNC
79  const MemberOp& functor() const { return m_functor; }
80 
81  protected:
82  typename MatrixType::Nested m_matrix;
83  const MemberOp m_functor;
84 };
85 
86 template<typename A,typename B> struct partial_redux_dummy_func;
87 
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(); } \
100  }
101 
102 #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
103  EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER,COST,0,partial_redux_dummy_func)
104 
105 namespace internal {
106 
107 EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
108 EIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
109 EIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
110 EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * functor_traits<scalar_hypot_op<Scalar> >::Cost );
111 EIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);
112 EIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);
113 EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);
114 
115 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_sum_op);
116 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_min_op);
117 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_max_op);
118 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(prod, (Size-1)*NumTraits<Scalar>::MulCost, 1, internal::scalar_product_op);
119 
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
125  { enum { value = (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost }; };
126  EIGEN_DEVICE_FUNC member_lpnorm() {}
127  template<typename XprType>
128  EIGEN_DEVICE_FUNC inline ResultType operator()(const XprType& mat) const
129  { return mat.template lpNorm<p>(); }
130 };
131 
132 template <typename BinaryOpT, typename Scalar>
133 struct member_redux {
134  typedef BinaryOpT BinaryOp;
135  typedef typename result_of<
136  BinaryOp(const Scalar&,const Scalar&)
137  >::type result_type;
138 
139  enum { Vectorizable = functor_traits<BinaryOp>::PacketAccess };
140  template<int Size> struct Cost { enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };
141  EIGEN_DEVICE_FUNC explicit member_redux(const BinaryOp func) : m_functor(func) {}
142  template<typename Derived>
143  EIGEN_DEVICE_FUNC inline result_type operator()(const DenseBase<Derived>& mat) const
144  { return mat.redux(m_functor); }
145  const BinaryOp& binaryFunc() const { return m_functor; }
146  const BinaryOp m_functor;
147 };
148 }
149 
187 template<typename ExpressionType, int Direction> class VectorwiseOp
188 {
189  public:
190 
191  typedef typename ExpressionType::Scalar Scalar;
192  typedef typename ExpressionType::RealScalar RealScalar;
193  typedef Eigen::Index Index;
194  typedef typename internal::ref_selector<ExpressionType>::non_const_type ExpressionTypeNested;
195  typedef internal::remove_all_t<ExpressionTypeNested> ExpressionTypeNestedCleaned;
196 
197  template<template<typename OutScalar,typename InputScalar> class Functor,
198  typename ReturnScalar=Scalar> struct ReturnType
199  {
200  typedef PartialReduxExpr<ExpressionType,
201  Functor<ReturnScalar,Scalar>,
202  Direction
203  > Type;
204  };
205 
206  template<typename BinaryOp> struct ReduxReturnType
207  {
208  typedef PartialReduxExpr<ExpressionType,
209  internal::member_redux<BinaryOp,Scalar>,
210  Direction
211  > Type;
212  };
213 
214  enum {
215  isVertical = (Direction==Vertical) ? 1 : 0,
216  isHorizontal = (Direction==Horizontal) ? 1 : 0
217  };
218 
219  protected:
220 
221  template<typename OtherDerived> struct ExtendedType {
222  typedef Replicate<OtherDerived,
223  isVertical ? 1 : ExpressionType::RowsAtCompileTime,
224  isHorizontal ? 1 : ExpressionType::ColsAtCompileTime> Type;
225  };
226 
229  template<typename OtherDerived>
230  EIGEN_DEVICE_FUNC
231  typename ExtendedType<OtherDerived>::Type
232  extendedTo(const DenseBase<OtherDerived>& other) const
233  {
234  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxColsAtCompileTime==1),
235  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
236  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxRowsAtCompileTime==1),
237  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
238  return typename ExtendedType<OtherDerived>::Type
239  (other.derived(),
240  isVertical ? 1 : m_matrix.rows(),
241  isHorizontal ? 1 : m_matrix.cols());
242  }
243 
244  template<typename OtherDerived> struct OppositeExtendedType {
245  typedef Replicate<OtherDerived,
246  isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,
247  isVertical ? 1 : ExpressionType::ColsAtCompileTime> Type;
248  };
249 
252  template<typename OtherDerived>
253  EIGEN_DEVICE_FUNC
254  typename OppositeExtendedType<OtherDerived>::Type
255  extendedToOpposite(const DenseBase<OtherDerived>& other) const
256  {
257  EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxColsAtCompileTime==1),
258  YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
259  EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxRowsAtCompileTime==1),
260  YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
261  return typename OppositeExtendedType<OtherDerived>::Type
262  (other.derived(),
263  isHorizontal ? 1 : m_matrix.rows(),
264  isVertical ? 1 : m_matrix.cols());
265  }
266 
267  public:
268  EIGEN_DEVICE_FUNC
269  explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
270 
272  EIGEN_DEVICE_FUNC
273  inline const ExpressionType& _expression() const { return m_matrix; }
274 
275  #ifdef EIGEN_PARSED_BY_DOXYGEN
279  random_access_iterator_type iterator;
281  random_access_iterator_type const_iterator;
282  #else
283  typedef internal::subvector_stl_iterator<ExpressionType, DirectionType(Direction)> iterator;
284  typedef internal::subvector_stl_iterator<const ExpressionType, DirectionType(Direction)> const_iterator;
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;
287  #endif
288 
292  iterator begin() { return iterator (m_matrix, 0); }
294  const_iterator begin() const { return const_iterator(m_matrix, 0); }
296  const_iterator cbegin() const { return const_iterator(m_matrix, 0); }
297 
301  reverse_iterator rbegin() { return reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
303  const_reverse_iterator rbegin() const { return const_reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
305  const_reverse_iterator crbegin() const { return const_reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
306 
310  iterator end() { return iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
312  const_iterator end() const { return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
314  const_iterator cend() const { return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
315 
319  reverse_iterator rend() { return reverse_iterator (m_matrix, -1); }
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); }
324 
335  template<typename BinaryOp>
336  EIGEN_DEVICE_FUNC
337  const typename ReduxReturnType<BinaryOp>::Type
338  redux(const BinaryOp& func = BinaryOp()) const
339  {
340  eigen_assert(redux_length()>0 && "you are using an empty matrix");
341  return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp,Scalar>(func));
342  }
343 
344  typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;
345  typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;
346  typedef PartialReduxExpr<const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const ExpressionTypeNestedCleaned>,internal::member_sum<RealScalar,RealScalar>,Direction> SquaredNormReturnType;
347  typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> NormReturnType;
348  typedef typename ReturnType<internal::member_blueNorm,RealScalar>::Type BlueNormReturnType;
349  typedef typename ReturnType<internal::member_stableNorm,RealScalar>::Type StableNormReturnType;
350  typedef typename ReturnType<internal::member_hypotNorm,RealScalar>::Type HypotNormReturnType;
351  typedef typename ReturnType<internal::member_sum>::Type SumReturnType;
352  typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(SumReturnType,Scalar,quotient) MeanReturnType;
353  typedef typename ReturnType<internal::member_all>::Type AllReturnType;
354  typedef typename ReturnType<internal::member_any>::Type AnyReturnType;
356  typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;
357  typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;
358  typedef Reverse<ExpressionType, Direction> ReverseReturnType;
359 
360  template<int p> struct LpNormReturnType {
362  };
363 
376  EIGEN_DEVICE_FUNC
378  {
379  eigen_assert(redux_length()>0 && "you are using an empty matrix");
380  return MinCoeffReturnType(_expression());
381  }
382 
395  EIGEN_DEVICE_FUNC
397  {
398  eigen_assert(redux_length()>0 && "you are using an empty matrix");
399  return MaxCoeffReturnType(_expression());
400  }
401 
410  EIGEN_DEVICE_FUNC
412  { return SquaredNormReturnType(m_matrix.cwiseAbs2()); }
413 
422  EIGEN_DEVICE_FUNC
423  const NormReturnType norm() const
424  { return NormReturnType(squaredNorm()); }
425 
434  template<int p>
435  EIGEN_DEVICE_FUNC
436  const typename LpNormReturnType<p>::Type lpNorm() const
437  { return typename LpNormReturnType<p>::Type(_expression()); }
438 
439 
446  EIGEN_DEVICE_FUNC
448  { return BlueNormReturnType(_expression()); }
449 
450 
457  EIGEN_DEVICE_FUNC
459  { return StableNormReturnType(_expression()); }
460 
461 
468  EIGEN_DEVICE_FUNC
470  { return HypotNormReturnType(_expression()); }
471 
479  EIGEN_DEVICE_FUNC
480  const SumReturnType sum() const
481  { return SumReturnType(_expression()); }
482 
487  EIGEN_DEVICE_FUNC
488  const MeanReturnType mean() const
489  { return sum() / Scalar(Direction==Vertical?m_matrix.rows():m_matrix.cols()); }
490 
496  EIGEN_DEVICE_FUNC
497  const AllReturnType all() const
498  { return AllReturnType(_expression()); }
499 
505  EIGEN_DEVICE_FUNC
506  const AnyReturnType any() const
507  { return AnyReturnType(_expression()); }
508 
518  EIGEN_DEVICE_FUNC
519  const CountReturnType count() const
520  { return CountReturnType(_expression()); }
521 
529  EIGEN_DEVICE_FUNC
530  const ProdReturnType prod() const
531  { return ProdReturnType(_expression()); }
532 
533 
541  EIGEN_DEVICE_FUNC
543  { return ConstReverseReturnType( _expression() ); }
544 
549  EIGEN_DEVICE_FUNC
551  { return ReverseReturnType( _expression() ); }
552 
553  typedef Replicate<ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType;
554  EIGEN_DEVICE_FUNC
555  const ReplicateReturnType replicate(Index factor) const;
556 
565  // NOTE implemented here because of sunstudio's compilation errors
566  // isVertical*Factor+isHorizontal instead of (isVertical?Factor:1) to handle CUDA bug with ternary operator
568  EIGEN_DEVICE_FUNC
569  replicate(Index factor = Factor) const
570  {
572  (_expression(),isVertical?factor:1,isHorizontal?factor:1);
573  }
574 
576 
578  template<typename OtherDerived>
579  EIGEN_DEVICE_FUNC
580  ExpressionType& operator=(const DenseBase<OtherDerived>& other)
581  {
582  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
583  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
584  //eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
585  return m_matrix = extendedTo(other.derived());
586  }
587 
589  template<typename OtherDerived>
590  EIGEN_DEVICE_FUNC
591  ExpressionType& operator+=(const DenseBase<OtherDerived>& other)
592  {
593  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
594  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
595  return m_matrix += extendedTo(other.derived());
596  }
597 
599  template<typename OtherDerived>
600  EIGEN_DEVICE_FUNC
601  ExpressionType& operator-=(const DenseBase<OtherDerived>& other)
602  {
603  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
604  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
605  return m_matrix -= extendedTo(other.derived());
606  }
607 
609  template<typename OtherDerived>
610  EIGEN_DEVICE_FUNC
611  ExpressionType& operator*=(const DenseBase<OtherDerived>& other)
612  {
613  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
614  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
615  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
616  m_matrix *= extendedTo(other.derived());
617  return m_matrix;
618  }
619 
621  template<typename OtherDerived>
622  EIGEN_DEVICE_FUNC
623  ExpressionType& operator/=(const DenseBase<OtherDerived>& other)
624  {
625  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
626  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
627  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
628  m_matrix /= extendedTo(other.derived());
629  return m_matrix;
630  }
631 
633  template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
635  const ExpressionTypeNestedCleaned,
636  const typename ExtendedType<OtherDerived>::Type>
637  operator+(const DenseBase<OtherDerived>& other) const
638  {
639  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
640  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
641  return m_matrix + extendedTo(other.derived());
642  }
643 
645  template<typename OtherDerived>
646  EIGEN_DEVICE_FUNC
648  const ExpressionTypeNestedCleaned,
649  const typename ExtendedType<OtherDerived>::Type>
650  operator-(const DenseBase<OtherDerived>& other) const
651  {
652  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
653  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
654  return m_matrix - extendedTo(other.derived());
655  }
656 
659  template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
661  const ExpressionTypeNestedCleaned,
662  const typename ExtendedType<OtherDerived>::Type>
663  EIGEN_DEVICE_FUNC
664  operator*(const DenseBase<OtherDerived>& other) const
665  {
666  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
667  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
668  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
669  return m_matrix * extendedTo(other.derived());
670  }
671 
674  template<typename OtherDerived>
675  EIGEN_DEVICE_FUNC
677  const ExpressionTypeNestedCleaned,
678  const typename ExtendedType<OtherDerived>::Type>
679  operator/(const DenseBase<OtherDerived>& other) const
680  {
681  EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
682  EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
683  EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
684  return m_matrix / extendedTo(other.derived());
685  }
686 
691  EIGEN_DEVICE_FUNC
693  const ExpressionTypeNestedCleaned,
694  const typename OppositeExtendedType<NormReturnType>::Type>
695  normalized() const { return m_matrix.cwiseQuotient(extendedToOpposite(this->norm())); }
696 
697 
701  EIGEN_DEVICE_FUNC void normalize() {
702  m_matrix = this->normalized();
703  }
704 
705  EIGEN_DEVICE_FUNC inline void reverseInPlace();
706 
708 
709  typedef Homogeneous<ExpressionType,Direction> HomogeneousReturnType;
710  EIGEN_DEVICE_FUNC
711  HomogeneousReturnType homogeneous() const;
712 
713  typedef typename ExpressionType::PlainObject CrossReturnType;
714  template<typename OtherDerived>
715  EIGEN_DEVICE_FUNC
716  const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;
717 
718  enum {
719  HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
720  : internal::traits<ExpressionType>::ColsAtCompileTime,
721  HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1
722  };
723  typedef Block<const ExpressionType,
724  Direction==Vertical ? int(HNormalized_SizeMinusOne)
725  : int(internal::traits<ExpressionType>::RowsAtCompileTime),
726  Direction==Horizontal ? int(HNormalized_SizeMinusOne)
727  : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
728  HNormalized_Block;
729  typedef Block<const ExpressionType,
730  Direction==Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
731  Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
732  HNormalized_Factors;
733  typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>,
734  const HNormalized_Block,
735  const Replicate<HNormalized_Factors,
736  Direction==Vertical ? HNormalized_SizeMinusOne : 1,
737  Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >
738  HNormalizedReturnType;
739 
740  EIGEN_DEVICE_FUNC
741  const HNormalizedReturnType hnormalized() const;
742 
743 # ifdef EIGEN_VECTORWISEOP_PLUGIN
744 # include EIGEN_VECTORWISEOP_PLUGIN
745 # endif
746 
747  protected:
748  Index redux_length() const
749  {
750  return Direction==Vertical ? m_matrix.rows() : m_matrix.cols();
751  }
752  ExpressionTypeNested m_matrix;
753 };
754 
755 //const colwise moved to DenseBase.h due to CUDA compiler bug
756 
757 
762 template<typename Derived>
763 EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::ColwiseReturnType
765 {
766  return ColwiseReturnType(derived());
767 }
768 
769 //const rowwise moved to DenseBase.h due to CUDA compiler bug
770 
771 
776 template<typename Derived>
777 EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::RowwiseReturnType
779 {
780  return RowwiseReturnType(derived());
781 }
782 
783 } // end namespace Eigen
784 
785 #endif // EIGEN_PARTIAL_REDUX_H
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:86
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:58
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
ConstColwiseReturnType colwise() const
Definition: DenseBase.h:551
ConstRowwiseReturnType rowwise() const
Definition: DenseBase.h:539
Derived & derived()
Definition: EigenBase.h:48
Expression of one (or a set of) homogeneous vector(s)
Definition: Homogeneous.h:64
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
Generic expression of a partially reduxed matrix.
Definition: VectorwiseOp.h:60
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:65
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:67
Pseudo expression providing broadcasting and partial reduction operations.
Definition: VectorwiseOp.h:188
const HypotNormReturnType hypotNorm() const
Definition: VectorwiseOp.h:469
const SquaredNormReturnType squaredNorm() const
Definition: VectorwiseOp.h:411
const ProdReturnType prod() const
Definition: VectorwiseOp.h:530
ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
Definition: VectorwiseOp.h:591
const_reverse_iterator crend() const
Definition: VectorwiseOp.h:323
CwiseBinaryOp< internal::scalar_product_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator*(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:664
Eigen::Index Index
Definition: VectorwiseOp.h:193
const BlueNormReturnType blueNorm() const
Definition: VectorwiseOp.h:447
const_iterator cend() const
Definition: VectorwiseOp.h:314
random_access_iterator_type const_iterator
Definition: VectorwiseOp.h:281
const CountReturnType count() const
Definition: VectorwiseOp.h:519
CwiseBinaryOp< internal::scalar_difference_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator-(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:650
const ReplicateReturnType replicate(Index factor) const
Definition: Replicate.h:136
const MaxCoeffReturnType maxCoeff() const
Definition: VectorwiseOp.h:396
ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
Definition: VectorwiseOp.h:601
const SumReturnType sum() const
Definition: VectorwiseOp.h:480
CwiseBinaryOp< internal::scalar_sum_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator+(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:637
ExpressionType & operator=(const DenseBase< OtherDerived > &other)
Definition: VectorwiseOp.h:580
const_iterator cbegin() const
Definition: VectorwiseOp.h:296
const MinCoeffReturnType minCoeff() const
Definition: VectorwiseOp.h:377
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > replicate(Index factor=Factor) const
Definition: VectorwiseOp.h:569
reverse_iterator rbegin()
Definition: VectorwiseOp.h:301
const AnyReturnType any() const
Definition: VectorwiseOp.h:506
const AllReturnType all() const
Definition: VectorwiseOp.h:497
iterator end()
Definition: VectorwiseOp.h:310
ExpressionType & operator/=(const DenseBase< OtherDerived > &other)
Definition: VectorwiseOp.h:623
random_access_iterator_type iterator
Definition: VectorwiseOp.h:279
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator/(const DenseBase< OtherDerived > &other) const
Definition: VectorwiseOp.h:679
const_reverse_iterator rbegin() const
Definition: VectorwiseOp.h:303
reverse_iterator rend()
Definition: VectorwiseOp.h:319
const LpNormReturnType< p >::Type lpNorm() const
Definition: VectorwiseOp.h:436
const MeanReturnType mean() const
Definition: VectorwiseOp.h:488
const_iterator begin() const
Definition: VectorwiseOp.h:294
ReverseReturnType reverse()
Definition: VectorwiseOp.h:550
void reverseInPlace()
Definition: Reverse.h:212
iterator begin()
Definition: VectorwiseOp.h:292
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized() const
Definition: VectorwiseOp.h:695
ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
Definition: VectorwiseOp.h:611
const_iterator end() const
Definition: VectorwiseOp.h:312
void normalize()
Definition: VectorwiseOp.h:701
const StableNormReturnType stableNorm() const
Definition: VectorwiseOp.h:458
const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
Definition: VectorwiseOp.h:338
const ConstReverseReturnType reverse() const
Definition: VectorwiseOp.h:542
const_reverse_iterator crbegin() const
Definition: VectorwiseOp.h:305
const NormReturnType norm() const
Definition: VectorwiseOp.h:423
const_reverse_iterator rend() const
Definition: VectorwiseOp.h:321
static const Eigen::internal::all_t all
Definition: IndexedViewHelper.h:189
const HNormalizedReturnType hnormalized() const
column or row-wise homogeneous normalization
Definition: Homogeneous.h:200
const CrossReturnType cross(const MatrixBase< OtherDerived > &other) const
Definition: OrthoMethods.h:113
HomogeneousReturnType homogeneous() const
Definition: Homogeneous.h:152
DirectionType
Definition: Constants.h:263
@ Horizontal
Definition: Constants.h:269
@ Vertical
Definition: Constants.h:266
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231