1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library 2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra. 3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr> 5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> 6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla 8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed 9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is a base class plugin containing matrix specifics coefficient wise functions. 12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the coefficient-wise absolute value of \c *this 14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Example: \include MatrixBase_cwiseAbs.cpp 16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Output: \verbinclude MatrixBase_cwiseAbs.out 17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa cwiseAbs2() 19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> 21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathcwiseAbs() const { return derived(); } 22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the coefficient-wise squared absolute value of \c *this 24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Example: \include MatrixBase_cwiseAbs2.cpp 26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Output: \verbinclude MatrixBase_cwiseAbs2.out 27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa cwiseAbs() 29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> 31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathcwiseAbs2() const { return derived(); } 32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the coefficient-wise square root of *this. 34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Example: \include MatrixBase_cwiseSqrt.cpp 36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Output: \verbinclude MatrixBase_cwiseSqrt.out 37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa cwisePow(), cwiseSquare() 39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> 41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathcwiseSqrt() const { return derived(); } 42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the coefficient-wise inverse of *this. 44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Example: \include MatrixBase_cwiseInverse.cpp 46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * Output: \verbinclude MatrixBase_cwiseInverse.out 47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa cwiseProduct() 49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> 51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathcwiseInverse() const { return derived(); } 52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * isMuchSmallerThan(). 59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * 60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath * \sa cwiseEqual(const MatrixBase<OtherDerived> &) const 61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath */ 62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline const CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> 63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathcwiseEqual(const Scalar& s) const 64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath return CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >,const Derived> 66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath (derived(), std::bind1st(std::equal_to<Scalar>(), s)); 67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 68