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