Eigne Matrix Class Library
Dependents: Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more
MatrixCwiseBinaryOps.h
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr> 00005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> 00006 // 00007 // This Source Code Form is subject to the terms of the Mozilla 00008 // Public License v. 2.0. If a copy of the MPL was not distributed 00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00010 00011 // This file is a base class plugin containing matrix specifics coefficient wise functions. 00012 00013 /** \returns an expression of the Schur product (coefficient wise product) of *this and \a other 00014 * 00015 * Example: \include MatrixBase_cwiseProduct.cpp 00016 * Output: \verbinclude MatrixBase_cwiseProduct.out 00017 * 00018 * \sa class CwiseBinaryOp, cwiseAbs2 00019 */ 00020 template<typename OtherDerived> 00021 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived) 00022 cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00023 { 00024 return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived()); 00025 } 00026 00027 /** \returns an expression of the coefficient-wise == operator of *this and \a other 00028 * 00029 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 00030 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 00031 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 00032 * isMuchSmallerThan(). 00033 * 00034 * Example: \include MatrixBase_cwiseEqual.cpp 00035 * Output: \verbinclude MatrixBase_cwiseEqual.out 00036 * 00037 * \sa cwiseNotEqual(), isApprox(), isMuchSmallerThan() 00038 */ 00039 template<typename OtherDerived> 00040 inline const CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived> 00041 cwiseEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00042 { 00043 return CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00044 } 00045 00046 /** \returns an expression of the coefficient-wise != operator of *this and \a other 00047 * 00048 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 00049 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 00050 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 00051 * isMuchSmallerThan(). 00052 * 00053 * Example: \include MatrixBase_cwiseNotEqual.cpp 00054 * Output: \verbinclude MatrixBase_cwiseNotEqual.out 00055 * 00056 * \sa cwiseEqual(), isApprox(), isMuchSmallerThan() 00057 */ 00058 template<typename OtherDerived> 00059 inline const CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived> 00060 cwiseNotEqual(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00061 { 00062 return CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00063 } 00064 00065 /** \returns an expression of the coefficient-wise min of *this and \a other 00066 * 00067 * Example: \include MatrixBase_cwiseMin.cpp 00068 * Output: \verbinclude MatrixBase_cwiseMin.out 00069 * 00070 * \sa class CwiseBinaryOp, max() 00071 */ 00072 template<typename OtherDerived> 00073 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, const OtherDerived> 00074 cwiseMin(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00075 { 00076 return CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00077 } 00078 00079 /** \returns an expression of the coefficient-wise min of *this and scalar \a other 00080 * 00081 * \sa class CwiseBinaryOp, min() 00082 */ 00083 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, const ConstantReturnType> 00084 cwiseMin(const Scalar &other) const 00085 { 00086 return cwiseMin(Derived::Constant(rows(), cols(), other)); 00087 } 00088 00089 /** \returns an expression of the coefficient-wise max of *this and \a other 00090 * 00091 * Example: \include MatrixBase_cwiseMax.cpp 00092 * Output: \verbinclude MatrixBase_cwiseMax.out 00093 * 00094 * \sa class CwiseBinaryOp, min() 00095 */ 00096 template<typename OtherDerived> 00097 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const OtherDerived> 00098 cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00099 { 00100 return CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00101 } 00102 00103 /** \returns an expression of the coefficient-wise max of *this and scalar \a other 00104 * 00105 * \sa class CwiseBinaryOp, min() 00106 */ 00107 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const ConstantReturnType> 00108 cwiseMax(const Scalar &other) const 00109 { 00110 return cwiseMax(Derived::Constant(rows(), cols(), other)); 00111 } 00112 00113 00114 /** \returns an expression of the coefficient-wise quotient of *this and \a other 00115 * 00116 * Example: \include MatrixBase_cwiseQuotient.cpp 00117 * Output: \verbinclude MatrixBase_cwiseQuotient.out 00118 * 00119 * \sa class CwiseBinaryOp, cwiseProduct(), cwiseInverse() 00120 */ 00121 template<typename OtherDerived> 00122 EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived> 00123 cwiseQuotient(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const 00124 { 00125 return CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived>(derived(), other.derived()); 00126 } 00127 00128 typedef CwiseBinaryOp<internal::scalar_cmp_op<Scalar,internal::cmp_EQ>, const Derived, const ConstantReturnType> CwiseScalarEqualReturnType; 00129 00130 /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 00131 * 00132 * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 00133 * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 00134 * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 00135 * isMuchSmallerThan(). 00136 * 00137 * \sa cwiseEqual(const MatrixBase<OtherDerived> &) const 00138 */ 00139 inline const CwiseScalarEqualReturnType 00140 cwiseEqual(const Scalar& s) const 00141 { 00142 return CwiseScalarEqualReturnType(derived(), Derived::Constant(rows(), cols(), s), internal::scalar_cmp_op<Scalar,internal::cmp_EQ>()); 00143 }
Generated on Tue Jul 12 2022 17:46:58 by 1.7.2