Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ArrayCwiseBinaryOps.h
00001 /** \returns an expression of the coefficient wise product of \c *this and \a other 00002 * 00003 * \sa MatrixBase::cwiseProduct 00004 */ 00005 template<typename OtherDerived> 00006 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived) 00007 operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00008 { 00009 return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived()); 00010 } 00011 00012 /** \returns an expression of the coefficient wise quotient of \c *this and \a other 00013 * 00014 * \sa MatrixBase::cwiseQuotient 00015 */ 00016 template<typename OtherDerived> 00017 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived> 00018 operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00019 { 00020 return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00021 } 00022 00023 /** \returns an expression of the coefficient-wise min of \c *this and \a other 00024 * 00025 * Example: \include Cwise_min.cpp 00026 * Output: \verbinclude Cwise_min.out 00027 * 00028 * \sa max() 00029 */ 00030 EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op) 00031 00032 /** \returns an expression of the coefficient-wise min of \c *this and scalar \a other 00033 * 00034 * \sa max() 00035 */ 00036 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, 00037 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > 00038 #ifdef EIGEN_PARSED_BY_DOXYGEN 00039 min 00040 #else 00041 (min) 00042 #endif 00043 (const Scalar &other) const 00044 { 00045 return (min)(Derived::PlainObject::Constant(rows(), cols(), other)); 00046 } 00047 00048 /** \returns an expression of the coefficient-wise max of \c *this and \a other 00049 * 00050 * Example: \include Cwise_max.cpp 00051 * Output: \verbinclude Cwise_max.out 00052 * 00053 * \sa min() 00054 */ 00055 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op) 00056 00057 /** \returns an expression of the coefficient-wise max of \c *this and scalar \a other 00058 * 00059 * \sa min() 00060 */ 00061 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, 00062 const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > 00063 #ifdef EIGEN_PARSED_BY_DOXYGEN 00064 max 00065 #else 00066 (max) 00067 #endif 00068 (const Scalar &other) const 00069 { 00070 return (max)(Derived::PlainObject::Constant(rows(), cols(), other)); 00071 } 00072 00073 00074 #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \ 00075 template<typename OtherDerived> \ 00076 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \ 00077 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \ 00078 { \ 00079 return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \ 00080 }\ 00081 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \ 00082 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \ 00083 EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \ 00084 OP(const Scalar& s) const { \ 00085 return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \ 00086 } \ 00087 friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \ 00088 OP(const Scalar& s, const Derived& d) { \ 00089 return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \ 00090 } 00091 00092 #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \ 00093 template<typename OtherDerived> \ 00094 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \ 00095 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \ 00096 { \ 00097 return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \ 00098 } \ 00099 \ 00100 inline const RCmp ## RCOMPARATOR ## ReturnType \ 00101 OP(const Scalar& s) const { \ 00102 return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \ 00103 } \ 00104 friend inline const Cmp ## RCOMPARATOR ## ReturnType \ 00105 OP(const Scalar& s, const Derived& d) { \ 00106 return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \ 00107 } 00108 00109 00110 /** \returns an expression of the coefficient-wise < operator of *this and \a other 00111 * 00112 * Example: \include Cwise_less.cpp 00113 * Output: \verbinclude Cwise_less.out 00114 * 00115 * \sa all(), any(), operator>(), operator<=() 00116 */ 00117 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT) 00118 00119 /** \returns an expression of the coefficient-wise <= operator of *this and \a other 00120 * 00121 * Example: \include Cwise_less_equal.cpp 00122 * Output: \verbinclude Cwise_less_equal.out 00123 * 00124 * \sa all(), any(), operator>=(), operator<() 00125 */ 00126 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE) 00127 00128 /** \returns an expression of the coefficient-wise > operator of *this and \a other 00129 * 00130 * Example: \include Cwise_greater.cpp 00131 * Output: \verbinclude Cwise_greater.out 00132 * 00133 * \sa all(), any(), operator>=(), operator<() 00134 */ 00135 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT) 00136 00137 /** \returns an expression of the coefficient-wise >= operator of *this and \a other 00138 * 00139 * Example: \include Cwise_greater_equal.cpp 00140 * Output: \verbinclude Cwise_greater_equal.out 00141 * 00142 * \sa all(), any(), operator>(), operator<=() 00143 */ 00144 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE) 00145 00146 /** \returns an expression of the coefficient-wise == operator of *this and \a other 00147 * 00148 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 00149 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 00150 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 00151 * isMuchSmallerThan(). 00152 * 00153 * Example: \include Cwise_equal_equal.cpp 00154 * Output: \verbinclude Cwise_equal_equal.out 00155 * 00156 * \sa all(), any(), isApprox(), isMuchSmallerThan() 00157 */ 00158 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ) 00159 00160 /** \returns an expression of the coefficient-wise != operator of *this and \a other 00161 * 00162 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 00163 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 00164 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 00165 * isMuchSmallerThan(). 00166 * 00167 * Example: \include Cwise_not_equal.cpp 00168 * Output: \verbinclude Cwise_not_equal.out 00169 * 00170 * \sa all(), any(), isApprox(), isMuchSmallerThan() 00171 */ 00172 EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ) 00173 00174 #undef EIGEN_MAKE_CWISE_COMP_OP 00175 #undef EIGEN_MAKE_CWISE_COMP_R_OP 00176 00177 // scalar addition 00178 00179 /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar 00180 * 00181 * Example: \include Cwise_plus.cpp 00182 * Output: \verbinclude Cwise_plus.out 00183 * 00184 * \sa operator+=(), operator-() 00185 */ 00186 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 00187 operator+(const Scalar& scalar) const 00188 { 00189 return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar)); 00190 } 00191 00192 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 00193 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) 00194 { 00195 return other + scalar; 00196 } 00197 00198 /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar 00199 * 00200 * Example: \include Cwise_minus.cpp 00201 * Output: \verbinclude Cwise_minus.out 00202 * 00203 * \sa operator+(), operator-=() 00204 */ 00205 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 00206 operator-(const Scalar& scalar) const 00207 { 00208 return *this + (-scalar); 00209 } 00210 00211 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> > 00212 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) 00213 { 00214 return (-other) + scalar; 00215 } 00216 00217 /** \returns an expression of the coefficient-wise && operator of *this and \a other 00218 * 00219 * \warning this operator is for expression of bool only. 00220 * 00221 * Example: \include Cwise_boolean_and.cpp 00222 * Output: \verbinclude Cwise_boolean_and.out 00223 * 00224 * \sa operator||(), select() 00225 */ 00226 template<typename OtherDerived> 00227 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived> 00228 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00229 { 00230 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value), 00231 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL); 00232 return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived()); 00233 } 00234 00235 /** \returns an expression of the coefficient-wise || operator of *this and \a other 00236 * 00237 * \warning this operator is for expression of bool only. 00238 * 00239 * Example: \include Cwise_boolean_or.cpp 00240 * Output: \verbinclude Cwise_boolean_or.out 00241 * 00242 * \sa operator&&(), select() 00243 */ 00244 template<typename OtherDerived> 00245 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived> 00246 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00247 { 00248 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value), 00249 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL); 00250 return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived()); 00251 } 00252
Generated on Thu Nov 17 2022 22:01:27 by
1.7.2