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
00031 #define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
00032 CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
00033
00036 #define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
00037 CwiseUnaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType>
00038
00041 #define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
00042 CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, \
00043 typename ExpressionType::ConstantReturnType >
00044
00063 template<typename ExpressionType> class Cwise
00064 {
00065 public:
00066
00067 typedef typename internal::traits<ExpressionType>::Scalar Scalar;
00068 typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
00069 ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
00070 typedef CwiseUnaryOp<internal::scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
00071
00072 inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
00073
00075 inline const ExpressionType& _expression() const { return m_matrix; }
00076
00077 template<typename OtherDerived>
00078 const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
00079 operator*(const MatrixBase<OtherDerived> &other) const;
00080
00081 template<typename OtherDerived>
00082 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)
00083 operator/(const MatrixBase<OtherDerived> &other) const;
00084
00086 template<typename OtherDerived>
00087 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_min_op)
00088 (min)(const MatrixBase<OtherDerived> &other) const
00089 { return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_min_op)(_expression(), other.derived()); }
00090
00092 template<typename OtherDerived>
00093 const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_max_op)
00094 (max)(const MatrixBase<OtherDerived> &other) const
00095 { return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_max_op)(_expression(), other.derived()); }
00096
00097 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op) abs() const;
00098 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op) abs2() const;
00099 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op) square() const;
00100 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op) cube() const;
00101 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op) inverse() const;
00102 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op) sqrt() const;
00103 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op) exp() const;
00104 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op) log() const;
00105 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op) cos() const;
00106 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op) sin() const;
00107 const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op) pow(const Scalar& exponent) const;
00108
00109 const ScalarAddReturnType
00110 operator+(const Scalar& scalar) const;
00111
00113 friend const ScalarAddReturnType
00114 operator+(const Scalar& scalar, const Cwise& mat)
00115 { return mat + scalar; }
00116
00117 ExpressionType& operator+=(const Scalar& scalar);
00118
00119 const ScalarAddReturnType
00120 operator-(const Scalar& scalar) const;
00121
00122 ExpressionType& operator-=(const Scalar& scalar);
00123
00124 template<typename OtherDerived>
00125 inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
00126
00127 template<typename OtherDerived>
00128 inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
00129
00130 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
00131 operator<(const MatrixBase<OtherDerived>& other) const;
00132
00133 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
00134 operator<=(const MatrixBase<OtherDerived>& other) const;
00135
00136 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
00137 operator>(const MatrixBase<OtherDerived>& other) const;
00138
00139 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
00140 operator>=(const MatrixBase<OtherDerived>& other) const;
00141
00142 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
00143 operator==(const MatrixBase<OtherDerived>& other) const;
00144
00145 template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
00146 operator!=(const MatrixBase<OtherDerived>& other) const;
00147
00148
00149 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
00150 operator<(Scalar s) const;
00151
00152 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
00153 operator<=(Scalar s) const;
00154
00155 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
00156 operator>(Scalar s) const;
00157
00158 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
00159 operator>=(Scalar s) const;
00160
00161 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
00162 operator==(Scalar s) const;
00163
00164 const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
00165 operator!=(Scalar s) const;
00166
00167
00168 #ifdef EIGEN_CWISE_PLUGIN
00169 #include EIGEN_CWISE_PLUGIN
00170 #endif
00171
00172 protected:
00173 ExpressionTypeNested m_matrix;
00174 };
00175
00176
00184 template<typename Derived>
00185 inline const Cwise<Derived> MatrixBase<Derived>::cwise() const
00186 {
00187 return derived();
00188 }
00189
00197 template<typename Derived>
00198 inline Cwise<Derived> MatrixBase<Derived>::cwise()
00199 {
00200 return derived();
00201 }
00202
00203 #endif // EIGEN_CWISE_H