11 #ifndef EIGEN_CWISE_BINARY_OP_H 12 #define EIGEN_CWISE_BINARY_OP_H 17 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
18 struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
22 typedef typename remove_all<Lhs>::type Ancestor;
23 typedef typename traits<Ancestor>::XprKind XprKind;
25 RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
26 ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,
27 MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,
28 MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime
33 typedef typename result_of<
35 const typename Lhs::Scalar&,
36 const typename Rhs::Scalar&
39 typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,
40 typename traits<Rhs>::StorageKind,
41 BinaryOp>::ret StorageKind;
42 typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,
43 typename traits<Rhs>::StorageIndex>::type StorageIndex;
44 typedef typename Lhs::Nested LhsNested;
45 typedef typename Rhs::Nested RhsNested;
46 typedef typename remove_reference<LhsNested>::type _LhsNested;
47 typedef typename remove_reference<RhsNested>::type _RhsNested;
49 Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind,
typename traits<Rhs>::StorageKind,_LhsNested::Flags &
RowMajorBit,_RhsNested::Flags & RowMajorBit>::value
54 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
55 class CwiseBinaryOpImpl;
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,
83 internal::no_assignment_operator
87 typedef typename internal::remove_all<BinaryOp>::type Functor;
88 typedef typename internal::remove_all<LhsType>::type Lhs;
89 typedef typename internal::remove_all<RhsType>::type Rhs;
91 typedef typename CwiseBinaryOpImpl<
92 BinaryOp, LhsType, RhsType,
93 typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
94 typename internal::traits<Rhs>::StorageKind,
95 BinaryOp>::ret>::Base Base;
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;
103 #if EIGEN_COMP_MSVC && EIGEN_HAS_CXX11 109 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
110 CwiseBinaryOp(
const Lhs& aLhs,
const Rhs& aRhs,
const BinaryOp& func = BinaryOp())
111 : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
113 EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,
typename Lhs::Scalar,
typename Rhs::Scalar);
115 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
116 eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
119 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
120 Index rows()
const EIGEN_NOEXCEPT {
122 return internal::traits<typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==
Dynamic ? m_rhs.rows() : m_lhs.rows();
124 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
125 Index cols()
const EIGEN_NOEXCEPT {
127 return internal::traits<typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==
Dynamic ? m_rhs.cols() : m_lhs.cols();
131 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
132 const _LhsNested&
lhs()
const {
return m_lhs; }
134 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
135 const _RhsNested&
rhs()
const {
return m_rhs; }
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
138 const BinaryOp&
functor()
const {
return m_functor; }
143 const BinaryOp m_functor;
147 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
148 class CwiseBinaryOpImpl
149 :
public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
152 typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
159 template<
typename Derived>
160 template<
typename OtherDerived>
161 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
164 call_assignment(derived(), other.
derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
172 template<
typename Derived>
173 template<
typename OtherDerived>
174 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
177 call_assignment(derived(), other.
derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
183 #endif // EIGEN_CWISE_BINARY_OP_H const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Derived & derived()
Definition: EigenBase.h:46
const unsigned int RowMajorBit
Definition: Constants.h:66
Derived & operator+=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:175
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
Derived & operator-=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:162
const int Dynamic
Definition: Constants.h:22
const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
const BinaryOp & functor() const
Definition: CwiseBinaryOp.h:138