Eigen  3.3.0
 
Loading...
Searching...
No Matches
ArrayCwiseBinaryOps.h
1
6template<typename OtherDerived>
7EIGEN_DEVICE_FUNC
8EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
9operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
10{
11 return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());
12}
13
18template<typename OtherDerived>
19EIGEN_DEVICE_FUNC
20EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>
21operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
22{
23 return CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
24}
25
33EIGEN_MAKE_CWISE_BINARY_OP(min,min)
34
35
39EIGEN_DEVICE_FUNC
40EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived,
41 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
42#ifdef EIGEN_PARSED_BY_DOXYGEN
43min
44#else
45(min)
46#endif
47(const Scalar &other) const
48{
49 return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
50}
51
59EIGEN_MAKE_CWISE_BINARY_OP(max,max)
60
61
65EIGEN_DEVICE_FUNC
66EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived,
67 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
68#ifdef EIGEN_PARSED_BY_DOXYGEN
69max
70#else
71(max)
72#endif
73(const Scalar &other) const
74{
75 return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
76}
77
85EIGEN_MAKE_CWISE_BINARY_OP(pow,pow)
86
87#ifndef EIGEN_PARSED_BY_DOXYGEN
88EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(pow,pow)
89#else
102template<typename T>
103const CwiseBinaryOp<internal::scalar_pow_op<Scalar,T>,Derived,Constant<T> > pow(const T& exponent) const;
104#endif
105
106
107// TODO code generating macros could be moved to Macros.h and could include generation of documentation
108#define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
109template<typename OtherDerived> \
110EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
111OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
112{ \
113 return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
114}\
115typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
116typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
117EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
118OP(const Scalar& s) const { \
119 return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
120} \
121EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
122OP(const Scalar& s, const Derived& d) { \
123 return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
124}
125
126#define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
127template<typename OtherDerived> \
128EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
129OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
130{ \
131 return CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
132} \
133EIGEN_DEVICE_FUNC \
134inline const RCmp ## RCOMPARATOR ## ReturnType \
135OP(const Scalar& s) const { \
136 return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
137} \
138friend inline const Cmp ## RCOMPARATOR ## ReturnType \
139OP(const Scalar& s, const Derived& d) { \
140 return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
141}
142
143
144
152EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
153
154
161EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
162
163
170EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
171
172
179EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
180
181
193EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
194
195
207EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
208
209
210#undef EIGEN_MAKE_CWISE_COMP_OP
211#undef EIGEN_MAKE_CWISE_COMP_R_OP
212
213// scalar addition
214#ifndef EIGEN_PARSED_BY_DOXYGEN
215EIGEN_MAKE_SCALAR_BINARY_OP(operator+,sum)
216#else
226template<typename T>
227const CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<T> > operator+(const T& scalar) const;
232template<typename T> friend
233const CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<T>,Derived> operator+(const T& scalar, const StorageBaseType& expr);
234#endif
235
236#ifndef EIGEN_PARSED_BY_DOXYGEN
237EIGEN_MAKE_SCALAR_BINARY_OP(operator-,difference)
238#else
248template<typename T>
249const CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<T> > operator-(const T& scalar) const;
254template<typename T> friend
255const CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<T>,Derived> operator-(const T& scalar, const StorageBaseType& expr);
256#endif
257
258
259#ifndef EIGEN_PARSED_BY_DOXYGEN
260 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(operator/,quotient)
261#else
267 template<typename T> friend
268 inline const CwiseBinaryOp<internal::scalar_quotient_op<T,Scalar>,Constant<T>,Derived>
269 operator/(const T& s,const StorageBaseType& a);
270#endif
271
281template<typename OtherDerived>
282EIGEN_DEVICE_FUNC
283inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
284operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
285{
286 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
287 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
288 return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
289}
290
300template<typename OtherDerived>
301EIGEN_DEVICE_FUNC
302inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
303operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
304{
305 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
306 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
307 return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
308}
309
319template<typename OtherDerived>
320EIGEN_DEVICE_FUNC
321inline const CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
322operator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
323{
324 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
325 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
326 return CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>(derived(),other.derived());
327}
328
329// NOTE disabled until we agree on argument order
330#if 0
341template<typename DerivedN>
342inline const CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>
343polygamma(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedN> &n) const
344{
345 return CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>(n.derived(), this->derived());
346}
347#endif
348
365template<typename DerivedQ>
366inline const CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>
367zeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedQ> &q) const
368{
369 return CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>(this->derived(), q.derived());
370}