CwiseOperators.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
00011 #define EIGEN_ARRAY_CWISE_OPERATORS_H
00012 
00013 namespace Eigen { 
00014 
00015 /***************************************************************************
00016 * The following functions were defined in Core
00017 ***************************************************************************/
00018 
00019 
00021 template<typename ExpressionType>
00022 EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op)
00023 Cwise<ExpressionType>::abs() const
00024 {
00025   return _expression();
00026 }
00027 
00029 template<typename ExpressionType>
00030 EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op)
00031 Cwise<ExpressionType>::abs2() const
00032 {
00033   return _expression();
00034 }
00035 
00037 template<typename ExpressionType>
00038 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op)
00039 Cwise<ExpressionType>::exp() const
00040 {
00041   return _expression();
00042 }
00043 
00045 template<typename ExpressionType>
00046 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op)
00047 Cwise<ExpressionType>::log() const
00048 {
00049   return _expression();
00050 }
00051 
00053 template<typename ExpressionType>
00054 template<typename OtherDerived>
00055 EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
00056 Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
00057 {
00058   return EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)(_expression(), other.derived());
00059 }
00060 
00062 template<typename ExpressionType>
00063 template<typename OtherDerived>
00064 EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)
00065 Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
00066 {
00067   return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)(_expression(), other.derived());
00068 }
00069 
00071 template<typename ExpressionType>
00072 template<typename OtherDerived>
00073 inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
00074 {
00075   return m_matrix.const_cast_derived() = *this * other;
00076 }
00077 
00079 template<typename ExpressionType>
00080 template<typename OtherDerived>
00081 inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
00082 {
00083   return m_matrix.const_cast_derived() = *this / other;
00084 }
00085 
00086 /***************************************************************************
00087 * The following functions were defined in Array
00088 ***************************************************************************/
00089 
00090 // -- unary operators --
00091 
00093 template<typename ExpressionType>
00094 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op)
00095 Cwise<ExpressionType>::sqrt() const
00096 {
00097   return _expression();
00098 }
00099 
00101 template<typename ExpressionType>
00102 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op)
00103 Cwise<ExpressionType>::cos() const
00104 {
00105   return _expression();
00106 }
00107 
00108 
00110 template<typename ExpressionType>
00111 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op)
00112 Cwise<ExpressionType>::sin() const
00113 {
00114   return _expression();
00115 }
00116 
00117 
00119 template<typename ExpressionType>
00120 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op)
00121 Cwise<ExpressionType>::pow(const Scalar& exponent) const
00122 {
00123   return EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op)(_expression(), internal::scalar_pow_op<Scalar>(exponent));
00124 }
00125 
00126 
00128 template<typename ExpressionType>
00129 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op)
00130 Cwise<ExpressionType>::inverse() const
00131 {
00132   return _expression();
00133 }
00134 
00136 template<typename ExpressionType>
00137 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op)
00138 Cwise<ExpressionType>::square() const
00139 {
00140   return _expression();
00141 }
00142 
00144 template<typename ExpressionType>
00145 inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op)
00146 Cwise<ExpressionType>::cube() const
00147 {
00148   return _expression();
00149 }
00150 
00151 
00152 // -- binary operators --
00153 
00155 template<typename ExpressionType>
00156 template<typename OtherDerived>
00157 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
00158 Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
00159 {
00160   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
00161 }
00162 
00164 template<typename ExpressionType>
00165 template<typename OtherDerived>
00166 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
00167 Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
00168 {
00169   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
00170 }
00171 
00173 template<typename ExpressionType>
00174 template<typename OtherDerived>
00175 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
00176 Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
00177 {
00178   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
00179 }
00180 
00182 template<typename ExpressionType>
00183 template<typename OtherDerived>
00184 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
00185 Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
00186 {
00187   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
00188 }
00189 
00191 template<typename ExpressionType>
00192 template<typename OtherDerived>
00193 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
00194 Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
00195 {
00196   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
00197 }
00198 
00200 template<typename ExpressionType>
00201 template<typename OtherDerived>
00202 inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
00203 Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
00204 {
00205   return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
00206 }
00207 
00208 // comparisons to scalar value
00209 
00211 template<typename ExpressionType>
00212 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
00213 Cwise<ExpressionType>::operator<(Scalar s) const
00214 {
00215   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
00216             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00217 }
00218 
00220 template<typename ExpressionType>
00221 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
00222 Cwise<ExpressionType>::operator<=(Scalar s) const
00223 {
00224   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
00225             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00226 }
00227 
00229 template<typename ExpressionType>
00230 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
00231 Cwise<ExpressionType>::operator>(Scalar s) const
00232 {
00233   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
00234             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00235 }
00236 
00238 template<typename ExpressionType>
00239 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
00240 Cwise<ExpressionType>::operator>=(Scalar s) const
00241 {
00242   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
00243             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00244 }
00245 
00247 template<typename ExpressionType>
00248 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
00249 Cwise<ExpressionType>::operator==(Scalar s) const
00250 {
00251   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
00252             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00253 }
00254 
00256 template<typename ExpressionType>
00257 inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
00258 Cwise<ExpressionType>::operator!=(Scalar s) const
00259 {
00260   return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
00261             typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
00262 }
00263 
00264 // scalar addition
00265 
00267 template<typename ExpressionType>
00268 inline const typename Cwise<ExpressionType>::ScalarAddReturnType
00269 Cwise<ExpressionType>::operator+(const Scalar& scalar) const
00270 {
00271   return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, internal::scalar_add_op<Scalar>(scalar));
00272 }
00273 
00275 template<typename ExpressionType>
00276 inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
00277 {
00278   return m_matrix.const_cast_derived() = *this + scalar;
00279 }
00280 
00282 template<typename ExpressionType>
00283 inline const typename Cwise<ExpressionType>::ScalarAddReturnType
00284 Cwise<ExpressionType>::operator-(const Scalar& scalar) const
00285 {
00286   return *this + (-scalar);
00287 }
00288 
00290 template<typename ExpressionType>
00291 inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
00292 {
00293   return m_matrix.const_cast_derived() = *this - scalar;
00294 }
00295 
00296 } // end namespace Eigen
00297 
00298 #endif // EIGEN_ARRAY_CWISE_OPERATORS_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:10:29