File indexing completed on 2025-01-18 09:56:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef EIGEN_PARTIAL_REDUX_H
0012 #define EIGEN_PARTIAL_REDUX_H
0013
0014 namespace Eigen {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 template< typename MatrixType, typename MemberOp, int Direction>
0033 class PartialReduxExpr;
0034
0035 namespace internal {
0036 template<typename MatrixType, typename MemberOp, int Direction>
0037 struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
0038 : traits<MatrixType>
0039 {
0040 typedef typename MemberOp::result_type Scalar;
0041 typedef typename traits<MatrixType>::StorageKind StorageKind;
0042 typedef typename traits<MatrixType>::XprKind XprKind;
0043 typedef typename MatrixType::Scalar InputScalar;
0044 enum {
0045 RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime,
0046 ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
0047 MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
0048 MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
0049 Flags = RowsAtCompileTime == 1 ? RowMajorBit : 0,
0050 TraversalSize = Direction==Vertical ? MatrixType::RowsAtCompileTime : MatrixType::ColsAtCompileTime
0051 };
0052 };
0053 }
0054
0055 template< typename MatrixType, typename MemberOp, int Direction>
0056 class PartialReduxExpr : public internal::dense_xpr_base< PartialReduxExpr<MatrixType, MemberOp, Direction> >::type,
0057 internal::no_assignment_operator
0058 {
0059 public:
0060
0061 typedef typename internal::dense_xpr_base<PartialReduxExpr>::type Base;
0062 EIGEN_DENSE_PUBLIC_INTERFACE(PartialReduxExpr)
0063
0064 EIGEN_DEVICE_FUNC
0065 explicit PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
0066 : m_matrix(mat), m_functor(func) {}
0067
0068 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0069 Index rows() const EIGEN_NOEXCEPT { return (Direction==Vertical ? 1 : m_matrix.rows()); }
0070 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0071 Index cols() const EIGEN_NOEXCEPT { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
0072
0073 EIGEN_DEVICE_FUNC
0074 typename MatrixType::Nested nestedExpression() const { return m_matrix; }
0075
0076 EIGEN_DEVICE_FUNC
0077 const MemberOp& functor() const { return m_functor; }
0078
0079 protected:
0080 typename MatrixType::Nested m_matrix;
0081 const MemberOp m_functor;
0082 };
0083
0084 template<typename A,typename B> struct partial_redux_dummy_func;
0085
0086 #define EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER,COST,VECTORIZABLE,BINARYOP) \
0087 template <typename ResultType,typename Scalar> \
0088 struct member_##MEMBER { \
0089 EIGEN_EMPTY_STRUCT_CTOR(member_##MEMBER) \
0090 typedef ResultType result_type; \
0091 typedef BINARYOP<Scalar,Scalar> BinaryOp; \
0092 template<int Size> struct Cost { enum { value = COST }; }; \
0093 enum { Vectorizable = VECTORIZABLE }; \
0094 template<typename XprType> \
0095 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE \
0096 ResultType operator()(const XprType& mat) const \
0097 { return mat.MEMBER(); } \
0098 BinaryOp binaryFunc() const { return BinaryOp(); } \
0099 }
0100
0101 #define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
0102 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(MEMBER,COST,0,partial_redux_dummy_func)
0103
0104 namespace internal {
0105
0106 EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
0107 EIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
0108 EIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
0109 EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * functor_traits<scalar_hypot_op<Scalar> >::Cost );
0110 EIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);
0111 EIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);
0112 EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);
0113
0114 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_sum_op);
0115 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_min_op);
0116 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost, 1, internal::scalar_max_op);
0117 EIGEN_MAKE_PARTIAL_REDUX_FUNCTOR(prod, (Size-1)*NumTraits<Scalar>::MulCost, 1, internal::scalar_product_op);
0118
0119 template <int p, typename ResultType,typename Scalar>
0120 struct member_lpnorm {
0121 typedef ResultType result_type;
0122 enum { Vectorizable = 0 };
0123 template<int Size> struct Cost
0124 { enum { value = (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost }; };
0125 EIGEN_DEVICE_FUNC member_lpnorm() {}
0126 template<typename XprType>
0127 EIGEN_DEVICE_FUNC inline ResultType operator()(const XprType& mat) const
0128 { return mat.template lpNorm<p>(); }
0129 };
0130
0131 template <typename BinaryOpT, typename Scalar>
0132 struct member_redux {
0133 typedef BinaryOpT BinaryOp;
0134 typedef typename result_of<
0135 BinaryOp(const Scalar&,const Scalar&)
0136 >::type result_type;
0137
0138 enum { Vectorizable = functor_traits<BinaryOp>::PacketAccess };
0139 template<int Size> struct Cost { enum { value = (Size-1) * functor_traits<BinaryOp>::Cost }; };
0140 EIGEN_DEVICE_FUNC explicit member_redux(const BinaryOp func) : m_functor(func) {}
0141 template<typename Derived>
0142 EIGEN_DEVICE_FUNC inline result_type operator()(const DenseBase<Derived>& mat) const
0143 { return mat.redux(m_functor); }
0144 const BinaryOp& binaryFunc() const { return m_functor; }
0145 const BinaryOp m_functor;
0146 };
0147 }
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 template<typename ExpressionType, int Direction> class VectorwiseOp
0187 {
0188 public:
0189
0190 typedef typename ExpressionType::Scalar Scalar;
0191 typedef typename ExpressionType::RealScalar RealScalar;
0192 typedef Eigen::Index Index;
0193 typedef typename internal::ref_selector<ExpressionType>::non_const_type ExpressionTypeNested;
0194 typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned;
0195
0196 template<template<typename OutScalar,typename InputScalar> class Functor,
0197 typename ReturnScalar=Scalar> struct ReturnType
0198 {
0199 typedef PartialReduxExpr<ExpressionType,
0200 Functor<ReturnScalar,Scalar>,
0201 Direction
0202 > Type;
0203 };
0204
0205 template<typename BinaryOp> struct ReduxReturnType
0206 {
0207 typedef PartialReduxExpr<ExpressionType,
0208 internal::member_redux<BinaryOp,Scalar>,
0209 Direction
0210 > Type;
0211 };
0212
0213 enum {
0214 isVertical = (Direction==Vertical) ? 1 : 0,
0215 isHorizontal = (Direction==Horizontal) ? 1 : 0
0216 };
0217
0218 protected:
0219
0220 template<typename OtherDerived> struct ExtendedType {
0221 typedef Replicate<OtherDerived,
0222 isVertical ? 1 : ExpressionType::RowsAtCompileTime,
0223 isHorizontal ? 1 : ExpressionType::ColsAtCompileTime> Type;
0224 };
0225
0226
0227
0228 template<typename OtherDerived>
0229 EIGEN_DEVICE_FUNC
0230 typename ExtendedType<OtherDerived>::Type
0231 extendedTo(const DenseBase<OtherDerived>& other) const
0232 {
0233 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isVertical, OtherDerived::MaxColsAtCompileTime==1),
0234 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
0235 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isHorizontal, OtherDerived::MaxRowsAtCompileTime==1),
0236 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
0237 return typename ExtendedType<OtherDerived>::Type
0238 (other.derived(),
0239 isVertical ? 1 : m_matrix.rows(),
0240 isHorizontal ? 1 : m_matrix.cols());
0241 }
0242
0243 template<typename OtherDerived> struct OppositeExtendedType {
0244 typedef Replicate<OtherDerived,
0245 isHorizontal ? 1 : ExpressionType::RowsAtCompileTime,
0246 isVertical ? 1 : ExpressionType::ColsAtCompileTime> Type;
0247 };
0248
0249
0250
0251 template<typename OtherDerived>
0252 EIGEN_DEVICE_FUNC
0253 typename OppositeExtendedType<OtherDerived>::Type
0254 extendedToOpposite(const DenseBase<OtherDerived>& other) const
0255 {
0256 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isHorizontal, OtherDerived::MaxColsAtCompileTime==1),
0257 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED)
0258 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(isVertical, OtherDerived::MaxRowsAtCompileTime==1),
0259 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED)
0260 return typename OppositeExtendedType<OtherDerived>::Type
0261 (other.derived(),
0262 isHorizontal ? 1 : m_matrix.rows(),
0263 isVertical ? 1 : m_matrix.cols());
0264 }
0265
0266 public:
0267 EIGEN_DEVICE_FUNC
0268 explicit inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
0269
0270
0271 EIGEN_DEVICE_FUNC
0272 inline const ExpressionType& _expression() const { return m_matrix; }
0273
0274 #ifdef EIGEN_PARSED_BY_DOXYGEN
0275
0276
0277
0278 random_access_iterator_type iterator;
0279
0280 random_access_iterator_type const_iterator;
0281 #else
0282 typedef internal::subvector_stl_iterator<ExpressionType, DirectionType(Direction)> iterator;
0283 typedef internal::subvector_stl_iterator<const ExpressionType, DirectionType(Direction)> const_iterator;
0284 typedef internal::subvector_stl_reverse_iterator<ExpressionType, DirectionType(Direction)> reverse_iterator;
0285 typedef internal::subvector_stl_reverse_iterator<const ExpressionType, DirectionType(Direction)> const_reverse_iterator;
0286 #endif
0287
0288
0289
0290
0291 iterator begin() { return iterator (m_matrix, 0); }
0292
0293 const_iterator begin() const { return const_iterator(m_matrix, 0); }
0294
0295 const_iterator cbegin() const { return const_iterator(m_matrix, 0); }
0296
0297
0298
0299
0300 reverse_iterator rbegin() { return reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
0301
0302 const_reverse_iterator rbegin() const { return const_reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
0303
0304 const_reverse_iterator crbegin() const { return const_reverse_iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()-1); }
0305
0306
0307
0308
0309 iterator end() { return iterator (m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
0310
0311 const_iterator end() const { return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
0312
0313 const_iterator cend() const { return const_iterator(m_matrix, m_matrix.template subVectors<DirectionType(Direction)>()); }
0314
0315
0316
0317
0318 reverse_iterator rend() { return reverse_iterator (m_matrix, -1); }
0319
0320 const_reverse_iterator rend() const { return const_reverse_iterator (m_matrix, -1); }
0321
0322 const_reverse_iterator crend() const { return const_reverse_iterator (m_matrix, -1); }
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334 template<typename BinaryOp>
0335 EIGEN_DEVICE_FUNC
0336 const typename ReduxReturnType<BinaryOp>::Type
0337 redux(const BinaryOp& func = BinaryOp()) const
0338 {
0339 eigen_assert(redux_length()>0 && "you are using an empty matrix");
0340 return typename ReduxReturnType<BinaryOp>::Type(_expression(), internal::member_redux<BinaryOp,Scalar>(func));
0341 }
0342
0343 typedef typename ReturnType<internal::member_minCoeff>::Type MinCoeffReturnType;
0344 typedef typename ReturnType<internal::member_maxCoeff>::Type MaxCoeffReturnType;
0345 typedef PartialReduxExpr<const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const ExpressionTypeNestedCleaned>,internal::member_sum<RealScalar,RealScalar>,Direction> SquaredNormReturnType;
0346 typedef CwiseUnaryOp<internal::scalar_sqrt_op<RealScalar>, const SquaredNormReturnType> NormReturnType;
0347 typedef typename ReturnType<internal::member_blueNorm,RealScalar>::Type BlueNormReturnType;
0348 typedef typename ReturnType<internal::member_stableNorm,RealScalar>::Type StableNormReturnType;
0349 typedef typename ReturnType<internal::member_hypotNorm,RealScalar>::Type HypotNormReturnType;
0350 typedef typename ReturnType<internal::member_sum>::Type SumReturnType;
0351 typedef EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(SumReturnType,Scalar,quotient) MeanReturnType;
0352 typedef typename ReturnType<internal::member_all>::Type AllReturnType;
0353 typedef typename ReturnType<internal::member_any>::Type AnyReturnType;
0354 typedef PartialReduxExpr<ExpressionType, internal::member_count<Index,Scalar>, Direction> CountReturnType;
0355 typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;
0356 typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;
0357 typedef Reverse<ExpressionType, Direction> ReverseReturnType;
0358
0359 template<int p> struct LpNormReturnType {
0360 typedef PartialReduxExpr<ExpressionType, internal::member_lpnorm<p,RealScalar,Scalar>,Direction> Type;
0361 };
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375 EIGEN_DEVICE_FUNC
0376 const MinCoeffReturnType minCoeff() const
0377 {
0378 eigen_assert(redux_length()>0 && "you are using an empty matrix");
0379 return MinCoeffReturnType(_expression());
0380 }
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394 EIGEN_DEVICE_FUNC
0395 const MaxCoeffReturnType maxCoeff() const
0396 {
0397 eigen_assert(redux_length()>0 && "you are using an empty matrix");
0398 return MaxCoeffReturnType(_expression());
0399 }
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409 EIGEN_DEVICE_FUNC
0410 const SquaredNormReturnType squaredNorm() const
0411 { return SquaredNormReturnType(m_matrix.cwiseAbs2()); }
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421 EIGEN_DEVICE_FUNC
0422 const NormReturnType norm() const
0423 { return NormReturnType(squaredNorm()); }
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433 template<int p>
0434 EIGEN_DEVICE_FUNC
0435 const typename LpNormReturnType<p>::Type lpNorm() const
0436 { return typename LpNormReturnType<p>::Type(_expression()); }
0437
0438
0439
0440
0441
0442
0443
0444
0445 EIGEN_DEVICE_FUNC
0446 const BlueNormReturnType blueNorm() const
0447 { return BlueNormReturnType(_expression()); }
0448
0449
0450
0451
0452
0453
0454
0455
0456 EIGEN_DEVICE_FUNC
0457 const StableNormReturnType stableNorm() const
0458 { return StableNormReturnType(_expression()); }
0459
0460
0461
0462
0463
0464
0465
0466
0467 EIGEN_DEVICE_FUNC
0468 const HypotNormReturnType hypotNorm() const
0469 { return HypotNormReturnType(_expression()); }
0470
0471
0472
0473
0474
0475
0476
0477
0478 EIGEN_DEVICE_FUNC
0479 const SumReturnType sum() const
0480 { return SumReturnType(_expression()); }
0481
0482
0483
0484
0485
0486 EIGEN_DEVICE_FUNC
0487 const MeanReturnType mean() const
0488 { return sum() / Scalar(Direction==Vertical?m_matrix.rows():m_matrix.cols()); }
0489
0490
0491
0492
0493
0494
0495 EIGEN_DEVICE_FUNC
0496 const AllReturnType all() const
0497 { return AllReturnType(_expression()); }
0498
0499
0500
0501
0502
0503
0504 EIGEN_DEVICE_FUNC
0505 const AnyReturnType any() const
0506 { return AnyReturnType(_expression()); }
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517 EIGEN_DEVICE_FUNC
0518 const CountReturnType count() const
0519 { return CountReturnType(_expression()); }
0520
0521
0522
0523
0524
0525
0526
0527
0528 EIGEN_DEVICE_FUNC
0529 const ProdReturnType prod() const
0530 { return ProdReturnType(_expression()); }
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540 EIGEN_DEVICE_FUNC
0541 const ConstReverseReturnType reverse() const
0542 { return ConstReverseReturnType( _expression() ); }
0543
0544
0545
0546
0547
0548 EIGEN_DEVICE_FUNC
0549 ReverseReturnType reverse()
0550 { return ReverseReturnType( _expression() ); }
0551
0552 typedef Replicate<ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType;
0553 EIGEN_DEVICE_FUNC
0554 const ReplicateReturnType replicate(Index factor) const;
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566 template<int Factor> const Replicate<ExpressionType,isVertical*Factor+isHorizontal,isHorizontal*Factor+isVertical>
0567 EIGEN_DEVICE_FUNC
0568 replicate(Index factor = Factor) const
0569 {
0570 return Replicate<ExpressionType,(isVertical?Factor:1),(isHorizontal?Factor:1)>
0571 (_expression(),isVertical?factor:1,isHorizontal?factor:1);
0572 }
0573
0574
0575
0576
0577 template<typename OtherDerived>
0578 EIGEN_DEVICE_FUNC
0579 ExpressionType& operator=(const DenseBase<OtherDerived>& other)
0580 {
0581 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0582 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0583
0584 return m_matrix = extendedTo(other.derived());
0585 }
0586
0587
0588 template<typename OtherDerived>
0589 EIGEN_DEVICE_FUNC
0590 ExpressionType& operator+=(const DenseBase<OtherDerived>& other)
0591 {
0592 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0593 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0594 return m_matrix += extendedTo(other.derived());
0595 }
0596
0597
0598 template<typename OtherDerived>
0599 EIGEN_DEVICE_FUNC
0600 ExpressionType& operator-=(const DenseBase<OtherDerived>& other)
0601 {
0602 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0603 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0604 return m_matrix -= extendedTo(other.derived());
0605 }
0606
0607
0608 template<typename OtherDerived>
0609 EIGEN_DEVICE_FUNC
0610 ExpressionType& operator*=(const DenseBase<OtherDerived>& other)
0611 {
0612 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0613 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
0614 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0615 m_matrix *= extendedTo(other.derived());
0616 return m_matrix;
0617 }
0618
0619
0620 template<typename OtherDerived>
0621 EIGEN_DEVICE_FUNC
0622 ExpressionType& operator/=(const DenseBase<OtherDerived>& other)
0623 {
0624 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0625 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
0626 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0627 m_matrix /= extendedTo(other.derived());
0628 return m_matrix;
0629 }
0630
0631
0632 template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
0633 CwiseBinaryOp<internal::scalar_sum_op<Scalar,typename OtherDerived::Scalar>,
0634 const ExpressionTypeNestedCleaned,
0635 const typename ExtendedType<OtherDerived>::Type>
0636 operator+(const DenseBase<OtherDerived>& other) const
0637 {
0638 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0639 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0640 return m_matrix + extendedTo(other.derived());
0641 }
0642
0643
0644 template<typename OtherDerived>
0645 EIGEN_DEVICE_FUNC
0646 CwiseBinaryOp<internal::scalar_difference_op<Scalar,typename OtherDerived::Scalar>,
0647 const ExpressionTypeNestedCleaned,
0648 const typename ExtendedType<OtherDerived>::Type>
0649 operator-(const DenseBase<OtherDerived>& other) const
0650 {
0651 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0652 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0653 return m_matrix - extendedTo(other.derived());
0654 }
0655
0656
0657
0658 template<typename OtherDerived> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
0659 CwiseBinaryOp<internal::scalar_product_op<Scalar>,
0660 const ExpressionTypeNestedCleaned,
0661 const typename ExtendedType<OtherDerived>::Type>
0662 EIGEN_DEVICE_FUNC
0663 operator*(const DenseBase<OtherDerived>& other) const
0664 {
0665 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0666 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
0667 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0668 return m_matrix * extendedTo(other.derived());
0669 }
0670
0671
0672
0673 template<typename OtherDerived>
0674 EIGEN_DEVICE_FUNC
0675 CwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
0676 const ExpressionTypeNestedCleaned,
0677 const typename ExtendedType<OtherDerived>::Type>
0678 operator/(const DenseBase<OtherDerived>& other) const
0679 {
0680 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
0681 EIGEN_STATIC_ASSERT_ARRAYXPR(ExpressionType)
0682 EIGEN_STATIC_ASSERT_SAME_XPR_KIND(ExpressionType, OtherDerived)
0683 return m_matrix / extendedTo(other.derived());
0684 }
0685
0686
0687
0688
0689
0690 EIGEN_DEVICE_FUNC
0691 CwiseBinaryOp<internal::scalar_quotient_op<Scalar>,
0692 const ExpressionTypeNestedCleaned,
0693 const typename OppositeExtendedType<NormReturnType>::Type>
0694 normalized() const { return m_matrix.cwiseQuotient(extendedToOpposite(this->norm())); }
0695
0696
0697
0698
0699
0700 EIGEN_DEVICE_FUNC void normalize() {
0701 m_matrix = this->normalized();
0702 }
0703
0704 EIGEN_DEVICE_FUNC inline void reverseInPlace();
0705
0706
0707
0708 typedef Homogeneous<ExpressionType,Direction> HomogeneousReturnType;
0709 EIGEN_DEVICE_FUNC
0710 HomogeneousReturnType homogeneous() const;
0711
0712 typedef typename ExpressionType::PlainObject CrossReturnType;
0713 template<typename OtherDerived>
0714 EIGEN_DEVICE_FUNC
0715 const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const;
0716
0717 enum {
0718 HNormalized_Size = Direction==Vertical ? internal::traits<ExpressionType>::RowsAtCompileTime
0719 : internal::traits<ExpressionType>::ColsAtCompileTime,
0720 HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1
0721 };
0722 typedef Block<const ExpressionType,
0723 Direction==Vertical ? int(HNormalized_SizeMinusOne)
0724 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
0725 Direction==Horizontal ? int(HNormalized_SizeMinusOne)
0726 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
0727 HNormalized_Block;
0728 typedef Block<const ExpressionType,
0729 Direction==Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
0730 Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
0731 HNormalized_Factors;
0732 typedef CwiseBinaryOp<internal::scalar_quotient_op<typename internal::traits<ExpressionType>::Scalar>,
0733 const HNormalized_Block,
0734 const Replicate<HNormalized_Factors,
0735 Direction==Vertical ? HNormalized_SizeMinusOne : 1,
0736 Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >
0737 HNormalizedReturnType;
0738
0739 EIGEN_DEVICE_FUNC
0740 const HNormalizedReturnType hnormalized() const;
0741
0742 # ifdef EIGEN_VECTORWISEOP_PLUGIN
0743 # include EIGEN_VECTORWISEOP_PLUGIN
0744 # endif
0745
0746 protected:
0747 Index redux_length() const
0748 {
0749 return Direction==Vertical ? m_matrix.rows() : m_matrix.cols();
0750 }
0751 ExpressionTypeNested m_matrix;
0752 };
0753
0754
0755
0756
0757
0758
0759
0760
0761 template<typename Derived>
0762 EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::ColwiseReturnType
0763 DenseBase<Derived>::colwise()
0764 {
0765 return ColwiseReturnType(derived());
0766 }
0767
0768
0769
0770
0771
0772
0773
0774
0775 template<typename Derived>
0776 EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::RowwiseReturnType
0777 DenseBase<Derived>::rowwise()
0778 {
0779 return RowwiseReturnType(derived());
0780 }
0781
0782 }
0783
0784 #endif