Medial Code Documentation
Loading...
Searching...
No Matches
ArrayCwiseBinaryOps.h
1
5template<typename OtherDerived>
6EIGEN_DEVICE_FUNC
7EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
8operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
9{
10 return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
11}
12
17template<typename OtherDerived>
18EIGEN_DEVICE_FUNC
19EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
20operator/(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
32EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
33
34
38EIGEN_DEVICE_FUNC
39EIGEN_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
42min
43#else
44(min)
45#endif
46(const Scalar &other) const
47{
48 return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
49}
50
58EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
59
60
64EIGEN_DEVICE_FUNC
65EIGEN_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
68max
69#else
70(max)
71#endif
72(const Scalar &other) const
73{
74 return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
75}
76
84template<typename ExponentDerived>
85EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
86const CwiseBinaryOp<internal::scalar_binary_pow_op<Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>
87pow(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) \
97template<typename OtherDerived> \
98EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
99OP(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}\
103typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
104typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
105EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
106OP(const Scalar& s) const { \
107 return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
108} \
109EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
110OP(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) \
115template<typename OtherDerived> \
116EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
117OP(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} \
121EIGEN_DEVICE_FUNC \
122inline const RCmp ## RCOMPARATOR ## ReturnType \
123OP(const Scalar& s) const { \
124 return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
125} \
126friend inline const Cmp ## RCOMPARATOR ## ReturnType \
127OP(const Scalar& s, const Derived& d) { \
128 return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
129}
130
131
132
140EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
141
142
149EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
150
151
158EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
159
160
167EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
168
169
181EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
182
183
195EIGEN_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
210EIGEN_DEVICE_FUNC
211inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
212operator+(const Scalar& scalar) const
213{
214 return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
215}
216
217EIGEN_DEVICE_FUNC
218friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
219operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
220{
221 return other + scalar;
222}
223
231EIGEN_DEVICE_FUNC
232inline const CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>
233operator-(const Scalar& scalar) const
234{
235 return CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>(derived(), internal::scalar_sub_op<Scalar>(scalar));;
236}
237
238EIGEN_DEVICE_FUNC
239friend inline const CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>
240operator-(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
254template<typename OtherDerived>
255EIGEN_DEVICE_FUNC
256inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
257operator&&(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
273template<typename OtherDerived>
274EIGEN_DEVICE_FUNC
275inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
276operator||(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