Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:56:38

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
0005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 // This file is a base class plugin containing common coefficient wise functions.
0012 
0013 /** \returns an expression of the difference of \c *this and \a other
0014   *
0015   * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-().
0016   *
0017   * \sa class CwiseBinaryOp, operator-=()
0018   */
0019 EIGEN_MAKE_CWISE_BINARY_OP(operator-,difference)
0020 
0021 /** \returns an expression of the sum of \c *this and \a other
0022   *
0023   * \note If you want to add a given scalar to all coefficients, see Cwise::operator+().
0024   *
0025   * \sa class CwiseBinaryOp, operator+=()
0026   */
0027 EIGEN_MAKE_CWISE_BINARY_OP(operator+,sum)
0028 
0029 /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
0030   *
0031   * The template parameter \a CustomBinaryOp is the type of the functor
0032   * of the custom operator (see class CwiseBinaryOp for an example)
0033   *
0034   * Here is an example illustrating the use of custom functors:
0035   * \include class_CwiseBinaryOp.cpp
0036   * Output: \verbinclude class_CwiseBinaryOp.out
0037   *
0038   * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct()
0039   */
0040 template<typename CustomBinaryOp, typename OtherDerived>
0041 EIGEN_DEVICE_FUNC
0042 EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
0043 binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const
0044 {
0045   return CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>(derived(), other.derived(), func);
0046 }
0047 
0048 
0049 #ifndef EIGEN_PARSED_BY_DOXYGEN
0050 EIGEN_MAKE_SCALAR_BINARY_OP(operator*,product)
0051 #else
0052 /** \returns an expression of \c *this scaled by the scalar factor \a scalar
0053   *
0054   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0055   */
0056 template<typename T>
0057 const CwiseBinaryOp<internal::scalar_product_op<Scalar,T>,Derived,Constant<T> > operator*(const T& scalar) const;
0058 /** \returns an expression of \a expr scaled by the scalar factor \a scalar
0059   *
0060   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0061   */
0062 template<typename T> friend
0063 const CwiseBinaryOp<internal::scalar_product_op<T,Scalar>,Constant<T>,Derived> operator*(const T& scalar, const StorageBaseType& expr);
0064 #endif
0065 
0066 
0067 
0068 #ifndef EIGEN_PARSED_BY_DOXYGEN
0069 EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(operator/,quotient)
0070 #else
0071 /** \returns an expression of \c *this divided by the scalar value \a scalar
0072   *
0073   * \tparam T is the scalar type of \a scalar. It must be compatible with the scalar type of the given expression.
0074   */
0075 template<typename T>
0076 const CwiseBinaryOp<internal::scalar_quotient_op<Scalar,T>,Derived,Constant<T> > operator/(const T& scalar) const;
0077 #endif
0078 
0079 /** \returns an expression of the coefficient-wise boolean \b and operator of \c *this and \a other
0080   *
0081   * \warning this operator is for expression of bool only.
0082   *
0083   * Example: \include Cwise_boolean_and.cpp
0084   * Output: \verbinclude Cwise_boolean_and.out
0085   *
0086   * \sa operator||(), select()
0087   */
0088 template<typename OtherDerived>
0089 EIGEN_DEVICE_FUNC
0090 inline const CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>
0091 operator&&(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0092 {
0093   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
0094                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
0095   return CwiseBinaryOp<internal::scalar_boolean_and_op, const Derived, const OtherDerived>(derived(),other.derived());
0096 }
0097 
0098 /** \returns an expression of the coefficient-wise boolean \b or operator of \c *this and \a other
0099   *
0100   * \warning this operator is for expression of bool only.
0101   *
0102   * Example: \include Cwise_boolean_or.cpp
0103   * Output: \verbinclude Cwise_boolean_or.out
0104   *
0105   * \sa operator&&(), select()
0106   */
0107 template<typename OtherDerived>
0108 EIGEN_DEVICE_FUNC
0109 inline const CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>
0110 operator||(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0111 {
0112   EIGEN_STATIC_ASSERT((internal::is_same<bool,Scalar>::value && internal::is_same<bool,typename OtherDerived::Scalar>::value),
0113                       THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL);
0114   return CwiseBinaryOp<internal::scalar_boolean_or_op, const Derived, const OtherDerived>(derived(),other.derived());
0115 }