26 #ifndef EIGEN_CWISE_BINARY_OP_H
27 #define EIGEN_CWISE_BINARY_OP_H
52 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
53 struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
57 typedef typename remove_all<Lhs>::type Ancestor;
68 typedef typename result_of<
74 typedef typename promote_storage_type<typename traits<Lhs>::StorageKind,
76 typedef typename promote_index_type<typename traits<Lhs>::Index,
78 typedef typename Lhs::Nested LhsNested;
79 typedef typename Rhs::Nested RhsNested;
80 typedef typename remove_reference<LhsNested>::type _LhsNested;
81 typedef typename remove_reference<RhsNested>::type _RhsNested;
83 LhsCoeffReadCost = _LhsNested::CoeffReadCost,
84 RhsCoeffReadCost = _RhsNested::CoeffReadCost,
85 LhsFlags = _LhsNested::Flags,
86 RhsFlags = _RhsNested::Flags,
87 SameType = is_same<typename _LhsNested::Scalar,typename _RhsNested::Scalar>::value,
89 Flags0 = (
int(LhsFlags) |
int(RhsFlags)) & (
91 | (
int(LhsFlags) &
int(RhsFlags) &
94 | (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ?
PacketAccessBit : 0)
99 CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + functor_traits<BinaryOp>::Cost
111 #define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \
112 EIGEN_STATIC_ASSERT((internal::functor_allows_mixing_real_and_complex<BINOP>::ret \
113 ? int(internal::is_same<typename NumTraits<LHS>::Real, typename NumTraits<RHS>::Real>::value) \
114 : int(internal::is_same<LHS, RHS>::value)), \
115 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
117 template<
typename BinaryOp,
typename Lhs,
typename Rhs,
typename StorageKind>
120 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
122 public CwiseBinaryOpImpl<
124 typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind,
125 typename internal::traits<Rhs>::StorageKind>::ret>
129 typedef typename CwiseBinaryOpImpl<
131 typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind,
132 typename internal::traits<Rhs>::StorageKind>::ret>
::Base Base;
137 typedef typename internal::remove_reference<LhsNested>::type
_LhsNested;
138 typedef typename internal::remove_reference<RhsNested>::type
_RhsNested;
141 : m_lhs(lhs), m_rhs(rhs), m_functor(func)
146 eigen_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
151 if (internal::traits<
typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==
Dynamic)
158 if (internal::traits<
typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==
Dynamic)
169 const BinaryOp&
functor()
const {
return m_functor; }
177 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
179 :
public internal::dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
184 typedef typename internal::dense_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
Base;
189 return derived().functor()(derived().lhs().coeff(row, col),
190 derived().rhs().coeff(row, col));
193 template<
int LoadMode>
196 return derived().functor().packetOp(derived().lhs().
template packet<LoadMode>(row, col),
197 derived().rhs().
template packet<LoadMode>(row, col));
202 return derived().functor()(derived().lhs().coeff(index),
203 derived().rhs().coeff(index));
206 template<
int LoadMode>
209 return derived().functor().packetOp(derived().lhs().
template packet<LoadMode>(index),
210 derived().rhs().
template packet<LoadMode>(index));
218 template<
typename Derived>
219 template<
typename OtherDerived>
224 tmp = other.derived();
232 template<
typename Derived>
233 template<
typename OtherDerived>
238 tmp = other.derived();
244 #endif // EIGEN_CWISE_BINARY_OP_H