Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
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 <[email protected]>
5// Copyright (C) 2006-2008 Benoit Jacob <[email protected]>
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// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
35template <typename MatrixType, typename MemberOp, int Direction>
36class PartialReduxExpr;
37
38namespace internal {
39template <typename MatrixType, typename MemberOp, int Direction>
40struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > : traits<MatrixType> {
41 typedef typename MemberOp::result_type Scalar;
42 typedef typename traits<MatrixType>::StorageKind StorageKind;
43 typedef typename traits<MatrixType>::XprKind XprKind;
44 typedef typename MatrixType::Scalar InputScalar;
45 enum {
46 RowsAtCompileTime = Direction == Vertical ? 1 : MatrixType::RowsAtCompileTime,
47 ColsAtCompileTime = Direction == Horizontal ? 1 : MatrixType::ColsAtCompileTime,
48 MaxRowsAtCompileTime = Direction == Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
49 MaxColsAtCompileTime = Direction == Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
50 Flags = RowsAtCompileTime == 1 ? RowMajorBit : 0,
51 TraversalSize = Direction == Vertical ? MatrixType::RowsAtCompileTime : MatrixType::ColsAtCompileTime
52 };
53};
54} // namespace internal
55
56template <typename MatrixType, typename MemberOp, int Direction>
57class PartialReduxExpr : public internal::dense_xpr_base<PartialReduxExpr<MatrixType, MemberOp, Direction> >::type,
58 internal::no_assignment_operator {
59 public:
60 typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;
61 EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
62
63 EIGEN_DEVICE_FUNC explicit PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
64 : m_matrix(mat), m_functor(func) {}
65
66 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT {
67 return (Direction == Vertical ? 1 : m_matrix.rows());
68 }
69 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT {
70 return (Direction == Horizontal ? 1 : m_matrix.cols());
71 }
72
73 EIGEN_DEVICE_FUNC typename MatrixType::Nested nestedExpression() const { return m_matrix; }
74
75 EIGEN_DEVICE_FUNC const MemberOp& functor() const { return m_functor; }
76
77 protected:
78 typename MatrixType::Nested m_matrix;
79 const MemberOp m_functor;
80};
81
82template <typename A, typename B>
83struct partial_redux_dummy_func;
84
85#define EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER, COST, VECTORIZABLE, BINARYOP) \
86 template <typename ResultType, typename Scalar> \
87 struct member_##MEMBER { \
88 typedef ResultType result_type; \
89 typedef BINARYOP<Scalar, Scalar> BinaryOp; \
90 template <int Size> \
91 struct Cost { \
92 enum { value = COST }; \
93 }; \
94 enum { Vectorizable = VECTORIZABLE }; \
95 template <typename XprType> \
96 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType operator()(const XprType& mat) const { \
97 return mat.MEMBER(); \
98 } \
99 BinaryOp binaryFunc() const { return BinaryOp(); } \
100 }
101
102#define EIGEN_MEMBER_FUNCTOR(MEMBER, COST) EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER, COST, 0, partial_redux_dummy_func)
103
104namespace internal {
105
106EIGEN_MEMBER_FUNCTOR(norm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
107EIGEN_MEMBER_FUNCTOR(stableNorm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
108EIGEN_MEMBER_FUNCTOR(blueNorm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
109EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size - 1) * functor_traits<scalar_hypot_op<Scalar> >::Cost);
110EIGEN_MEMBER_FUNCTOR(all, (Size - 1) * NumTraits<Scalar>::AddCost);
111EIGEN_MEMBER_FUNCTOR(any, (Size - 1) * NumTraits<Scalar>::AddCost);
112EIGEN_MEMBER_FUNCTOR(count, (Size - 1) * NumTraits<Scalar>::AddCost);
113
114EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(sum, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_sum_op);
115EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(minCoeff, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_min_op);
116EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(maxCoeff, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_max_op);
117EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(prod, (Size - 1) * NumTraits<Scalar>::MulCost, 1, internal::scalar_product_op);
118
119template <int p, typename ResultType, typename Scalar>
120struct member_lpnorm {
121 typedef ResultType result_type;
122 enum { Vectorizable = 0 };
123 template <int Size>
124 struct Cost {
125 enum { value = (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost };
126 };
127 EIGEN_DEVICE_FUNC member_lpnorm() {}
128 template <typename XprType>
129 EIGEN_DEVICE_FUNC inline ResultType operator()(const XprType& mat) const {
130 return mat.template lpNorm<p>();
131 }
132};
133
134template <typename BinaryOpT, typename Scalar>
135struct member_redux {
136 typedef BinaryOpT BinaryOp;
137 typedef typename result_of<BinaryOp(const Scalar&, const Scalar&)>::type result_type;
138
139 enum { Vectorizable = functor_traits<BinaryOp>::PacketAccess };
140 template <int Size>
141 struct Cost {
142 enum { value = (Size - 1) * functor_traits<BinaryOp>::Cost };
143 };
144 EIGEN_DEVICE_FUNC explicit member_redux(const BinaryOp func) : m_functor(func) {}
145 template <typename Derived>
146 EIGEN_DEVICE_FUNC inline result_type operator()(const DenseBase<Derived>& mat) const {
147 return mat.redux(m_functor);
148 }
149 const BinaryOp& binaryFunc() const { return m_functor; }
150 const BinaryOp m_functor;
151};
152} // namespace internal
153
191template <typename ExpressionType, int Direction>
193 public:
194 typedef typename ExpressionType::Scalar Scalar;
195 typedef typename ExpressionType::RealScalar RealScalar;
197 typedef typename internal::ref_selector<ExpressionType>::non_const_type ExpressionTypeNested;
198 typedef internal::remove_all_t<ExpressionTypeNested> ExpressionTypeNestedCleaned;
199
200 template <template <typename OutScalar, typename InputScalar> class Functor, typename ReturnScalar = Scalar>
201 struct ReturnType {
203 };
204
205 template <typename BinaryOp>
206 struct ReduxReturnType {
208 };
209
210 enum { isVertical = (Direction == Vertical) ? 1 : 0, isHorizontal = (Direction == Horizontal) ? 1 : 0 };
211
212 protected:
213 template <typename OtherDerived>
214 struct ExtendedType {
215 typedef Replicate<OtherDerived, isVertical ? 1 : ExpressionType::RowsAtCompileTime,
216 isHorizontal ? 1 : ExpressionType::ColsAtCompileTime>
217 Type;
218 };
219
222 template <typename OtherDerived>
223 EIGEN_DEVICE_FUNC typename ExtendedType<OtherDerived>::Type extendedTo(const DenseBase<OtherDerived>& other) const {
224 EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxColsAtCompileTime == 1),
225 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
226 EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxRowsAtCompileTime == 1),
227 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
228 return typename ExtendedType<OtherDerived>::Type(other.derived(), isVertical ? 1 : m_matrix.rows(),
229 isHorizontal ? 1 : m_matrix.cols());
230 }
231
232 template <typename OtherDerived>
233 struct OppositeExtendedType {
234 typedef Replicate<OtherDerived, isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,
235 isVertical ? 1 : ExpressionType::ColsAtCompileTime>
236 Type;
237 };
238
241 template <typename OtherDerived>
242 EIGEN_DEVICE_FUNC typename OppositeExtendedType<OtherDerived>::Type extendedToOpposite(
243 const DenseBase<OtherDerived>& other) const {
244 EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxColsAtCompileTime == 1),
245 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
246 EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxRowsAtCompileTime == 1),
247 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
248 return typename OppositeExtendedType<OtherDerived>::Type(other.derived(), isHorizontal ? 1 : m_matrix.rows(),
249 isVertical ? 1 : m_matrix.cols());
250 }
251
252 public:
253 EIGEN_DEVICE_FUNC explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
254
256 EIGEN_DEVICE_FUNC inline const ExpressionType& _expression() const { return m_matrix; }
257
258#ifdef EIGEN_PARSED_BY_DOXYGEN
262 random_access_iterator_type iterator;
264 random_access_iterator_type const_iterator;
265#else
266 typedef internal::subvector_stl_iterator<ExpressionType, DirectionType(Direction)> iterator;
267 typedef internal::subvector_stl_iterator<const ExpressionType, DirectionType(Direction)> const_iterator;
268 typedef internal::subvector_stl_reverse_iterator<ExpressionType, DirectionType(Direction)> reverse_iterator;
269 typedef internal::subvector_stl_reverse_iterator<const ExpressionType, DirectionType(Direction)>
270 const_reverse_iterator;
271#endif
272
276 iterator begin() { return iterator(m_matrix, 0); }
278 const_iterator begin() const { return const_iterator(m_matrix, 0); }
280 const_iterator cbegin() const { return const_iterator(m_matrix, 0); }
281
285 reverse_iterator rbegin() {
286 return reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
287 }
289 const_reverse_iterator rbegin() const {
290 return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
291 }
293 const_reverse_iterator crbegin() const {
294 return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
295 }
296
300 iterator end() { return iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
303 return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
304 }
307 return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
308 }
309
313 reverse_iterator rend() { return reverse_iterator(m_matrix, -1); }
315 const_reverse_iterator rend() const { return const_reverse_iterator(m_matrix, -1); }
317 const_reverse_iterator crend() const { return const_reverse_iterator(m_matrix, -1); }
318
329 template <typename BinaryOp>
330 EIGEN_DEVICE_FUNC const typename ReduxReturnType<BinaryOp>::Type redux(const BinaryOp& func = BinaryOp()) const {
331 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
332 return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp, Scalar>(func));
333 }
334
335 typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;
336 typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;
337 typedef PartialReduxExpr<const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const ExpressionTypeNestedCleaned>,
338 internal::member_sum<RealScalar, RealScalar>, Direction>
339 SquaredNormReturnType;
340 typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> NormReturnType;
341 typedef typename ReturnType<internal::member_blueNorm, RealScalar>::Type BlueNormReturnType;
342 typedef typename ReturnType<internal::member_stableNorm, RealScalar>::Type StableNormReturnType;
343 typedef typename ReturnType<internal::member_hypotNorm, RealScalar>::Type HypotNormReturnType;
344 typedef typename ReturnType<internal::member_sum>::Type SumReturnType;
345 typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(SumReturnType, Scalar, quotient) MeanReturnType;
346 typedef typename ReturnType<internal::member_all, bool>::Type AllReturnType;
347 typedef typename ReturnType<internal::member_any, bool>::Type AnyReturnType;
349 typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;
350 typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;
351 typedef Reverse<ExpressionType, Direction> ReverseReturnType;
352
353 template <int p>
354 struct LpNormReturnType {
356 };
357
370 EIGEN_DEVICE_FUNC const MinCoeffReturnType minCoeff() const {
371 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
372 return MinCoeffReturnType(_expression());
373 }
374
387 EIGEN_DEVICE_FUNC const MaxCoeffReturnType maxCoeff() const {
388 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
389 return MaxCoeffReturnType(_expression());
390 }
391
400 EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm() const {
401 return SquaredNormReturnType(m_matrix.cwiseAbs2());
402 }
403
412 EIGEN_DEVICE_FUNC const NormReturnType norm() const { return NormReturnType(squaredNorm()); }
413
422 template <int p>
423 EIGEN_DEVICE_FUNC const typename LpNormReturnType<p>::Type lpNorm() const {
424 return typename LpNormReturnType<p>::Type(_expression());
425 }
426
433 EIGEN_DEVICE_FUNC const BlueNormReturnType blueNorm() const { return BlueNormReturnType(_expression()); }
434
441 EIGEN_DEVICE_FUNC const StableNormReturnType stableNorm() const { return StableNormReturnType(_expression()); }
442
449 EIGEN_DEVICE_FUNC const HypotNormReturnType hypotNorm() const { return HypotNormReturnType(_expression()); }
450
458 EIGEN_DEVICE_FUNC const SumReturnType sum() const { return SumReturnType(_expression()); }
459
464 EIGEN_DEVICE_FUNC const MeanReturnType mean() const {
465 return sum() / Scalar(Direction == Vertical ? m_matrix.rows() : m_matrix.cols());
466 }
467
473 EIGEN_DEVICE_FUNC const AllReturnType all() const { return AllReturnType(_expression()); }
474
480 EIGEN_DEVICE_FUNC const AnyReturnType any() const { return AnyReturnType(_expression()); }
481
491 EIGEN_DEVICE_FUNC const CountReturnType count() const { return CountReturnType(_expression()); }
492
500 EIGEN_DEVICE_FUNC const ProdReturnType prod() const { return ProdReturnType(_expression()); }
501
509 EIGEN_DEVICE_FUNC const ConstReverseReturnType reverse() const { return ConstReverseReturnType(_expression()); }
510
515 EIGEN_DEVICE_FUNC ReverseReturnType reverse() { return ReverseReturnType(_expression()); }
516
517 typedef Replicate<ExpressionType, (isVertical ? Dynamic : 1), (isHorizontal ? Dynamic : 1)> ReplicateReturnType;
518 EIGEN_DEVICE_FUNC const ReplicateReturnType replicate(Index factor) const;
519
528 // NOTE implemented here because of sunstudio's compilation errors
529 // isVertical*Factor+isHorizontal instead of (isVertical?Factor:1) to handle CUDA bug with ternary operator
530 template <int Factor>
531 const Replicate<ExpressionType, isVertical * Factor + isHorizontal,
532 isHorizontal * Factor + isVertical> EIGEN_DEVICE_FUNC
533 replicate(Index factor = Factor) const {
535 _expression(), isVertical ? factor : 1, isHorizontal ? factor : 1);
536 }
537
539
541 template <typename OtherDerived>
542 EIGEN_DEVICE_FUNC ExpressionType& operator=(const DenseBase<OtherDerived>& other) {
543 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
544 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
545 // eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
546 return m_matrix = extendedTo(other.derived());
547 }
548
550 template <typename OtherDerived>
551 EIGEN_DEVICE_FUNC ExpressionType& operator+=(const DenseBase<OtherDerived>& other) {
552 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
553 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
554 return m_matrix += extendedTo(other.derived());
555 }
556
558 template <typename OtherDerived>
559 EIGEN_DEVICE_FUNC ExpressionType& operator-=(const DenseBase<OtherDerived>& other) {
560 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
561 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
562 return m_matrix -= extendedTo(other.derived());
563 }
564
566 template <typename OtherDerived>
567 EIGEN_DEVICE_FUNC ExpressionType& operator*=(const DenseBase<OtherDerived>& other) {
568 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
569 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
570 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
571 m_matrix *= extendedTo(other.derived());
572 return m_matrix;
573 }
574
576 template <typename OtherDerived>
577 EIGEN_DEVICE_FUNC ExpressionType& operator/=(const DenseBase<OtherDerived>& other) {
578 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
579 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
580 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
581 m_matrix /= extendedTo(other.derived());
582 return m_matrix;
583 }
584
586 template <typename OtherDerived>
587 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
589 const typename ExtendedType<OtherDerived>::Type>
590 operator+(const DenseBase<OtherDerived>& other) const {
591 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
592 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
593 return m_matrix + extendedTo(other.derived());
594 }
595
597 template <typename OtherDerived>
599 const ExpressionTypeNestedCleaned, const typename ExtendedType<OtherDerived>::Type>
600 operator-(const DenseBase<OtherDerived>& other) const {
601 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
602 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
603 return m_matrix - extendedTo(other.derived());
604 }
605
608 template <typename OtherDerived>
609 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
610 CwiseBinaryOp<internal::scalar_product_op<Scalar>, const ExpressionTypeNestedCleaned,
611 const typename ExtendedType<OtherDerived>::Type> EIGEN_DEVICE_FUNC
612 operator*(const DenseBase<OtherDerived>& other) const {
613 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
614 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
615 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
616 return m_matrix * extendedTo(other.derived());
617 }
618
621 template <typename OtherDerived>
622 EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned,
623 const typename ExtendedType<OtherDerived>::Type>
624 operator/(const DenseBase<OtherDerived>& other) const {
625 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
626 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
627 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
628 return m_matrix / extendedTo(other.derived());
629 }
630
635 EIGEN_DEVICE_FUNC CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeNestedCleaned,
636 const typename OppositeExtendedType<NormReturnType>::Type>
637 normalized() const {
638 return m_matrix.cwiseQuotient(extendedToOpposite(this->norm()));
639 }
640
644 EIGEN_DEVICE_FUNC void normalize() { m_matrix = this->normalized(); }
645
646 EIGEN_DEVICE_FUNC inline void reverseInPlace();
647
649
650 typedef Homogeneous<ExpressionType, Direction> HomogeneousReturnType;
651 EIGEN_DEVICE_FUNC HomogeneousReturnType homogeneous() const;
652
653 typedef typename ExpressionType::PlainObject CrossReturnType;
654 template <typename OtherDerived>
655 EIGEN_DEVICE_FUNC const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;
656
657 enum {
658 HNormalized_Size = Direction == Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
659 : internal::traits<ExpressionType>::ColsAtCompileTime,
660 HNormalized_SizeMinusOne = HNormalized_Size == Dynamic ? Dynamic : HNormalized_Size - 1
661 };
662 typedef Block<const ExpressionType,
663 Direction == Vertical ? int(HNormalized_SizeMinusOne)
664 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
665 Direction == Horizontal ? int(HNormalized_SizeMinusOne)
666 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
667 HNormalized_Block;
668 typedef Block<const ExpressionType,
669 Direction == Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
670 Direction == Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
671 HNormalized_Factors;
672 typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>,
673 const HNormalized_Block,
674 const Replicate<HNormalized_Factors, Direction == Vertical ? HNormalized_SizeMinusOne : 1,
675 Direction == Horizontal ? HNormalized_SizeMinusOne : 1> >
676 HNormalizedReturnType;
677
678 EIGEN_DEVICE_FUNC const HNormalizedReturnType hnormalized() const;
679
680#ifdef EIGEN_VECTORWISEOP_PLUGIN
681#include EIGEN_VECTORWISEOP_PLUGIN
682#endif
683
684 protected:
685 EIGEN_DEVICE_FUNC Index redux_length() const { return Direction == Vertical ? m_matrix.rows() : m_matrix.cols(); }
686 ExpressionTypeNested m_matrix;
687};
688
689// const colwise moved to DenseBase.h due to CUDA compiler bug
690
695template <typename Derived>
697 return ColwiseReturnType(derived());
698}
699
700// const rowwise moved to DenseBase.h due to CUDA compiler bug
701
706template <typename Derived>
708 return RowwiseReturnType(derived());
709}
710
711} // end namespace Eigen
712
713#endif // EIGEN_PARTIAL_REDUX_H
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:79
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition CwiseUnaryOp.h:53
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
ConstColwiseReturnType colwise() const
Definition DenseBase.h:511
ConstRowwiseReturnType rowwise() const
Definition DenseBase.h:501
Derived & derived()
Definition EigenBase.h:49
Expression of one (or a set of) homogeneous vector(s)
Definition Homogeneous.h:62
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
Generic expression of a partially reduxed matrix.
Definition VectorwiseOp.h:58
Expression of the multiple replication of a matrix or vector.
Definition Replicate.h:64
Expression of the reverse of a vector or matrix.
Definition Reverse.h:65
Pseudo expression providing broadcasting and partial reduction operations.
Definition VectorwiseOp.h:192
const HypotNormReturnType hypotNorm() const
Definition VectorwiseOp.h:449
const SquaredNormReturnType squaredNorm() const
Definition VectorwiseOp.h:400
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > replicate(Index factor=Factor) const
Definition VectorwiseOp.h:533
const ProdReturnType prod() const
Definition VectorwiseOp.h:500
CwiseBinaryOp< internal::scalar_product_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator*(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:612
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:600
const_reverse_iterator crend() const
Definition VectorwiseOp.h:317
ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:559
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:590
Eigen::Index Index
Definition VectorwiseOp.h:196
const BlueNormReturnType blueNorm() const
Definition VectorwiseOp.h:433
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename OppositeExtendedType< NormReturnType >::Type > normalized() const
Definition VectorwiseOp.h:637
ExpressionType & operator/=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:577
const_iterator cend() const
Definition VectorwiseOp.h:306
random_access_iterator_type const_iterator
Definition VectorwiseOp.h:264
const CountReturnType count() const
Definition VectorwiseOp.h:491
const ReplicateReturnType replicate(Index factor) const
Definition Replicate.h:123
const MaxCoeffReturnType maxCoeff() const
Definition VectorwiseOp.h:387
const SumReturnType sum() const
Definition VectorwiseOp.h:458
ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:567
const_iterator cbegin() const
Definition VectorwiseOp.h:280
const MinCoeffReturnType minCoeff() const
Definition VectorwiseOp.h:370
reverse_iterator rbegin()
Definition VectorwiseOp.h:285
const AnyReturnType any() const
Definition VectorwiseOp.h:480
CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const ExpressionTypeNestedCleaned, const typename ExtendedType< OtherDerived >::Type > operator/(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:624
const AllReturnType all() const
Definition VectorwiseOp.h:473
iterator end()
Definition VectorwiseOp.h:300
random_access_iterator_type iterator
Definition VectorwiseOp.h:262
const_reverse_iterator rbegin() const
Definition VectorwiseOp.h:289
reverse_iterator rend()
Definition VectorwiseOp.h:313
const MeanReturnType mean() const
Definition VectorwiseOp.h:464
const_iterator begin() const
Definition VectorwiseOp.h:278
ExpressionType & operator=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:542
ReverseReturnType reverse()
Definition VectorwiseOp.h:515
void reverseInPlace()
Definition Reverse.h:190
iterator begin()
Definition VectorwiseOp.h:276
ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:551
const_iterator end() const
Definition VectorwiseOp.h:302
void normalize()
Definition VectorwiseOp.h:644
const StableNormReturnType stableNorm() const
Definition VectorwiseOp.h:441
const LpNormReturnType< p >::Type lpNorm() const
Definition VectorwiseOp.h:423
const ConstReverseReturnType reverse() const
Definition VectorwiseOp.h:509
const_reverse_iterator crbegin() const
Definition VectorwiseOp.h:293
const NormReturnType norm() const
Definition VectorwiseOp.h:412
const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
Definition VectorwiseOp.h:330
const_reverse_iterator rend() const
Definition VectorwiseOp.h:315
const HNormalizedReturnType hnormalized() const
column or row-wise homogeneous normalization
Definition Homogeneous.h:191
HomogeneousReturnType homogeneous() const
Definition Homogeneous.h:143
DirectionType
Definition Constants.h:263
@ Horizontal
Definition Constants.h:269
@ Vertical
Definition Constants.h:266
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
const int Dynamic
Definition Constants.h:25
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition Meta.h:523