Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:36

0001 
0002 /** \returns an expression of the coefficient wise product of \c *this and \a other
0003   *
0004   * \sa MatrixBase::cwiseProduct
0005   */
0006 template<typename OtherDerived>
0007 EIGEN_DEVICE_FUNC
0008 EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
0009 operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0010 {
0011   return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());
0012 }
0013 
0014 /** \returns an expression of the coefficient wise quotient of \c *this and \a other
0015   *
0016   * \sa MatrixBase::cwiseQuotient
0017   */
0018 template<typename OtherDerived>
0019 EIGEN_DEVICE_FUNC
0020 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>
0021 operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0022 {
0023   return CwiseBinaryOp<internal::scalar_quotient_op<Scalar,typename OtherDerived::Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0024 }
0025 
0026 /** \returns an expression of the coefficient-wise min of \c *this and \a other
0027   *
0028   * Example: \include Cwise_min.cpp
0029   * Output: \verbinclude Cwise_min.out
0030   *
0031   * \sa max()
0032   */
0033 EIGEN_MAKE_CWISE_BINARY_OP(min,min)
0034 
0035 /** \returns an expression of the coefficient-wise min of \c *this and scalar \a other
0036   *
0037   * \sa max()
0038   */
0039 EIGEN_DEVICE_FUNC
0040 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived,
0041                                         const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
0042 #ifdef EIGEN_PARSED_BY_DOXYGEN
0043 min
0044 #else
0045 (min)
0046 #endif
0047 (const Scalar &other) const
0048 {
0049   return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
0050 }
0051 
0052 /** \returns an expression of the coefficient-wise max of \c *this and \a other
0053   *
0054   * Example: \include Cwise_max.cpp
0055   * Output: \verbinclude Cwise_max.out
0056   *
0057   * \sa min()
0058   */
0059 EIGEN_MAKE_CWISE_BINARY_OP(max,max)
0060 
0061 /** \returns an expression of the coefficient-wise max of \c *this and scalar \a other
0062   *
0063   * \sa min()
0064   */
0065 EIGEN_DEVICE_FUNC
0066 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived,
0067                                         const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
0068 #ifdef EIGEN_PARSED_BY_DOXYGEN
0069 max
0070 #else
0071 (max)
0072 #endif
0073 (const Scalar &other) const
0074 {
0075   return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
0076 }
0077 
0078 /** \returns an expression of the coefficient-wise absdiff of \c *this and \a other
0079   *
0080   * Example: \include Cwise_absolute_difference.cpp
0081   * Output: \verbinclude Cwise_absolute_difference.out
0082   *
0083   * \sa absolute_difference()
0084   */
0085 EIGEN_MAKE_CWISE_BINARY_OP(absolute_difference,absolute_difference)
0086 
0087 /** \returns an expression of the coefficient-wise absolute_difference of \c *this and scalar \a other
0088   *
0089   * \sa absolute_difference()
0090   */
0091 EIGEN_DEVICE_FUNC
0092 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_absolute_difference_op<Scalar,Scalar>, const Derived,
0093                                         const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> >
0094 #ifdef EIGEN_PARSED_BY_DOXYGEN
0095 absolute_difference
0096 #else
0097 (absolute_difference)
0098 #endif
0099 (const Scalar &other) const
0100 {
0101   return (absolute_difference)(Derived::PlainObject::Constant(rows(), cols(), other));
0102 }
0103 
0104 /** \returns an expression of the coefficient-wise power of \c *this to the given array of \a exponents.
0105   *
0106   * This function computes the coefficient-wise power.
0107   *
0108   * Example: \include Cwise_array_power_array.cpp
0109   * Output: \verbinclude Cwise_array_power_array.out
0110   */
0111 EIGEN_MAKE_CWISE_BINARY_OP(pow,pow)
0112 
0113 #ifndef EIGEN_PARSED_BY_DOXYGEN
0114 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(pow,pow)
0115 #else
0116 /** \returns an expression of the coefficients of \c *this rasied to the constant power \a exponent
0117   *
0118   * \tparam T is the scalar type of \a exponent. It must be compatible with the scalar type of the given expression.
0119   *
0120   * This function computes the coefficient-wise power. The function MatrixBase::pow() in the
0121   * unsupported module MatrixFunctions computes the matrix power.
0122   *
0123   * Example: \include Cwise_pow.cpp
0124   * Output: \verbinclude Cwise_pow.out
0125   *
0126   * \sa ArrayBase::pow(ArrayBase), square(), cube(), exp(), log()
0127   */
0128 template<typename T>
0129 const CwiseBinaryOp<internal::scalar_pow_op<Scalar,T>,Derived,Constant<T> > pow(const T& exponent) const;
0130 #endif
0131 
0132 
0133 // TODO code generating macros could be moved to Macros.h and could include generation of documentation
0134 #define EIGEN_MAKE_CWISE_COMP_OP(OP, COMPARATOR) \
0135 template<typename OtherDerived> \
0136 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived> \
0137 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
0138 { \
0139   return CwiseBinaryOp<internal::scalar_cmp_op<Scalar, typename OtherDerived::Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const OtherDerived>(derived(), other.derived()); \
0140 }\
0141 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const Derived, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> > Cmp ## COMPARATOR ## ReturnType; \
0142 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar, internal::cmp_ ## COMPARATOR>, const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject>, const Derived > RCmp ## COMPARATOR ## ReturnType; \
0143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Cmp ## COMPARATOR ## ReturnType \
0144 OP(const Scalar& s) const { \
0145   return this->OP(Derived::PlainObject::Constant(rows(), cols(), s)); \
0146 } \
0147 EIGEN_DEVICE_FUNC friend EIGEN_STRONG_INLINE const RCmp ## COMPARATOR ## ReturnType \
0148 OP(const Scalar& s, const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& d) { \
0149   return Derived::PlainObject::Constant(d.rows(), d.cols(), s).OP(d); \
0150 }
0151 
0152 #define EIGEN_MAKE_CWISE_COMP_R_OP(OP, R_OP, RCOMPARATOR) \
0153 template<typename OtherDerived> \
0154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived> \
0155 OP(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
0156 { \
0157   return CwiseBinaryOp<internal::scalar_cmp_op<typename OtherDerived::Scalar, Scalar, internal::cmp_##RCOMPARATOR>, const OtherDerived, const Derived>(other.derived(), derived()); \
0158 } \
0159 EIGEN_DEVICE_FUNC \
0160 inline const RCmp ## RCOMPARATOR ## ReturnType \
0161 OP(const Scalar& s) const { \
0162   return Derived::PlainObject::Constant(rows(), cols(), s).R_OP(*this); \
0163 } \
0164 friend inline const Cmp ## RCOMPARATOR ## ReturnType \
0165 OP(const Scalar& s, const Derived& d) { \
0166   return d.R_OP(Derived::PlainObject::Constant(d.rows(), d.cols(), s)); \
0167 }
0168 
0169 
0170 
0171 /** \returns an expression of the coefficient-wise \< operator of *this and \a other
0172   *
0173   * Example: \include Cwise_less.cpp
0174   * Output: \verbinclude Cwise_less.out
0175   *
0176   * \sa all(), any(), operator>(), operator<=()
0177   */
0178 EIGEN_MAKE_CWISE_COMP_OP(operator<, LT)
0179 
0180 /** \returns an expression of the coefficient-wise \<= operator of *this and \a other
0181   *
0182   * Example: \include Cwise_less_equal.cpp
0183   * Output: \verbinclude Cwise_less_equal.out
0184   *
0185   * \sa all(), any(), operator>=(), operator<()
0186   */
0187 EIGEN_MAKE_CWISE_COMP_OP(operator<=, LE)
0188 
0189 /** \returns an expression of the coefficient-wise \> operator of *this and \a other
0190   *
0191   * Example: \include Cwise_greater.cpp
0192   * Output: \verbinclude Cwise_greater.out
0193   *
0194   * \sa all(), any(), operator>=(), operator<()
0195   */
0196 EIGEN_MAKE_CWISE_COMP_R_OP(operator>, operator<, LT)
0197 
0198 /** \returns an expression of the coefficient-wise \>= operator of *this and \a other
0199   *
0200   * Example: \include Cwise_greater_equal.cpp
0201   * Output: \verbinclude Cwise_greater_equal.out
0202   *
0203   * \sa all(), any(), operator>(), operator<=()
0204   */
0205 EIGEN_MAKE_CWISE_COMP_R_OP(operator>=, operator<=, LE)
0206 
0207 /** \returns an expression of the coefficient-wise == operator of *this and \a other
0208   *
0209   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
0210   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
0211   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
0212   * isMuchSmallerThan().
0213   *
0214   * Example: \include Cwise_equal_equal.cpp
0215   * Output: \verbinclude Cwise_equal_equal.out
0216   *
0217   * \sa all(), any(), isApprox(), isMuchSmallerThan()
0218   */
0219 EIGEN_MAKE_CWISE_COMP_OP(operator==, EQ)
0220 
0221 /** \returns an expression of the coefficient-wise != operator of *this and \a other
0222   *
0223   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
0224   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
0225   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
0226   * isMuchSmallerThan().
0227   *
0228   * Example: \include Cwise_not_equal.cpp
0229   * Output: \verbinclude Cwise_not_equal.out
0230   *
0231   * \sa all(), any(), isApprox(), isMuchSmallerThan()
0232   */
0233 EIGEN_MAKE_CWISE_COMP_OP(operator!=, NEQ)
0234 
0235 
0236 #undef EIGEN_MAKE_CWISE_COMP_OP
0237 #undef EIGEN_MAKE_CWISE_COMP_R_OP
0238 
0239 // scalar addition
0240 #ifndef EIGEN_PARSED_BY_DOXYGEN
0241 EIGEN_MAKE_SCALAR_BINARY_OP(operator+,sum)
0242 #else
0243 /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar
0244   *
0245   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0246   *
0247   * Example: \include Cwise_plus.cpp
0248   * Output: \verbinclude Cwise_plus.out
0249   *
0250   * \sa operator+=(), operator-()
0251   */
0252 template<typename T>
0253 const CwiseBinaryOp<internal::scalar_sum_op<Scalar,T>,Derived,Constant<T> > operator+(const T& scalar) const;
0254 /** \returns an expression of \a expr with each coeff incremented by the constant \a scalar
0255   *
0256   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0257   */
0258 template<typename T> friend
0259 const CwiseBinaryOp<internal::scalar_sum_op<T,Scalar>,Constant<T>,Derived> operator+(const T& scalar, const StorageBaseType& expr);
0260 #endif
0261 
0262 #ifndef EIGEN_PARSED_BY_DOXYGEN
0263 EIGEN_MAKE_SCALAR_BINARY_OP(operator-,difference)
0264 #else
0265 /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar
0266   *
0267   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0268   *
0269   * Example: \include Cwise_minus.cpp
0270   * Output: \verbinclude Cwise_minus.out
0271   *
0272   * \sa operator+=(), operator-()
0273   */
0274 template<typename T>
0275 const CwiseBinaryOp<internal::scalar_difference_op<Scalar,T>,Derived,Constant<T> > operator-(const T& scalar) const;
0276 /** \returns an expression of the constant matrix of value \a scalar decremented by the coefficients of \a expr
0277   *
0278   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0279   */
0280 template<typename T> friend
0281 const CwiseBinaryOp<internal::scalar_difference_op<T,Scalar>,Constant<T>,Derived> operator-(const T& scalar, const StorageBaseType& expr);
0282 #endif
0283 
0284 
0285 #ifndef EIGEN_PARSED_BY_DOXYGEN
0286   EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(operator/,quotient)
0287 #else
0288   /**
0289     * \brief Component-wise division of the scalar \a s by array elements of \a a.
0290     *
0291     * \tparam Scalar is the scalar type of \a x. It must be compatible with the scalar type of the given array expression (\c Derived::Scalar).
0292     */
0293   template<typename T> friend
0294   inline const CwiseBinaryOp<internal::scalar_quotient_op<T,Scalar>,Constant<T>,Derived>
0295   operator/(const T& s,const StorageBaseType& a);
0296 #endif
0297 
0298 /** \returns an expression of the coefficient-wise ^ operator of *this and \a other
0299  *
0300  * \warning this operator is for expression of bool only.
0301  *
0302  * Example: \include Cwise_boolean_xor.cpp
0303  * Output: \verbinclude Cwise_boolean_xor.out
0304  *
0305  * \sa operator&&(), select()
0306  */
0307 template<typename OtherDerived>
0308 EIGEN_DEVICE_FUNC
0309 inline const CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>
0310 operator^(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0311 {
0312   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
0313                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
0314   return CwiseBinaryOp<internal::scalar_boolean_xor_op, const Derived, const OtherDerived>(derived(),other.derived());
0315 }
0316 
0317 // NOTE disabled until we agree on argument order
0318 #if 0
0319 /** \cpp11 \returns an expression of the coefficient-wise polygamma function.
0320   *
0321   * \specialfunctions_module
0322   *
0323   * It returns the \a n -th derivative of the digamma(psi) evaluated at \c *this.
0324   *
0325   * \warning Be careful with the order of the parameters: x.polygamma(n) is equivalent to polygamma(n,x)
0326   *
0327   * \sa RivetEigen::polygamma()
0328   */
0329 template<typename DerivedN>
0330 inline const CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>
0331 polygamma(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedN> &n) const
0332 {
0333   return CwiseBinaryOp<internal::scalar_polygamma_op<Scalar>, const DerivedN, const Derived>(n.derived(), this->derived());
0334 }
0335 #endif
0336 
0337 /** \returns an expression of the coefficient-wise zeta function.
0338   *
0339   * \specialfunctions_module
0340   *
0341   * It returns the Riemann zeta function of two arguments \c *this and \a q:
0342   *
0343   * \param q is the shift, it must be > 0
0344   *
0345   * \note *this is the exponent, it must be > 1.
0346   * \note This function supports only float and double scalar types. To support other scalar types, the user has
0347   * to provide implementations of zeta(T,T) for any scalar type T to be supported.
0348   *
0349   * This method is an alias for zeta(*this,q);
0350   *
0351   * \sa RivetEigen::zeta()
0352   */
0353 template<typename DerivedQ>
0354 inline const CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>
0355 zeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS<DerivedQ> &q) const
0356 {
0357   return CwiseBinaryOp<internal::scalar_zeta_op<Scalar>, const Derived, const DerivedQ>(this->derived(), q.derived());
0358 }