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-2009 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 matrix specifics coefficient wise functions.
0012 
0013 /** \returns an expression of the Schur product (coefficient wise product) of *this and \a other
0014   *
0015   * Example: \include MatrixBase_cwiseProduct.cpp
0016   * Output: \verbinclude MatrixBase_cwiseProduct.out
0017   *
0018   * \sa class CwiseBinaryOp, cwiseAbs2
0019   */
0020 template<typename OtherDerived>
0021 EIGEN_DEVICE_FUNC
0022 EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
0023 cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0024 {
0025   return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());
0026 }
0027 
0028 /** \returns an expression of the coefficient-wise == operator of *this and \a other
0029   *
0030   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
0031   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
0032   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
0033   * isMuchSmallerThan().
0034   *
0035   * Example: \include MatrixBase_cwiseEqual.cpp
0036   * Output: \verbinclude MatrixBase_cwiseEqual.out
0037   *
0038   * \sa cwiseNotEqual(), isApprox(), isMuchSmallerThan()
0039   */
0040 template<typename OtherDerived>
0041 EIGEN_DEVICE_FUNC
0042 inline const CwiseBinaryOp<numext::equal_to<Scalar>, const Derived, const OtherDerived>
0043 cwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0044 {
0045   return CwiseBinaryOp<numext::equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0046 }
0047 
0048 /** \returns an expression of the coefficient-wise != operator of *this and \a other
0049   *
0050   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
0051   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
0052   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
0053   * isMuchSmallerThan().
0054   *
0055   * Example: \include MatrixBase_cwiseNotEqual.cpp
0056   * Output: \verbinclude MatrixBase_cwiseNotEqual.out
0057   *
0058   * \sa cwiseEqual(), isApprox(), isMuchSmallerThan()
0059   */
0060 template<typename OtherDerived>
0061 EIGEN_DEVICE_FUNC
0062 inline const CwiseBinaryOp<numext::not_equal_to<Scalar>, const Derived, const OtherDerived>
0063 cwiseNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0064 {
0065   return CwiseBinaryOp<numext::not_equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0066 }
0067 
0068 /** \returns an expression of the coefficient-wise min of *this and \a other
0069   *
0070   * Example: \include MatrixBase_cwiseMin.cpp
0071   * Output: \verbinclude MatrixBase_cwiseMin.out
0072   *
0073   * \sa class CwiseBinaryOp, max()
0074   */
0075 template<typename OtherDerived>
0076 EIGEN_DEVICE_FUNC
0077 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const OtherDerived>
0078 cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0079 {
0080   return CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0081 }
0082 
0083 /** \returns an expression of the coefficient-wise min of *this and scalar \a other
0084   *
0085   * \sa class CwiseBinaryOp, min()
0086   */
0087 EIGEN_DEVICE_FUNC
0088 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar,Scalar>, const Derived, const ConstantReturnType>
0089 cwiseMin(const Scalar &other) const
0090 {
0091   return cwiseMin(Derived::Constant(rows(), cols(), other));
0092 }
0093 
0094 /** \returns an expression of the coefficient-wise max of *this and \a other
0095   *
0096   * Example: \include MatrixBase_cwiseMax.cpp
0097   * Output: \verbinclude MatrixBase_cwiseMax.out
0098   *
0099   * \sa class CwiseBinaryOp, min()
0100   */
0101 template<typename OtherDerived>
0102 EIGEN_DEVICE_FUNC
0103 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const OtherDerived>
0104 cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0105 {
0106   return CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0107 }
0108 
0109 /** \returns an expression of the coefficient-wise max of *this and scalar \a other
0110   *
0111   * \sa class CwiseBinaryOp, min()
0112   */
0113 EIGEN_DEVICE_FUNC
0114 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar,Scalar>, const Derived, const ConstantReturnType>
0115 cwiseMax(const Scalar &other) const
0116 {
0117   return cwiseMax(Derived::Constant(rows(), cols(), other));
0118 }
0119 
0120 
0121 /** \returns an expression of the coefficient-wise quotient of *this and \a other
0122   *
0123   * Example: \include MatrixBase_cwiseQuotient.cpp
0124   * Output: \verbinclude MatrixBase_cwiseQuotient.out
0125   *
0126   * \sa class CwiseBinaryOp, cwiseProduct(), cwiseInverse()
0127   */
0128 template<typename OtherDerived>
0129 EIGEN_DEVICE_FUNC
0130 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>
0131 cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
0132 {
0133   return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived());
0134 }
0135 
0136 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,Scalar,internal::cmp_EQ>, const Derived, const ConstantReturnType> CwiseScalarEqualReturnType;
0137 
0138 /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s
0139   *
0140   * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
0141   * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
0142   * generally a far better idea to use a fuzzy comparison as provided by isApprox() and
0143   * isMuchSmallerThan().
0144   *
0145   * \sa cwiseEqual(const MatrixBase<OtherDerived> &) const
0146   */
0147 EIGEN_DEVICE_FUNC
0148 inline const CwiseScalarEqualReturnType
0149 cwiseEqual(const Scalar& s) const
0150 {
0151   return CwiseScalarEqualReturnType(derived(), Derived::Constant(rows(), cols(), s), internal::scalar_cmp_op<Scalar,Scalar,internal::cmp_EQ>());
0152 }