Cwise.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@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 #ifndef EIGEN_CWISE_H
12 #define EIGEN_CWISE_H
13 
14 namespace Eigen {
15 
18 #define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
19  CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
20 
23 #define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
24  CwiseUnaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType>
25 
28 #define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
29  CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, \
30  typename ExpressionType::ConstantReturnType >
31 
50 template<typename ExpressionType> class Cwise
51 {
52  public:
53 
56  ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
58 
59  inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
60 
62  inline const ExpressionType& _expression() const { return m_matrix; }
63 
64  template<typename OtherDerived>
65  const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
66  operator*(const MatrixBase<OtherDerived> &other) const;
67 
68  template<typename OtherDerived>
70  operator/(const MatrixBase<OtherDerived> &other) const;
71 
73  template<typename OtherDerived>
75  (min)(const MatrixBase<OtherDerived> &other) const
77 
79  template<typename OtherDerived>
81  (max)(const MatrixBase<OtherDerived> &other) const
83 
94  const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op) pow(const Scalar& exponent) const;
95 
97  operator+(const Scalar& scalar) const;
98 
100  friend const ScalarAddReturnType
101  operator+(const Scalar& scalar, const Cwise& mat)
102  { return mat + scalar; }
103 
104  ExpressionType& operator+=(const Scalar& scalar);
105 
106  const ScalarAddReturnType
107  operator-(const Scalar& scalar) const;
108 
109  ExpressionType& operator-=(const Scalar& scalar);
110 
111  template<typename OtherDerived>
112  inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
113 
114  template<typename OtherDerived>
115  inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
116 
117  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
118  operator<(const MatrixBase<OtherDerived>& other) const;
119 
120  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
121  operator<=(const MatrixBase<OtherDerived>& other) const;
122 
123  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
124  operator>(const MatrixBase<OtherDerived>& other) const;
125 
126  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
127  operator>=(const MatrixBase<OtherDerived>& other) const;
128 
129  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
130  operator==(const MatrixBase<OtherDerived>& other) const;
131 
132  template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
133  operator!=(const MatrixBase<OtherDerived>& other) const;
134 
135  // comparisons to a scalar value
137  operator<(Scalar s) const;
138 
139  const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
140  operator<=(Scalar s) const;
141 
142  const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
143  operator>(Scalar s) const;
144 
145  const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
146  operator>=(Scalar s) const;
147 
148  const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
149  operator==(Scalar s) const;
150 
151  const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
152  operator!=(Scalar s) const;
153 
154  // allow to extend Cwise outside Eigen
155  #ifdef EIGEN_CWISE_PLUGIN
156  #include EIGEN_CWISE_PLUGIN
157  #endif
158 
159  protected:
161 };
162 
163 
171 template<typename Derived>
172 inline const Cwise<Derived> MatrixBase<Derived>::cwise() const
173 {
174  return derived();
175 }
176 
184 template<typename Derived>
186 {
187  return derived();
188 }
189 
190 } // end namespace Eigen
191 
192 #endif // EIGEN_CWISE_H
friend const ScalarAddReturnType operator+(const Scalar &scalar, const Cwise &mat)
Definition: Cwise.h:101
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar >, const Derived > pow(const Eigen::ArrayBase< Derived > &x, const typename Derived::Scalar &exponent)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_mult_op< typename Derived::Scalar >, const Derived > operator/(const typename Derived::Scalar &s, const Eigen::ArrayBase< Derived > &a)
Component-wise division of a scalar by array elements.
bool operator>(const TransformStorage &lhs, const TransformStorage &rhs)
const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op) abs() const
TFSIMD_FORCE_INLINE bool operator==(const Matrix3x3 &m1, const Matrix3x3 &m2)
ExpressionType & operator-=(const Scalar &scalar)
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) operator<(Scalar s) const
XmlRpcServer s
CwiseUnaryOp< internal::scalar_add_op< Scalar >, ExpressionType > ScalarAddReturnType
Definition: Cwise.h:57
const EIGEN_CWISE_BINOP_RETURN_TYPE() internal::scalar_max_op() max(const MatrixBase< OtherDerived > &other) const
Definition: Cwise.h:81
Definition: LDLT.h:16
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
const ExpressionType & _expression() const
Definition: Cwise.h:62
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
internal::conditional< internal::must_nest_by_value< ExpressionType >::ret, ExpressionType, const ExpressionType & >::type ExpressionTypeNested
Definition: Cwise.h:56
const CwiseUnaryOp< internal::scalar_square_op< Scalar >, const Derived > square() const
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
const CwiseUnaryOp< internal::scalar_inverse_op< Scalar >, const Derived > inverse() const
Pseudo expression providing additional coefficient-wise operations.
Definition: Cwise.h:50
const CwiseUnaryOp< internal::scalar_cube_op< Scalar >, const Derived > cube() const
ExpressionType & operator+=(const Scalar &scalar)
const EIGEN_CWISE_BINOP_RETURN_TYPE() internal::scalar_min_op() min(const MatrixBase< OtherDerived > &other) const
Definition: Cwise.h:75
const CwiseUnaryOp< internal::scalar_log_op< Scalar >, const Derived > log() const
TFSIMD_FORCE_INLINE bool operator!=(const Vector3 &other) const
const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType, OtherDerived) operator*(const MatrixBase< OtherDerived > &other) const
const CwiseUnaryOp< internal::scalar_sin_op< Scalar >, const Derived > sin() const
internal::traits< ExpressionType >::Scalar Scalar
Definition: Cwise.h:54
const ScalarAddReturnType operator+(const Scalar &scalar) const
const CwiseUnaryOp< internal::scalar_cos_op< Scalar >, const Derived > cos() const
Cwise(const ExpressionType &matrix)
Definition: Cwise.h:59
const CwiseUnaryOp< internal::scalar_sqrt_op< Scalar >, const Derived > sqrt() const
const ScalarAddReturnType operator-(const Scalar &scalar) const
const CwiseUnaryOp< internal::scalar_exp_op< Scalar >, const Derived > exp() const
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:59
ExpressionType & operator/=(const MatrixBase< OtherDerived > &other)
ExpressionTypeNested m_matrix
Definition: Cwise.h:160
const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op) operator/(const MatrixBase< OtherDerived > &other) const
ExpressionType & operator*=(const MatrixBase< OtherDerived > &other)
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:47