Eigen  5.0.1-dev+60122df6
 
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 <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// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
34
35template <typename MatrixType, typename MemberOp, int Direction>
37
38namespace internal {
39
40template <typename MatrixType, typename MemberOp, int Direction>
41struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> > : traits<MatrixType> {
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} // namespace internal
56
57template <typename MatrixType, typename MemberOp, int Direction>
58class PartialReduxExpr : public internal::dense_xpr_base<PartialReduxExpr<MatrixType, MemberOp, Direction> >::type,
59 internal::no_assignment_operator {
60 public:
61 typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;
62 EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
63
64 EIGEN_DEVICE_FUNC explicit PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
65 : m_matrix(mat), m_functor(func) {}
66
67 EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return (Direction == Vertical ? 1 : m_matrix.rows()); }
68 EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return (Direction == Horizontal ? 1 : m_matrix.cols()); }
69
70 EIGEN_DEVICE_FUNC typename MatrixType::Nested nestedExpression() const { return m_matrix; }
71
72 EIGEN_DEVICE_FUNC const MemberOp& functor() const { return m_functor; }
73
74 protected:
75 typename MatrixType::Nested m_matrix;
76 const MemberOp m_functor;
77};
78
79template <typename A, typename B>
80struct partial_redux_dummy_func;
81
82#define EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER, COST, VECTORIZABLE, BINARYOP) \
83 template <typename ResultType, typename Scalar> \
84 struct member_##MEMBER { \
85 typedef ResultType result_type; \
86 typedef BINARYOP<Scalar, Scalar> BinaryOp; \
87 template <int Size> \
88 struct Cost { \
89 enum { value = COST }; \
90 }; \
91 enum { Vectorizable = VECTORIZABLE }; \
92 template <typename XprType> \
93 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType operator()(const XprType& mat) const { \
94 return mat.MEMBER(); \
95 } \
96 BinaryOp binaryFunc() const { return BinaryOp(); } \
97 }
98
99#define EIGEN_MEMBER_FUNCTOR(MEMBER, COST) EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER, COST, 0, partial_redux_dummy_func)
100
101namespace internal {
102
103EIGEN_MEMBER_FUNCTOR(norm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
104EIGEN_MEMBER_FUNCTOR(stableNorm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
105EIGEN_MEMBER_FUNCTOR(blueNorm, (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost);
106EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size - 1) * functor_traits<scalar_hypot_op<Scalar> >::Cost);
107EIGEN_MEMBER_FUNCTOR(all, (Size - 1) * NumTraits<Scalar>::AddCost);
108EIGEN_MEMBER_FUNCTOR(any, (Size - 1) * NumTraits<Scalar>::AddCost);
109EIGEN_MEMBER_FUNCTOR(count, (Size - 1) * NumTraits<Scalar>::AddCost);
110
111EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(sum, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_sum_op);
112EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(minCoeff, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_min_op);
113EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(maxCoeff, (Size - 1) * NumTraits<Scalar>::AddCost, 1, internal::scalar_max_op);
114EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(prod, (Size - 1) * NumTraits<Scalar>::MulCost, 1, internal::scalar_product_op);
115
116template <int p, typename ResultType, typename Scalar>
117struct member_lpnorm {
118 typedef ResultType result_type;
119 enum { Vectorizable = 0 };
120 template <int Size>
121 struct Cost {
122 enum { value = (Size + 5) * NumTraits<Scalar>::MulCost + (Size - 1) * NumTraits<Scalar>::AddCost };
123 };
124 EIGEN_DEVICE_FUNC member_lpnorm() {}
125 template <typename XprType>
126 EIGEN_DEVICE_FUNC inline ResultType operator()(const XprType& mat) const {
127 return mat.template lpNorm<p>();
128 }
129};
130
131template <typename BinaryOpT, typename Scalar>
132struct member_redux {
133 typedef BinaryOpT BinaryOp;
134 typedef typename result_of<BinaryOp(const Scalar&, const Scalar&)>::type result_type;
135
136 enum { Vectorizable = functor_traits<BinaryOp>::PacketAccess };
137 template <int Size>
138 struct Cost {
139 enum { value = (Size - 1) * functor_traits<BinaryOp>::Cost };
140 };
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 }
146 const BinaryOp& binaryFunc() const { return m_functor; }
147 const BinaryOp m_functor;
148};
149
150template <typename Scalar>
151struct scalar_replace_zero_with_one_op {
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& x) const {
153 return numext::is_exactly_zero(x) ? Scalar(1) : x;
154 }
155 template <typename Packet>
156 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& x) const {
157 return pselect(pcmp_eq(x, pzero(x)), pset1<Packet>(Scalar(1)), x);
158 }
159};
160template <typename Scalar>
161struct functor_traits<scalar_replace_zero_with_one_op<Scalar>> {
162 enum { Cost = 1, PacketAccess = packet_traits<Scalar>::HasCmp };
163};
164
165} // namespace internal
166
204template <typename ExpressionType, int Direction>
205class VectorwiseOp {
206 public:
207 typedef typename ExpressionType::Scalar Scalar;
208 typedef typename ExpressionType::RealScalar RealScalar;
209 typedef internal::remove_all_t<ExpressionType> ExpressionTypeCleaned;
210
211 template <template <typename OutScalar, typename InputScalar> class Functor, typename ReturnScalar = Scalar>
212 struct ReturnType {
214 };
215
216 template <typename BinaryOp>
217 struct ReduxReturnType {
219 };
220
221 enum { isVertical = (Direction == Vertical) ? 1 : 0, isHorizontal = (Direction == Horizontal) ? 1 : 0 };
222
223 protected:
224 template <typename OtherDerived>
225 struct ExtendedType {
226 typedef Replicate<OtherDerived, isVertical ? 1 : ExpressionType::RowsAtCompileTime,
227 isHorizontal ? 1 : ExpressionType::ColsAtCompileTime>
228 Type;
229 };
230
233 template <typename OtherDerived>
234 EIGEN_DEVICE_FUNC typename ExtendedType<OtherDerived>::Type extendedTo(const DenseBase<OtherDerived>& other) const {
235 EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxColsAtCompileTime == 1),
236 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
237 EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxRowsAtCompileTime == 1),
238 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
239 return typename ExtendedType<OtherDerived>::Type(other.derived(), isVertical ? 1 : m_matrix.rows(),
240 isHorizontal ? 1 : m_matrix.cols());
241 }
242
243 template <typename OtherDerived>
244 struct OppositeExtendedType {
245 typedef Replicate<OtherDerived, isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,
246 isVertical ? 1 : ExpressionType::ColsAtCompileTime>
247 Type;
248 };
249
252 template <typename OtherDerived>
253 EIGEN_DEVICE_FUNC typename OppositeExtendedType<OtherDerived>::Type extendedToOpposite(
254 const DenseBase<OtherDerived>& other) const {
255 EIGEN_STATIC_ASSERT(internal::check_implication(isHorizontal, OtherDerived::MaxColsAtCompileTime == 1),
256 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
257 EIGEN_STATIC_ASSERT(internal::check_implication(isVertical, OtherDerived::MaxRowsAtCompileTime == 1),
258 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
259 return typename OppositeExtendedType<OtherDerived>::Type(other.derived(), isHorizontal ? 1 : m_matrix.rows(),
260 isVertical ? 1 : m_matrix.cols());
261 }
262
263 public:
264 EIGEN_DEVICE_FUNC explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
265
267 EIGEN_DEVICE_FUNC inline const ExpressionType& _expression() const { return m_matrix; }
268
269#ifdef EIGEN_PARSED_BY_DOXYGEN
273 random_access_iterator_type iterator;
275 random_access_iterator_type const_iterator;
276#else
277 typedef internal::subvector_stl_iterator<ExpressionType, DirectionType(Direction)> iterator;
278 typedef internal::subvector_stl_iterator<const ExpressionType, DirectionType(Direction)> const_iterator;
279 typedef internal::subvector_stl_reverse_iterator<ExpressionType, DirectionType(Direction)> reverse_iterator;
280 typedef internal::subvector_stl_reverse_iterator<const ExpressionType, DirectionType(Direction)>
281 const_reverse_iterator;
282#endif
283
287 iterator begin() { return iterator(m_matrix, 0); }
289 const_iterator begin() const { return const_iterator(m_matrix, 0); }
291 const_iterator cbegin() const { return const_iterator(m_matrix, 0); }
292
296 reverse_iterator rbegin() {
297 return reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
298 }
299
300 const_reverse_iterator rbegin() const {
301 return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
302 }
303
304 const_reverse_iterator crbegin() const {
305 return const_reverse_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>() - 1);
306 }
307
311 iterator end() { return iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
314 return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
315 }
316
318 return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>());
319 }
320
324 reverse_iterator rend() { return reverse_iterator(m_matrix, -1); }
326 const_reverse_iterator rend() const { return const_reverse_iterator(m_matrix, -1); }
328 const_reverse_iterator crend() const { return const_reverse_iterator(m_matrix, -1); }
329
340 template <typename BinaryOp>
341 EIGEN_DEVICE_FUNC const typename ReduxReturnType<BinaryOp>::Type redux(const BinaryOp& func = BinaryOp()) const {
342 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
343 return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp, Scalar>(func));
344 }
345
346 typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;
347 typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;
349 internal::member_sum<RealScalar, RealScalar>, Direction>
350 SquaredNormReturnType;
351 typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> NormReturnType;
352 typedef typename ReturnType<internal::member_blueNorm, RealScalar>::Type BlueNormReturnType;
353 typedef typename ReturnType<internal::member_stableNorm, RealScalar>::Type StableNormReturnType;
354 typedef typename ReturnType<internal::member_hypotNorm, RealScalar>::Type HypotNormReturnType;
355 typedef typename ReturnType<internal::member_sum>::Type SumReturnType;
356 typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(SumReturnType, Scalar, quotient) MeanReturnType;
357 typedef typename ReturnType<internal::member_all, bool>::Type AllReturnType;
358 typedef typename ReturnType<internal::member_any, bool>::Type AnyReturnType;
360 typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;
361 typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;
362 typedef Reverse<ExpressionType, Direction> ReverseReturnType;
363
364 template <int p>
365 struct LpNormReturnType {
367 };
368
381 EIGEN_DEVICE_FUNC const MinCoeffReturnType minCoeff() const {
382 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
383 return MinCoeffReturnType(_expression());
384 }
385
398 EIGEN_DEVICE_FUNC const MaxCoeffReturnType maxCoeff() const {
399 eigen_assert(redux_length() > 0 && "you are using an empty matrix");
400 return MaxCoeffReturnType(_expression());
401 }
402
411 EIGEN_DEVICE_FUNC const SquaredNormReturnType squaredNorm() const {
412 return SquaredNormReturnType(m_matrix.cwiseAbs2());
413 }
414
423 EIGEN_DEVICE_FUNC const NormReturnType norm() const { return NormReturnType(squaredNorm()); }
424
433 template <int p>
434 EIGEN_DEVICE_FUNC const typename LpNormReturnType<p>::Type lpNorm() const {
435 return typename LpNormReturnType<p>::Type(_expression());
436 }
437
444 EIGEN_DEVICE_FUNC const BlueNormReturnType blueNorm() const { return BlueNormReturnType(_expression()); }
445
452 EIGEN_DEVICE_FUNC const StableNormReturnType stableNorm() const { return StableNormReturnType(_expression()); }
453
460 EIGEN_DEVICE_FUNC const HypotNormReturnType hypotNorm() const { return HypotNormReturnType(_expression()); }
461
469 EIGEN_DEVICE_FUNC const SumReturnType sum() const { return SumReturnType(_expression()); }
470
475 EIGEN_DEVICE_FUNC const MeanReturnType mean() const {
476 return sum() / Scalar(Direction == Vertical ? m_matrix.rows() : m_matrix.cols());
477 }
478
484 EIGEN_DEVICE_FUNC const AllReturnType all() const { return AllReturnType(_expression()); }
485
491 EIGEN_DEVICE_FUNC const AnyReturnType any() const { return AnyReturnType(_expression()); }
492
502 EIGEN_DEVICE_FUNC const CountReturnType count() const { return CountReturnType(_expression()); }
503
510 * \sa DenseBase::prod() */
511 EIGEN_DEVICE_FUNC const ProdReturnType prod() const { return ProdReturnType(_expression()); }
512
519 * \sa DenseBase::reverse() */
520 EIGEN_DEVICE_FUNC const ConstReverseReturnType reverse() const { return ConstReverseReturnType(_expression()); }
521
526 EIGEN_DEVICE_FUNC ReverseReturnType reverse() { return ReverseReturnType(_expression()); }
527
528 typedef Replicate<ExpressionType, (isVertical ? Dynamic : 1), (isHorizontal ? Dynamic : 1)> ReplicateReturnType;
529 EIGEN_DEVICE_FUNC const ReplicateReturnType replicate(Index factor) const;
530
539 // NOTE implemented here because of sunstudio's compilation errors
540 // isVertical*Factor+isHorizontal instead of (isVertical?Factor:1) to handle CUDA bug with ternary operator
541 template <int Factor>
542 const Replicate<ExpressionType, isVertical * Factor + isHorizontal,
543 isHorizontal * Factor + isVertical> EIGEN_DEVICE_FUNC
544 replicate(Index factor = Factor) const {
546 _expression(), isVertical ? factor : 1, isHorizontal ? factor : 1);
547 }
548
550
552 template <typename OtherDerived>
553 EIGEN_DEVICE_FUNC ExpressionType& operator=(const DenseBase<OtherDerived>& other) {
554 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
555 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
556 // eigen_assert((m_matrix.isNull()) == (other.isNull())); FIXME
557 return m_matrix = extendedTo(other.derived());
558 }
559
561 template <typename OtherDerived>
562 EIGEN_DEVICE_FUNC ExpressionType& operator+=(const DenseBase<OtherDerived>& other) {
563 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
564 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
565 return m_matrix += extendedTo(other.derived());
566 }
567
569 template <typename OtherDerived>
570 EIGEN_DEVICE_FUNC ExpressionType& operator-=(const DenseBase<OtherDerived>& other) {
571 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
572 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
573 return m_matrix -= extendedTo(other.derived());
574 }
575
577 template <typename OtherDerived>
578 EIGEN_DEVICE_FUNC ExpressionType& operator*=(const DenseBase<OtherDerived>& other) {
579 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
580 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
581 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
582 m_matrix *= extendedTo(other.derived());
583 return m_matrix;
584 }
585
587 template <typename OtherDerived>
588 EIGEN_DEVICE_FUNC ExpressionType& operator/=(const DenseBase<OtherDerived>& other) {
589 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
590 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
591 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
592 m_matrix /= extendedTo(other.derived());
593 return m_matrix;
594 }
595
597 template <typename OtherDerived>
598 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
600 const typename ExtendedType<OtherDerived>::Type>
601 operator+(const DenseBase<OtherDerived>& other) const {
602 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
603 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
604 return m_matrix + extendedTo(other.derived());
605 }
606
608 template <typename OtherDerived>
610 const ExpressionTypeCleaned, const typename ExtendedType<OtherDerived>::Type>
611 operator-(const DenseBase<OtherDerived>& other) const {
612 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
613 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
614 return m_matrix - extendedTo(other.derived());
615 }
616
619 template <typename OtherDerived>
621 const ExpressionTypeCleaned, const typename ExtendedType<OtherDerived>::Type>
622 operator*(const DenseBase<OtherDerived>& other) const {
623 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
624 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
625 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
626 return m_matrix * extendedTo(other.derived());
627 }
628
631 template <typename OtherDerived>
633 const ExpressionTypeCleaned, const typename ExtendedType<OtherDerived>::Type>
634 operator/(const DenseBase<OtherDerived>& other) const {
635 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
636 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
637 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
638 return m_matrix / extendedTo(other.derived());
639 }
640
641 using Normalized_NonzeroNormType =
643 using NormalizedReturnType = CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const ExpressionTypeCleaned,
644 const typename OppositeExtendedType<Normalized_NonzeroNormType>::Type>;
645
654 EIGEN_DEVICE_FUNC NormalizedReturnType normalized() const {
655 return m_matrix.cwiseQuotient(extendedToOpposite(Normalized_NonzeroNormType(this->norm())));
656 }
657
664 EIGEN_DEVICE_FUNC void normalize() { m_matrix = this->normalized(); }
665
666 EIGEN_DEVICE_FUNC inline void reverseInPlace();
667
669
670 typedef Homogeneous<ExpressionType, Direction> HomogeneousReturnType;
671 EIGEN_DEVICE_FUNC HomogeneousReturnType homogeneous() const;
672
673 typedef typename ExpressionType::PlainObject CrossReturnType;
674 template <typename OtherDerived>
675 EIGEN_DEVICE_FUNC const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;
676
677 enum {
678 HNormalized_Size = Direction == Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
679 : internal::traits<ExpressionType>::ColsAtCompileTime,
680 HNormalized_SizeMinusOne = HNormalized_Size == Dynamic ? Dynamic : HNormalized_Size - 1
681 };
682 typedef Block<const ExpressionType,
683 Direction == Vertical ? int(HNormalized_SizeMinusOne)
684 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
685 Direction == Horizontal ? int(HNormalized_SizeMinusOne)
686 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
687 HNormalized_Block;
688 typedef Block<const ExpressionType,
689 Direction == Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
690 Direction == Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
691 HNormalized_Factors;
693 const HNormalized_Block,
694 const Replicate<HNormalized_Factors, Direction == Vertical ? HNormalized_SizeMinusOne : 1,
695 Direction == Horizontal ? HNormalized_SizeMinusOne : 1> >
696 HNormalizedReturnType;
697
698 EIGEN_DEVICE_FUNC const HNormalizedReturnType hnormalized() const;
699
700#ifdef EIGEN_VECTORWISEOP_PLUGIN
701#include EIGEN_VECTORWISEOP_PLUGIN
702#endif
703
704 protected:
705 EIGEN_DEVICE_FUNC Index redux_length() const { return Direction == Vertical ? m_matrix.rows() : m_matrix.cols(); }
706 ExpressionType& m_matrix;
707};
708
709// const colwise moved to DenseBase.h due to CUDA compiler bug
710
715template <typename Derived>
716EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::ColwiseReturnType DenseBase<Derived>::colwise() {
717 return ColwiseReturnType(derived());
718}
719
720// const rowwise moved to DenseBase.h due to CUDA compiler bug
721
726template <typename Derived>
727EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::RowwiseReturnType DenseBase<Derived>::rowwise() {
728 return RowwiseReturnType(derived());
729}
730
731} // end namespace Eigen
732
733#endif // EIGEN_PARTIAL_REDUX_H
Expression of a fixed-size or dynamic-size block.
Definition Block.h:110
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:518
ConstRowwiseReturnType rowwise() const
Definition DenseBase.h:508
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:59
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
const HypotNormReturnType hypotNorm() const
Definition VectorwiseOp.h:460
const SquaredNormReturnType squaredNorm() const
Definition VectorwiseOp.h:411
const Replicate< ExpressionType, isVertical *Factor+isHorizontal, isHorizontal *Factor+isVertical > replicate(Index factor=Factor) const
Definition VectorwiseOp.h:544
const ProdReturnType prod() const
Definition VectorwiseOp.h:511
NormalizedReturnType normalized() const
Definition VectorwiseOp.h:654
const_reverse_iterator crend() const
Definition VectorwiseOp.h:328
ExpressionType & operator-=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:570
CwiseBinaryOp< internal::scalar_difference_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeCleaned, const typename ExtendedType< OtherDerived >::Type > operator-(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:611
const BlueNormReturnType blueNorm() const
Definition VectorwiseOp.h:444
ExpressionType & operator/=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:588
const_iterator cend() const
Definition VectorwiseOp.h:317
random_access_iterator_type const_iterator
Definition VectorwiseOp.h:275
CwiseBinaryOp< internal::scalar_product_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeCleaned, const typename ExtendedType< OtherDerived >::Type > operator*(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:622
const CountReturnType count() const
Definition VectorwiseOp.h:502
const ReplicateReturnType replicate(Index factor) const
Definition Replicate.h:123
const MaxCoeffReturnType maxCoeff() const
Definition VectorwiseOp.h:398
const SumReturnType sum() const
Definition VectorwiseOp.h:469
ExpressionType & operator*=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:578
const_iterator cbegin() const
Definition VectorwiseOp.h:291
const MinCoeffReturnType minCoeff() const
Definition VectorwiseOp.h:381
reverse_iterator rbegin()
Definition VectorwiseOp.h:296
const AnyReturnType any() const
Definition VectorwiseOp.h:491
const AllReturnType all() const
Definition VectorwiseOp.h:484
iterator end()
Definition VectorwiseOp.h:311
random_access_iterator_type iterator
Definition VectorwiseOp.h:273
const_reverse_iterator rbegin() const
Definition VectorwiseOp.h:300
reverse_iterator rend()
Definition VectorwiseOp.h:324
const MeanReturnType mean() const
Definition VectorwiseOp.h:475
const_iterator begin() const
Definition VectorwiseOp.h:289
ExpressionType & operator=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:553
ReverseReturnType reverse()
Definition VectorwiseOp.h:526
void reverseInPlace()
Definition Reverse.h:196
iterator begin()
Definition VectorwiseOp.h:287
ExpressionType & operator+=(const DenseBase< OtherDerived > &other)
Definition VectorwiseOp.h:562
CwiseBinaryOp< internal::scalar_sum_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeCleaned, const typename ExtendedType< OtherDerived >::Type > operator+(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:601
const_iterator end() const
Definition VectorwiseOp.h:313
void normalize()
Definition VectorwiseOp.h:664
const StableNormReturnType stableNorm() const
Definition VectorwiseOp.h:452
const LpNormReturnType< p >::Type lpNorm() const
Definition VectorwiseOp.h:434
CwiseBinaryOp< internal::scalar_quotient_op< Scalar, typename OtherDerived::Scalar >, const ExpressionTypeCleaned, const typename ExtendedType< OtherDerived >::Type > operator/(const DenseBase< OtherDerived > &other) const
Definition VectorwiseOp.h:634
const ConstReverseReturnType reverse() const
Definition VectorwiseOp.h:520
const_reverse_iterator crbegin() const
Definition VectorwiseOp.h:304
const NormReturnType norm() const
Definition VectorwiseOp.h:423
const ReduxReturnType< BinaryOp >::Type redux(const BinaryOp &func=BinaryOp()) const
Definition VectorwiseOp.h:341
const_reverse_iterator rend() const
Definition VectorwiseOp.h:326
const HNormalizedReturnType hnormalized() const
column or row-wise homogeneous normalization
Definition Homogeneous.h:189
const CrossReturnType cross(const MatrixBase< OtherDerived > &other) const
Definition OrthoMethods.h:149
HomogeneousReturnType homogeneous() const
Definition Homogeneous.h:141
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 B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25