Eigen  3.2.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ArrayCwiseBinaryOps.h
1 
5 template<typename OtherDerived>
6 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
7 operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
8 {
9  return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
10 }
11 
16 template<typename OtherDerived>
17 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
18 operator/(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 
30 EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
31 
32 
36 EIGEN_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
39 min
40 #else
41 (min)
42 #endif
43 (const Scalar &other) const
44 {
45  return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
46 }
47 
55 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
56 
57 
61 EIGEN_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
64 max
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) \
75 template<typename OtherDerived> \
76 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
77 OP(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 }\
81 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
82 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
83 EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
84 OP(const Scalar& s) const { \
85  return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
86 } \
87 friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
88 OP(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) \
93 template<typename OtherDerived> \
94 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
95 OP(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 \
100 inline const RCmp ## RCOMPARATOR ## ReturnType \
101 OP(const Scalar& s) const { \
102  return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
103 } \
104 friend inline const Cmp ## RCOMPARATOR ## ReturnType \
105 OP(const Scalar& s, const Derived& d) { \
106  return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
107 }
108 
109 
117 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
118 
119 
126 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
127 
135 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
136 
144 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
145 
158 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
159 
172 EIGEN_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 
186 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
187 operator+(const Scalar& scalar) const
188 {
189  return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
190 }
191 
192 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
193 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
194 {
195  return other + scalar;
196 }
197 
205 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
206 operator-(const Scalar& scalar) const
207 {
208  return *this + (-scalar);
209 }
210 
211 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> >
212 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
213 {
214  return (-other) + scalar;
215 }
216 
226 template<typename OtherDerived>
227 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
228 operator&&(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 
244 template<typename OtherDerived>
245 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
246 operator||(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 
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_mult_op< typename Derived::Scalar >, const Derived > operator/(const typename Derived::Scalar &s, const Eigen::ArrayBase< Derived > &a)
Component-wise division of a scalar by array elements.
Definition: GlobalFunctions.h:74