Eigen  3.2.10
 
Loading...
Searching...
No Matches
ArrayCwiseBinaryOps.h
1
5template<typename OtherDerived>
6EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
7operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
8{
9 return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
10}
11
16template<typename OtherDerived>
17EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
18operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
19{
20 return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
21}
22
30EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
31
32
36EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived,
37 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
38#ifdef EIGEN_PARSED_BY_DOXYGEN
39min
40#else
41(min)
42#endif
43(const Scalar &other) const
44{
45 return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
46}
47
55EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
56
57
61EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived,
62 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
63#ifdef EIGEN_PARSED_BY_DOXYGEN
64max
65#else
66(max)
67#endif
68(const Scalar &other) const
69{
70 return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
71}
72
73
74#define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
75template<typename OtherDerived> \
76EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
77OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
78{ \
79 return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
80}\
81typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
82typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
83EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
84OP(const Scalar& s) const { \
85 return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
86} \
87friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
88OP(const Scalar& s, const Derived& d) { \
89 return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
90}
91
92#define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
93template<typename OtherDerived> \
94EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
95OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
96{ \
97 return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
98} \
99\
100inline const RCmp ## RCOMPARATOR ## ReturnType \
101OP(const Scalar& s) const { \
102 return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
103} \
104friend inline const Cmp ## RCOMPARATOR ## ReturnType \
105OP(const Scalar& s, const Derived& d) { \
106 return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
107}
108
109
117EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
118
119
126EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
127
128
135EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
136
137
144EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
145
146
158EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
159
160
172EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
173
174#undef EIGEN_MAKE_CWISE_COMP_OP
175#undef EIGEN_MAKE_CWISE_COMP_R_OP
176
177// scalar addition
178
186inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
187operator+(const Scalar& scalar) const
188{
189 return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
190}
191
192friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
193operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
194{
195 return other + scalar;
196}
197
205inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
206operator-(const Scalar& scalar) const
207{
208 return *this + (-scalar);
209}
210
211friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> >
212operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
213{
214 return (-other) + scalar;
215}
216
226template<typename OtherDerived>
227inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
228operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
229{
230 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
231 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
232 return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
233}
234
244template<typename OtherDerived>
245inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
246operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
247{
248 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
249 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
250 return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
251}
252
253