ArrayCwiseBinaryOps.h
Go to the documentation of this file.
1 
6 template<typename OtherDerived>
8 EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
9 operator*(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 
18 template<typename OtherDerived>
20 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>
21 operator/(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 
33 template <int NaNPropagation=PropagateFast, typename OtherDerived>
35 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar,NaNPropagation>, const Derived, const OtherDerived>
36 #ifdef EIGEN_PARSED_BY_DOXYGEN
38 #else
39 (min)
40 #endif
41 (const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
42 {
43  return CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar,NaNPropagation>, const Derived, const OtherDerived>(derived(), other.derived());
44 }
45 
50 template <int NaNPropagation=PropagateFast>
52 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar,NaNPropagation>, const Derived,
53  const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
54 #ifdef EIGEN_PARSED_BY_DOXYGEN
56 #else
57 (min)
58 #endif
59 (const Scalar &other) const
60 {
61  return (min<NaNPropagation>)(Derived::PlainObject::Constant(rows(), cols(), other));
62 }
63 
71 template <int NaNPropagation=PropagateFast, typename OtherDerived>
73 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar,NaNPropagation>, const Derived, const OtherDerived>
74 #ifdef EIGEN_PARSED_BY_DOXYGEN
76 #else
77 (max)
78 #endif
79 (const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
80 {
81  return CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar,NaNPropagation>, const Derived, const OtherDerived>(derived(), other.derived());
82 }
83 
88 template <int NaNPropagation=PropagateFast>
90  EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar,NaNPropagation>, const Derived,
91  const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
92 #ifdef EIGEN_PARSED_BY_DOXYGEN
94 #else
95 (max)
96 #endif
97 (const Scalar &other) const
98 {
99  return (max<NaNPropagation>)(Derived::PlainObject::Constant(rows(), cols(), other));
100 }
101 
110 
111 
116 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_absolute_difference_op<Scalar,Scalar>, const Derived,
117  const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
118 #ifdef EIGEN_PARSED_BY_DOXYGEN
120 #else
122 #endif
123 (const Scalar &other) const
124 {
125  return (absolute_difference)(Derived::PlainObject::Constant(rows(), cols(), other));
126 }
127 
136 
137 
143 
144 
145 // TODO code generating macros could be moved to Macros.h and could include generation of documentation
146 #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
147 template<typename OtherDerived> \
148 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
149 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
150 { \
151  return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
152 }\
153 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
154 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
155 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
156 OP(const Scalar& s) const { \
157  return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
158 } \
159 EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
160 OP(const Scalar& s, const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& d) { \
161  return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
162 }
163 
164 #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
165 template<typename OtherDerived> \
166 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
167 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
168 { \
169  return CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
170 } \
171 EIGEN_DEVICE_FUNC \
172 inline const RCmp ## RCOMPARATOR ## ReturnType \
173 OP(const Scalar& s) const { \
174  return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
175 } \
176 friend inline const Cmp ## RCOMPARATOR ## ReturnType \
177 OP(const Scalar& s, const Derived& d) { \
178  return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
179 }
180 
181 
182 
190 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
191 
192 
199 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
200 
201 
208 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
209 
210 
217 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
218 
219 
231 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
232 
233 
245 EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
246 
247 
248 #undef EIGEN_MAKE_CWISE_COMP_OP
249 #undef EIGEN_MAKE_CWISE_COMP_R_OP
250 
251 // scalar addition
252 #ifndef EIGEN_PARSED_BY_DOXYGEN
253 EIGEN_MAKE_SCALAR_BINARY_OP(operator+,sum)
254 #else
264 template<typename T>
265 const CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<T> > operator+(const T& scalar) const;
270 template<typename T> friend
271 const CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<T>,Derived> operator+(const T& scalar, const StorageBaseType& expr);
272 #endif
273 
274 #ifndef EIGEN_PARSED_BY_DOXYGEN
275 EIGEN_MAKE_SCALAR_BINARY_OP(operator-,difference)
276 #else
286 template<typename T>
287 const CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<T> > operator-(const T& scalar) const;
292 template<typename T> friend
293 const CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<T>,Derived> operator-(const T& scalar, const StorageBaseType& expr);
294 #endif
295 
296 
297 #ifndef EIGEN_PARSED_BY_DOXYGEN
298  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(operator/,quotient)
299 #else
305  template<typename T> friend
306  inline const CwiseBinaryOp<internal::scalar_quotient_op<T,Scalar>,Constant<T>,Derived>
307  operator/(const T& s,const StorageBaseType& a);
308 #endif
309 
310 // NOTE disabled until we agree on argument order
311 #if 0
322 template<typename DerivedN>
323 inline const CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>
324 polygamma(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedN> &n) const
325 {
326  return CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>(n.derived(), this->derived());
327 }
328 #endif
329 
346 template<typename DerivedQ>
347 inline const CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>
348 zeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedQ> &q) const
349 {
350  return CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>(this->derived(), q.derived());
351 }
#define EIGEN_CURRENT_STORAGE_BASE_CLASS
Definition: ArrayBase.h:92
const CwiseBinaryOp< internal::scalar_min_op< Scalar, Scalar, NaNPropagation >, const Derived, const OtherDerived > min(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_max_op< Scalar, Scalar, NaNPropagation >, const Derived, const OtherDerived > max(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< absolute_difference< Scalar >, const Derived, const OtherDerived > absolute_difference(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp< internal::scalar_quotient_op< Scalar, typename OtherDerived::Scalar >, const Derived, const OtherDerived > operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
#define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR)
#define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR)
const CwiseBinaryOp< internal::scalar_difference_op< Scalar, T >, Derived, Constant< T > > operator-(const T &scalar) const
const CwiseBinaryOp< internal::scalar_zeta_op< Scalar >, const Derived, const DerivedQ > zeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS< DerivedQ > &q) const
const CwiseBinaryOp< internal::scalar_sum_op< Scalar, T >, Derived, Constant< T > > operator+(const T &scalar) const
int n
#define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS, RHS, OPNAME)
Definition: Macros.h:1182
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD, OPNAME)
Definition: Macros.h:1220
#define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD, OPNAME)
Definition: Macros.h:1229
#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD, OPNAME)
Definition: Macros.h:1192
const GlobalUnaryPowReturnType< Derived, ScalarExponent > pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
const std::enable_if_t< std::is_same< typename LhsDerived::Scalar, typename RhsDerived::Scalar >::value, Eigen::CwiseBinaryOp< Eigen::internal::scalar_atan2_op< typename LhsDerived::Scalar, typename RhsDerived::Scalar >, const LhsDerived, const RhsDerived > > atan2(const Eigen::ArrayBase< LhsDerived > &x, const Eigen::ArrayBase< RhsDerived > &exponents)