Home | History | Annotate | Download | only in plugins
      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, const ConstantReturnType>
     37 (min)(const Scalar &other) const
     38 {
     39   return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
     40 }
     41 
     42 /** \returns an expression of the coefficient-wise max of \c *this and \a other
     43   *
     44   * Example: \include Cwise_max.cpp
     45   * Output: \verbinclude Cwise_max.out
     46   *
     47   * \sa min()
     48   */
     49 EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
     50 
     51 /** \returns an expression of the coefficient-wise max of \c *this and scalar \a other
     52   *
     53   * \sa min()
     54   */
     55 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const ConstantReturnType>
     56 (max)(const Scalar &other) const
     57 {
     58   return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
     59 }
     60 
     61 /** \returns an expression of the coefficient-wise \< operator of *this and \a other
     62   *
     63   * Example: \include Cwise_less.cpp
     64   * Output: \verbinclude Cwise_less.out
     65   *
     66   * \sa all(), any(), operator>(), operator<=()
     67   */
     68 EIGEN_MAKE_CWISE_BINARY_OP(operator<,std::less)
     69 
     70 /** \returns an expression of the coefficient-wise \<= operator of *this and \a other
     71   *
     72   * Example: \include Cwise_less_equal.cpp
     73   * Output: \verbinclude Cwise_less_equal.out
     74   *
     75   * \sa all(), any(), operator>=(), operator<()
     76   */
     77 EIGEN_MAKE_CWISE_BINARY_OP(operator<=,std::less_equal)
     78 
     79 /** \returns an expression of the coefficient-wise \> operator of *this and \a other
     80   *
     81   * Example: \include Cwise_greater.cpp
     82   * Output: \verbinclude Cwise_greater.out
     83   *
     84   * \sa all(), any(), operator>=(), operator<()
     85   */
     86 EIGEN_MAKE_CWISE_BINARY_OP(operator>,std::greater)
     87 
     88 /** \returns an expression of the coefficient-wise \>= operator of *this and \a other
     89   *
     90   * Example: \include Cwise_greater_equal.cpp
     91   * Output: \verbinclude Cwise_greater_equal.out
     92   *
     93   * \sa all(), any(), operator>(), operator<=()
     94   */
     95 EIGEN_MAKE_CWISE_BINARY_OP(operator>=,std::greater_equal)
     96 
     97 /** \returns an expression of the coefficient-wise == operator of *this and \a other
     98   *
     99   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
    100   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
    101   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
    102   * isMuchSmallerThan().
    103   *
    104   * Example: \include Cwise_equal_equal.cpp
    105   * Output: \verbinclude Cwise_equal_equal.out
    106   *
    107   * \sa all(), any(), isApprox(), isMuchSmallerThan()
    108   */
    109 EIGEN_MAKE_CWISE_BINARY_OP(operator==,std::equal_to)
    110 
    111 /** \returns an expression of the coefficient-wise != operator of *this and \a other
    112   *
    113   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
    114   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
    115   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
    116   * isMuchSmallerThan().
    117   *
    118   * Example: \include Cwise_not_equal.cpp
    119   * Output: \verbinclude Cwise_not_equal.out
    120   *
    121   * \sa all(), any(), isApprox(), isMuchSmallerThan()
    122   */
    123 EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to)
    124 
    125 // scalar addition
    126 
    127 /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar
    128   *
    129   * Example: \include Cwise_plus.cpp
    130   * Output: \verbinclude Cwise_plus.out
    131   *
    132   * \sa operator+=(), operator-()
    133   */
    134 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
    135 operator+(const Scalar& scalar) const
    136 {
    137   return CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>(derived(), internal::scalar_add_op<Scalar>(scalar));
    138 }
    139 
    140 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
    141 operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
    142 {
    143   return other + scalar;
    144 }
    145 
    146 /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar
    147   *
    148   * Example: \include Cwise_minus.cpp
    149   * Output: \verbinclude Cwise_minus.out
    150   *
    151   * \sa operator+(), operator-=()
    152   */
    153 inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
    154 operator-(const Scalar& scalar) const
    155 {
    156   return *this + (-scalar);
    157 }
    158 
    159 friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> >
    160 operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
    161 {
    162   return (-other) + scalar;
    163 }
    164 
    165 /** \returns an expression of the coefficient-wise && operator of *this and \a other
    166   *
    167   * \warning this operator is for expression of bool only.
    168   *
    169   * Example: \include Cwise_boolean_and.cpp
    170   * Output: \verbinclude Cwise_boolean_and.out
    171   *
    172   * \sa operator||(), select()
    173   */
    174 template<typename OtherDerived>
    175 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
    176 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
    177 {
    178   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
    179                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
    180   return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
    181 }
    182 
    183 /** \returns an expression of the coefficient-wise || operator of *this and \a other
    184   *
    185   * \warning this operator is for expression of bool only.
    186   *
    187   * Example: \include Cwise_boolean_or.cpp
    188   * Output: \verbinclude Cwise_boolean_or.out
    189   *
    190   * \sa operator&&(), select()
    191   */
    192 template<typename OtherDerived>
    193 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
    194 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
    195 {
    196   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
    197                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
    198   return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
    199 }
    200