Eigen  3.2.91
ArrayCwiseBinaryOps.h
1 
5 template<typename OtherDerived>
6 EIGEN_DEVICE_FUNC
7 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
8 operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
9 {
10  return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
11 }
12 
17 template<typename OtherDerived>
18 EIGEN_DEVICE_FUNC
19 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
20 operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
21 {
22  return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
23 }
24 
32 EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
33 
34 
38 EIGEN_DEVICE_FUNC
39 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived,
40  const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
41 #ifdef EIGEN_PARSED_BY_DOXYGEN
42 min
43 #else
44 (min)
45 #endif
46 (const Scalar &other) const
47 {
48  return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
49 }
50 
58 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
59 
60 
64 EIGEN_DEVICE_FUNC
65 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived,
66  const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
67 #ifdef EIGEN_PARSED_BY_DOXYGEN
68 max
69 #else
70 (max)
71 #endif
72 (const Scalar &other) const
73 {
74  return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
75 }
76 
84 template<typename ExponentDerived>
85 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
86 const CwiseBinaryOp<internal::scalar_binary_pow_op<Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>
87 pow(const ArrayBase<ExponentDerived>& exponents) const
88 {
89  return CwiseBinaryOp<internal::scalar_binary_pow_op<Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>(
90  this->derived(),
91  exponents.derived()
92  );
93 }
94 
95 // TODO code generating macros could be moved to Macros.h and could include generation of documentation
96 #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
97 template<typename OtherDerived> \
98 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
99 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
100 { \
101  return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
102 }\
103 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
104 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
105 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
106 OP(const Scalar& s) const { \
107  return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
108 } \
109 EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
110 OP(const Scalar& s, const Derived& d) { \
111  return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
112 }
113 
114 #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
115 template<typename OtherDerived> \
116 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
117 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
118 { \
119  return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
120 } \
121 EIGEN_DEVICE_FUNC \
122 inline const RCmp ## RCOMPARATOR ## ReturnType \
123 OP(const Scalar& s) const { \
124  return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
125 } \
126 friend inline const Cmp ## RCOMPARATOR ## ReturnType \
127 OP(const Scalar& s, const Derived& d) { \
128  return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
129 }
130 
131 
132 
140 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
141 
142 
149 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
150 
158 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
159 
167 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
168 
181 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
182 
195 EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
196 
197 
198 #undef EIGEN_MAKE_CWISE_COMP_OP
199 #undef EIGEN_MAKE_CWISE_COMP_R_OP
200 
201 // scalar addition
202 
210 EIGEN_DEVICE_FUNC
211 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
212 operator+(const Scalar& scalar) const
213 {
214  return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
215 }
216 
217 EIGEN_DEVICE_FUNC
218 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
219 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
220 {
221  return other + scalar;
222 }
223 
231 EIGEN_DEVICE_FUNC
232 inline const CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>
233 operator-(const Scalar& scalar) const
234 {
235  return CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>(derived(), internal::scalar_sub_op<Scalar>(scalar));;
236 }
237 
238 EIGEN_DEVICE_FUNC
239 friend inline const CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>
240 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
241 {
242  return CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>(other.derived(), internal::scalar_rsub_op<Scalar>(scalar));;
243 }
244 
254 template<typename OtherDerived>
255 EIGEN_DEVICE_FUNC
256 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
257 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
258 {
259  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
260  THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
261  return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
262 }
263 
273 template<typename OtherDerived>
274 EIGEN_DEVICE_FUNC
275 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
276 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
277 {
278  EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
279  THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
280  return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
281 }
282 
Definition: Eigen_Colamd.h:54