// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008 Gael Guennebaud // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_ARRAY_CWISE_OPERATORS_H #define EIGEN_ARRAY_CWISE_OPERATORS_H namespace Eigen { /*************************************************************************** * The following functions were defined in Core ***************************************************************************/ /** \deprecated ArrayBase::abs() */ template EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op) Cwise::abs() const { return _expression(); } /** \deprecated ArrayBase::abs2() */ template EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op) Cwise::abs2() const { return _expression(); } /** \deprecated ArrayBase::exp() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op) Cwise::exp() const { return _expression(); } /** \deprecated ArrayBase::log() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op) Cwise::log() const { return _expression(); } /** \deprecated ArrayBase::operator*() */ template template EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived) Cwise::operator*(const MatrixBase &other) const { return EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator/() */ template template EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op) Cwise::operator/(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator*=() */ template template inline ExpressionType& Cwise::operator*=(const MatrixBase &other) { return m_matrix.const_cast_derived() = *this * other; } /** \deprecated ArrayBase::operator/=() */ template template inline ExpressionType& Cwise::operator/=(const MatrixBase &other) { return m_matrix.const_cast_derived() = *this / other; } /*************************************************************************** * The following functions were defined in Array ***************************************************************************/ // -- unary operators -- /** \deprecated ArrayBase::sqrt() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op) Cwise::sqrt() const { return _expression(); } /** \deprecated ArrayBase::cos() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op) Cwise::cos() const { return _expression(); } /** \deprecated ArrayBase::sin() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op) Cwise::sin() const { return _expression(); } /** \deprecated ArrayBase::log() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op) Cwise::pow(const Scalar& exponent) const { return EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op)(_expression(), internal::scalar_pow_op(exponent)); } /** \deprecated ArrayBase::inverse() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op) Cwise::inverse() const { return _expression(); } /** \deprecated ArrayBase::square() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op) Cwise::square() const { return _expression(); } /** \deprecated ArrayBase::cube() */ template inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op) Cwise::cube() const { return _expression(); } // -- binary operators -- /** \deprecated ArrayBase::operator<() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) Cwise::operator<(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); } /** \deprecated ArrayBase::<=() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) Cwise::operator<=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator>() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) Cwise::operator>(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator>=() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) Cwise::operator>=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator==() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) Cwise::operator==(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); } /** \deprecated ArrayBase::operator!=() */ template template inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) Cwise::operator!=(const MatrixBase &other) const { return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); } // comparisons to scalar value /** \deprecated ArrayBase::operator<(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) Cwise::operator<(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } /** \deprecated ArrayBase::operator<=(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) Cwise::operator<=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } /** \deprecated ArrayBase::operator>(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) Cwise::operator>(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } /** \deprecated ArrayBase::operator>=(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) Cwise::operator>=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } /** \deprecated ArrayBase::operator==(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) Cwise::operator==(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } /** \deprecated ArrayBase::operator!=(Scalar) */ template inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) Cwise::operator!=(Scalar s) const { return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(), typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); } // scalar addition /** \deprecated ArrayBase::operator+(Scalar) */ template inline const typename Cwise::ScalarAddReturnType Cwise::operator+(const Scalar& scalar) const { return typename Cwise::ScalarAddReturnType(m_matrix, internal::scalar_add_op(scalar)); } /** \deprecated ArrayBase::operator+=(Scalar) */ template inline ExpressionType& Cwise::operator+=(const Scalar& scalar) { return m_matrix.const_cast_derived() = *this + scalar; } /** \deprecated ArrayBase::operator-(Scalar) */ template inline const typename Cwise::ScalarAddReturnType Cwise::operator-(const Scalar& scalar) const { return *this + (-scalar); } /** \deprecated ArrayBase::operator-=(Scalar) */ template inline ExpressionType& Cwise::operator-=(const Scalar& scalar) { return m_matrix.const_cast_derived() = *this - scalar; } } // end namespace Eigen #endif // EIGEN_ARRAY_CWISE_OPERATORS_H