MOAB  4.9.3pre
ArrayCwiseBinaryOps.h
Go to the documentation of this file.
00001 
00005 template<typename OtherDerived>
00006 EIGEN_DEVICE_FUNC
00007 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
00008 operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
00009 {
00010   return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
00011 }
00012 
00017 template<typename OtherDerived>
00018 EIGEN_DEVICE_FUNC
00019 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
00020 operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
00021 {
00022   return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
00023 }
00024 
00032 EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
00033 
00034 
00038 EIGEN_DEVICE_FUNC
00039 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived,
00040                                         const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
00041 #ifdef EIGEN_PARSED_BY_DOXYGEN
00042 min
00043 #else
00044 (min)
00045 #endif
00046 (const Scalar &other) const
00047 {
00048   return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
00049 }
00050 
00058 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
00059 
00060 
00064 EIGEN_DEVICE_FUNC
00065 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived,
00066                                         const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
00067 #ifdef EIGEN_PARSED_BY_DOXYGEN
00068 max
00069 #else
00070 (max)
00071 #endif
00072 (const Scalar &other) const
00073 {
00074   return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
00075 }
00076 
00084 template<typename ExponentDerived>
00085 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
00086 const CwiseBinaryOp<internal::scalar_binary_pow_op<Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>
00087 pow(const ArrayBase<ExponentDerived>& exponents) const
00088 {
00089   return CwiseBinaryOp<internal::scalar_binary_pow_op<Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>(
00090     this->derived(),
00091     exponents.derived()
00092   );
00093 }
00094 
00095 // TODO code generating macros could be moved to Macros.h and could include generation of documentation
00096 #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
00097 template<typename OtherDerived> \
00098 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
00099 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
00100 { \
00101   return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
00102 }\
00103 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
00104 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
00105 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
00106 OP(const Scalar& s) const { \
00107   return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
00108 } \
00109 EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
00110 OP(const Scalar& s, const Derived& d) { \
00111   return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
00112 }
00113 
00114 #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
00115 template<typename OtherDerived> \
00116 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
00117 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
00118 { \
00119   return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
00120 } \
00121 EIGEN_DEVICE_FUNC \
00122 inline const RCmp ## RCOMPARATOR ## ReturnType \
00123 OP(const Scalar& s) const { \
00124   return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
00125 } \
00126 friend inline const Cmp ## RCOMPARATOR ## ReturnType \
00127 OP(const Scalar& s, const Derived& d) { \
00128   return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
00129 }
00130 
00131 
00132 
00140 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
00141 
00142 
00149 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
00150 
00158 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
00159 
00167 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
00168 
00181 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
00182 
00195 EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
00196 
00197 
00198 #undef EIGEN_MAKE_CWISE_COMP_OP
00199 #undef EIGEN_MAKE_CWISE_COMP_R_OP
00200 
00201 // scalar addition
00202 
00210 EIGEN_DEVICE_FUNC
00211 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
00212 operator+(const Scalar& scalar) const
00213 {
00214   return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
00215 }
00216 
00217 EIGEN_DEVICE_FUNC
00218 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
00219 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
00220 {
00221   return other + scalar;
00222 }
00223 
00231 EIGEN_DEVICE_FUNC
00232 inline const CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>
00233 operator-(const Scalar& scalar) const
00234 {
00235   return CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>(derived(), internal::scalar_sub_op<Scalar>(scalar));;
00236 }
00237 
00238 EIGEN_DEVICE_FUNC
00239 friend inline const CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>
00240 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
00241 {
00242   return CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>(other.derived(), internal::scalar_rsub_op<Scalar>(scalar));;
00243 }
00244 
00254 template<typename OtherDerived>
00255 EIGEN_DEVICE_FUNC
00256 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
00257 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
00258 {
00259   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
00260                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
00261   return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
00262 }
00263 
00273 template<typename OtherDerived>
00274 EIGEN_DEVICE_FUNC
00275 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
00276 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
00277 {
00278   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
00279                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
00280   return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
00281 }
00282 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines