1 /** \returns an expression of the coefficient wise product of \c *this and \a other 2 * 3 * \sa MatrixBase::cwiseProduct 4 */ 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 12 /** \returns an expression of the coefficient wise quotient of \c *this and \a other 13 * 14 * \sa MatrixBase::cwiseQuotient 15 */ 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 23 /** \returns an expression of the coefficient-wise min of \c *this and \a other 24 * 25 * Example: \include Cwise_min.cpp 26 * Output: \verbinclude Cwise_min.out 27 * 28 * \sa max() 29 */ 30 EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op) 31 32 /** \returns an expression of the coefficient-wise min of \c *this and scalar \a other 33 * 34 * \sa max() 35 */ 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 48 /** \returns an expression of the coefficient-wise max of \c *this and \a other 49 * 50 * Example: \include Cwise_max.cpp 51 * Output: \verbinclude Cwise_max.out 52 * 53 * \sa min() 54 */ 55 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op) 56 57 /** \returns an expression of the coefficient-wise max of \c *this and scalar \a other 58 * 59 * \sa min() 60 */ 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 /** \returns an expression of the coefficient-wise \< operator of *this and \a other 74 * 75 * Example: \include Cwise_less.cpp 76 * Output: \verbinclude Cwise_less.out 77 * 78 * \sa all(), any(), operator>(), operator<=() 79 */ 80 EIGEN_MAKE_CWISE_BINARY_OP(operator<,std::less) 81 82 /** \returns an expression of the coefficient-wise \<= operator of *this and \a other 83 * 84 * Example: \include Cwise_less_equal.cpp 85 * Output: \verbinclude Cwise_less_equal.out 86 * 87 * \sa all(), any(), operator>=(), operator<() 88 */ 89 EIGEN_MAKE_CWISE_BINARY_OP(operator<=,std::less_equal) 90 91 /** \returns an expression of the coefficient-wise \> operator of *this and \a other 92 * 93 * Example: \include Cwise_greater.cpp 94 * Output: \verbinclude Cwise_greater.out 95 * 96 * \sa all(), any(), operator>=(), operator<() 97 */ 98 EIGEN_MAKE_CWISE_BINARY_OP(operator>,std::greater) 99 100 /** \returns an expression of the coefficient-wise \>= operator of *this and \a other 101 * 102 * Example: \include Cwise_greater_equal.cpp 103 * Output: \verbinclude Cwise_greater_equal.out 104 * 105 * \sa all(), any(), operator>(), operator<=() 106 */ 107 EIGEN_MAKE_CWISE_BINARY_OP(operator>=,std::greater_equal) 108 109 /** \returns an expression of the coefficient-wise == operator of *this and \a other 110 * 111 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 112 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 113 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 114 * isMuchSmallerThan(). 115 * 116 * Example: \include Cwise_equal_equal.cpp 117 * Output: \verbinclude Cwise_equal_equal.out 118 * 119 * \sa all(), any(), isApprox(), isMuchSmallerThan() 120 */ 121 EIGEN_MAKE_CWISE_BINARY_OP(operator==,std::equal_to) 122 123 /** \returns an expression of the coefficient-wise != operator of *this and \a other 124 * 125 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 126 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 127 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 128 * isMuchSmallerThan(). 129 * 130 * Example: \include Cwise_not_equal.cpp 131 * Output: \verbinclude Cwise_not_equal.out 132 * 133 * \sa all(), any(), isApprox(), isMuchSmallerThan() 134 */ 135 EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to) 136 137 // scalar addition 138 139 /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar 140 * 141 * Example: \include Cwise_plus.cpp 142 * Output: \verbinclude Cwise_plus.out 143 * 144 * \sa operator+=(), operator-() 145 */ 146 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 147 operator+(const Scalar& scalar) const 148 { 149 return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar)); 150 } 151 152 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 153 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) 154 { 155 return other + scalar; 156 } 157 158 /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar 159 * 160 * Example: \include Cwise_minus.cpp 161 * Output: \verbinclude Cwise_minus.out 162 * 163 * \sa operator+(), operator-=() 164 */ 165 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived> 166 operator-(const Scalar& scalar) const 167 { 168 return *this + (-scalar); 169 } 170 171 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> > 172 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other) 173 { 174 return (-other) + scalar; 175 } 176 177 /** \returns an expression of the coefficient-wise && operator of *this and \a other 178 * 179 * \warning this operator is for expression of bool only. 180 * 181 * Example: \include Cwise_boolean_and.cpp 182 * Output: \verbinclude Cwise_boolean_and.out 183 * 184 * \sa operator||(), select() 185 */ 186 template<typename OtherDerived> 187 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived> 188 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 189 { 190 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value), 191 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL); 192 return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived()); 193 } 194 195 /** \returns an expression of the coefficient-wise || operator of *this and \a other 196 * 197 * \warning this operator is for expression of bool only. 198 * 199 * Example: \include Cwise_boolean_or.cpp 200 * Output: \verbinclude Cwise_boolean_or.out 201 * 202 * \sa operator&&(), select() 203 */ 204 template<typename OtherDerived> 205 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived> 206 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 207 { 208 EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value), 209 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL); 210 return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived()); 211 } 212