11 #ifndef EIGEN_CWISE_BINARY_OP_H
12 #define EIGEN_CWISE_BINARY_OP_H
14 #include "./InternalHeaderCheck.h"
19 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
20 struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
24 typedef remove_all_t<Lhs> Ancestor;
25 typedef typename traits<Ancestor>::XprKind XprKind;
27 RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
28 ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,
29 MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,
30 MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime
35 typedef typename result_of<
37 const typename Lhs::Scalar&,
38 const typename Rhs::Scalar&
41 typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,
42 typename traits<Rhs>::StorageKind,
43 BinaryOp>::ret StorageKind;
44 typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,
45 typename traits<Rhs>::StorageIndex>::type StorageIndex;
46 typedef typename Lhs::Nested LhsNested;
47 typedef typename Rhs::Nested RhsNested;
48 typedef std::remove_reference_t<LhsNested> LhsNested_;
49 typedef std::remove_reference_t<RhsNested> RhsNested_;
51 Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind,
typename traits<Rhs>::StorageKind,LhsNested_::Flags &
RowMajorBit,RhsNested_::Flags &
RowMajorBit>::value
56 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
57 class CwiseBinaryOpImpl;
78 template<
typename BinaryOp,
typename LhsType,
typename RhsType>
80 public CwiseBinaryOpImpl<
81 BinaryOp, LhsType, RhsType,
82 typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
83 typename internal::traits<RhsType>::StorageKind,
85 internal::no_assignment_operator
89 typedef internal::remove_all_t<BinaryOp> Functor;
90 typedef internal::remove_all_t<LhsType> Lhs;
91 typedef internal::remove_all_t<RhsType> Rhs;
93 typedef typename CwiseBinaryOpImpl<
94 BinaryOp, LhsType, RhsType,
95 typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
96 typename internal::traits<Rhs>::StorageKind,
97 BinaryOp>::ret>::Base Base;
100 EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,
typename Lhs::Scalar,
typename Rhs::Scalar)
101 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
103 typedef typename internal::ref_selector<LhsType>::type LhsNested;
104 typedef typename internal::ref_selector<RhsType>::type RhsNested;
105 typedef std::remove_reference_t<LhsNested> LhsNested_;
106 typedef std::remove_reference_t<RhsNested> RhsNested_;
114 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
115 CwiseBinaryOp(
const Lhs& aLhs,
const Rhs& aRhs,
const BinaryOp& func = BinaryOp())
116 : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
118 eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
121 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
122 Index rows()
const EIGEN_NOEXCEPT {
124 return internal::traits<internal::remove_all_t<LhsNested>>::RowsAtCompileTime==
Dynamic ? m_rhs.rows() : m_lhs.rows();
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
127 Index cols()
const EIGEN_NOEXCEPT {
129 return internal::traits<internal::remove_all_t<LhsNested>>::ColsAtCompileTime==
Dynamic ? m_rhs.cols() : m_lhs.cols();
133 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
134 const LhsNested_&
lhs()
const {
return m_lhs; }
136 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
137 const RhsNested_&
rhs()
const {
return m_rhs; }
139 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
140 const BinaryOp&
functor()
const {
return m_functor; }
145 const BinaryOp m_functor;
149 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
150 class CwiseBinaryOpImpl
151 :
public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
154 typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
161 template<
typename Derived>
162 template<
typename OtherDerived>
163 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
166 call_assignment(derived(), other.
derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
174 template<
typename Derived>
175 template<
typename OtherDerived>
176 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
179 call_assignment(derived(), other.
derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:86
const LhsNested_ & lhs() const
Definition: CwiseBinaryOp.h:134
const RhsNested_ & rhs() const
Definition: CwiseBinaryOp.h:137
const BinaryOp & functor() const
Definition: CwiseBinaryOp.h:140
Derived & derived()
Definition: EigenBase.h:48
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
Derived & operator-=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:164
Derived & operator+=(const MatrixBase< OtherDerived > &other)
Definition: CwiseBinaryOp.h:177
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24