Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_CWISE_H
00027 #define EIGEN_CWISE_H
00028
00029
00030
00031 #define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
00032 CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
00033
00034
00035
00036 #define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
00037 CwiseUnaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType>
00038
00039
00040
00041 #define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
00042 CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, \
00043 typename ExpressionType::ConstantReturnType >
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 template<typename ExpressionType> class Cwise
00061 {
00062 public:
00063
00064 typedef typename internal::traits<ExpressionType>::Scalar Scalar;
00065 typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
00066 ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
00067 typedef CwiseUnaryOp<internal::scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
00068
00069 inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
00070
00071
00072 inline const ExpressionType& _expression() const { return m_matrix; }
00073
00074 template<typename OtherDerived>
00075 const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
00076 operator*(const MatrixBase<OtherDerived> &other) const;
00077
00078 template<typename OtherDerived>
00079 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)
00080 operator/(const MatrixBase<OtherDerived> &other) const;
00081
00082 template<typename OtherDerived>
00083 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_min_op)
00084 min(const MatrixBase<OtherDerived> &other) const;
00085
00086 template<typename OtherDerived>
00087 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_max_op)
00088 max(const MatrixBase<OtherDerived> &other) const;
00089
00090 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op) abs() const;
00091 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op) abs2() const;
00092 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op) square() const;
00093 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op) cube() const;
00094 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op) inverse() const;
00095 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op) sqrt() const;
00096 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op) exp() const;
00097 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op) log() const;
00098 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op) cos() const;
00099 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op) sin() const;
00100 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op) pow(const Scalar& exponent) const;
00101
00102 const ScalarAddReturnType
00103 operator+(const Scalar& scalar) const;
00104
00105
00106 friend const ScalarAddReturnType
00107 operator+(const Scalar& scalar, const Cwise& mat)
00108 { return mat + scalar; }
00109
00110 ExpressionType& operator+=(const Scalar& scalar);
00111
00112 const ScalarAddReturnType
00113 operator-(const Scalar& scalar) const;
00114
00115 ExpressionType& operator-=(const Scalar& scalar);
00116
00117 template<typename OtherDerived>
00118 inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
00119
00120 template<typename OtherDerived>
00121 inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
00122
00123 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
00124 operator<(const MatrixBase<OtherDerived>& other) const;
00125
00126 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
00127 operator<=(const MatrixBase<OtherDerived>& other) const;
00128
00129 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
00130 operator>(const MatrixBase<OtherDerived>& other) const;
00131
00132 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
00133 operator>=(const MatrixBase<OtherDerived>& other) const;
00134
00135 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
00136 operator==(const MatrixBase<OtherDerived>& other) const;
00137
00138 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
00139 operator!=(const MatrixBase<OtherDerived>& other) const;
00140
00141
00142 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
00143 operator<(Scalar s) const;
00144
00145 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
00146 operator<=(Scalar s) const;
00147
00148 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
00149 operator>(Scalar s) const;
00150
00151 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
00152 operator>=(Scalar s) const;
00153
00154 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
00155 operator==(Scalar s) const;
00156
00157 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
00158 operator!=(Scalar s) const;
00159
00160
00161 #ifdef EIGEN_CWISE_PLUGIN
00162 #include EIGEN_CWISE_PLUGIN
00163 #endif
00164
00165 protected:
00166 ExpressionTypeNested m_matrix;
00167 };
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 template<typename Derived>
00178 inline const Cwise<Derived> MatrixBase<Derived>::cwise() const
00179 {
00180 return derived();
00181 }
00182
00183
00184
00185
00186
00187
00188
00189
00190 template<typename Derived>
00191 inline Cwise<Derived> MatrixBase<Derived>::cwise()
00192 {
00193 return derived();
00194 }
00195
00196 #endif // EIGEN_CWISE_H