CwiseBinaryOp.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2014 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_CWISE_BINARY_OP_H
12 #define EIGEN_CWISE_BINARY_OP_H
13 
14 namespace Eigen {
15 
16 namespace internal {
17 template<typename BinaryOp, typename Lhs, typename Rhs>
18 struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
19 {
20  // we must not inherit from traits<Lhs> since it has
21  // the potential to cause problems with MSVC
22  typedef typename remove_all<Lhs>::type Ancestor;
24  enum {
29  };
30 
31  // even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
32  // we still want to handle the case when the result type is different.
33  typedef typename result_of<
34  BinaryOp(
35  const typename Lhs::Scalar&,
36  const typename Rhs::Scalar&
37  )
40  typename traits<Rhs>::StorageKind,
41  BinaryOp>::ret StorageKind;
44  typedef typename Lhs::Nested LhsNested;
45  typedef typename Rhs::Nested RhsNested;
48  enum {
50  };
51 };
52 } // end namespace internal
53 
54 template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
56 
76 template<typename BinaryOp, typename LhsType, typename RhsType>
78  public CwiseBinaryOpImpl<
79  BinaryOp, LhsType, RhsType,
80  typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
81  typename internal::traits<RhsType>::StorageKind,
82  BinaryOp>::ret>,
84 {
85  public:
86 
90 
91  typedef typename CwiseBinaryOpImpl<
92  BinaryOp, LhsType, RhsType,
95  BinaryOp>::ret>::Base Base;
97 
98  typedef typename internal::ref_selector<LhsType>::type LhsNested;
99  typedef typename internal::ref_selector<RhsType>::type RhsNested;
100  typedef typename internal::remove_reference<LhsNested>::type _LhsNested;
101  typedef typename internal::remove_reference<RhsNested>::type _RhsNested;
102 
103 #if EIGEN_COMP_MSVC && EIGEN_HAS_CXX11
104  //Required for Visual Studio or the Copy constructor will probably not get inlined!
107 #endif
108 
110  CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, const BinaryOp& func = BinaryOp())
111  : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
112  {
113  EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);
114  // require the sizes to match
116  eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
117  }
118 
121  // return the fixed size type if available to enable compile time optimizations
122  return internal::traits<typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==Dynamic ? m_rhs.rows() : m_lhs.rows();
123  }
126  // return the fixed size type if available to enable compile time optimizations
127  return internal::traits<typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==Dynamic ? m_rhs.cols() : m_lhs.cols();
128  }
129 
132  const _LhsNested& lhs() const { return m_lhs; }
135  const _RhsNested& rhs() const { return m_rhs; }
138  const BinaryOp& functor() const { return m_functor; }
139 
140  protected:
143  const BinaryOp m_functor;
144 };
145 
146 // Generic API dispatcher
147 template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
148 class CwiseBinaryOpImpl
149  : public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
150 {
151 public:
153 };
154 
159 template<typename Derived>
160 template<typename OtherDerived>
163 {
165  return derived();
166 }
167 
172 template<typename Derived>
173 template<typename OtherDerived>
176 {
178  return derived();
179 }
180 
181 } // end namespace Eigen
182 
183 #endif // EIGEN_CWISE_BINARY_OP_H
Eigen::CwiseBinaryOpImpl
Definition: CwiseBinaryOp.h:55
Eigen::internal::Lhs
@ Lhs
Definition: TensorContractionMapper.h:19
Eigen::CwiseBinaryOp::functor
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE BinaryOp & functor() const
Definition: CwiseBinaryOp.h:138
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
EIGEN_CHECK_BINARY_COMPATIBILIY
#define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP, LHS, RHS)
Definition: XprHelper.h:850
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::CwiseBinaryOp
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::Scalar
result_of< BinaryOp(const typename Lhs::Scalar &, const typename Rhs::Scalar &) >::type Scalar
Definition: CwiseBinaryOp.h:38
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
ret
DenseIndex ret
Definition: level1_cplx_impl.h:44
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::_LhsNested
remove_reference< LhsNested >::type _LhsNested
Definition: CwiseBinaryOp.h:46
EIGEN_CONSTEXPR
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::RhsNested
Rhs::Nested RhsNested
Definition: CwiseBinaryOp.h:45
type
Definition: pytypes.h:1491
Eigen::MatrixBase::operator+=
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator+=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:175
Eigen::CwiseBinaryOp::Rhs
internal::remove_all< RhsType >::type Rhs
Definition: CwiseBinaryOp.h:89
Eigen::MatrixBase::operator-=
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator-=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:162
Eigen::CwiseBinaryOp::m_lhs
LhsNested m_lhs
Definition: CwiseBinaryOp.h:141
Eigen::CwiseBinaryOp::m_rhs
RhsNested m_rhs
Definition: CwiseBinaryOp.h:142
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::LhsNested
Lhs::Nested LhsNested
Definition: CwiseBinaryOp.h:44
Eigen::internal::true_type
Definition: Meta.h:96
Eigen::internal::remove_reference::type
T type
Definition: Meta.h:114
EIGEN_GENERIC_PUBLIC_INTERFACE
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1264
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::internal::cwise_promote_storage_type
Definition: XprHelper.h:546
Eigen::internal::generic_xpr_base
Definition: XprHelper.h:501
Eigen::CwiseBinaryOp::Lhs
internal::remove_all< LhsType >::type Lhs
Definition: CwiseBinaryOp.h:88
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE
#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:192
Eigen::CwiseBinaryOp::CwiseBinaryOp
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs &aLhs, const Rhs &aRhs, const BinaryOp &func=BinaryOp())
Definition: CwiseBinaryOp.h:110
Eigen::Triplet< double >
Eigen::CwiseBinaryOp::rhs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::XprKind
traits< Ancestor >::XprKind XprKind
Definition: CwiseBinaryOp.h:23
Eigen::CwiseBinaryOp::cols
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:125
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::StorageKind
cwise_promote_storage_type< typename traits< Lhs >::StorageKind, typename traits< Rhs >::StorageKind, BinaryOp >::ret StorageKind
Definition: CwiseBinaryOp.h:41
Eigen::internal::Rhs
@ Rhs
Definition: TensorContractionMapper.h:18
Eigen::internal::sub_assign_op
Definition: AssignmentFunctors.h:67
Eigen::CwiseBinaryOp::Functor
internal::remove_all< BinaryOp >::type Functor
Definition: CwiseBinaryOp.h:87
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::_RhsNested
remove_reference< RhsNested >::type _RhsNested
Definition: CwiseBinaryOp.h:47
Eigen::internal::result_of
Definition: Meta.h:513
Eigen::internal::no_assignment_operator
Definition: XprHelper.h:109
Eigen::internal::add_assign_op
Definition: AssignmentFunctors.h:46
EIGEN_NOEXCEPT
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
internal
Definition: BandTriangularSolver.h:13
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::Ancestor
remove_all< Lhs >::type Ancestor
Definition: CwiseBinaryOp.h:22
Eigen::internal::promote_index_type
Definition: XprHelper.h:120
Eigen::internal::cwise_promote_storage_order
Definition: XprHelper.h:555
func
Definition: benchGeometry.cpp:23
Eigen::CwiseBinaryOpImpl::Base
internal::generic_xpr_base< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::type Base
Definition: CwiseBinaryOp.h:152
Eigen::internal::traits< CwiseBinaryOp< BinaryOp, Lhs, Rhs > >::StorageIndex
promote_index_type< typename traits< Lhs >::StorageIndex, typename traits< Rhs >::StorageIndex >::type StorageIndex
Definition: CwiseBinaryOp.h:43
Eigen::CwiseBinaryOp::m_functor
const BinaryOp m_functor
Definition: CwiseBinaryOp.h:143
Eigen::internal::call_assignment
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
Definition: AssignEvaluator.h:834
Eigen::CwiseBinaryOp::Base
CwiseBinaryOpImpl< BinaryOp, LhsType, RhsType, typename internal::cwise_promote_storage_type< typename internal::traits< LhsType >::StorageKind, typename internal::traits< Rhs >::StorageKind, BinaryOp >::ret >::Base Base
Definition: CwiseBinaryOp.h:95
test_callbacks.value
value
Definition: test_callbacks.py:158
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Eigen::CwiseBinaryOp::lhs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Eigen::CwiseBinaryOp::rows
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:120
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:02:05