mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Relax mixing-type constraints for binary coefficient-wise operators:
- Replace internal::scalar_product_traits<A,B> by Eigen::ScalarBinaryOpTraits<A,B,OP> - Remove the "functor_is_product_like" helper (was pretty ugly) - Currently, OP is not used, but it is available to the user for fine grained tuning - Currently, only the following operators have been generalized: *,/,+,-,=,*=,/=,+=,-= - TODO: generalize all other binray operators (comparisons,pow,etc.) - TODO: handle "scalar op array" operators (currently only * is handled) - TODO: move the handling of the "void" scalar type to ScalarBinaryOpTraits
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
|
||||
operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||
{
|
||||
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
|
||||
return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient wise quotient of \c *this and \a other
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
// Copyright (C) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
@@ -16,7 +16,13 @@
|
||||
*
|
||||
* \sa class CwiseBinaryOp, operator-=()
|
||||
*/
|
||||
EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op)
|
||||
template<typename OtherDerived>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,difference)
|
||||
operator-(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||
{
|
||||
return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,difference)(derived(), other.derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the sum of \c *this and \a other
|
||||
*
|
||||
@@ -24,7 +30,13 @@ EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op)
|
||||
*
|
||||
* \sa class CwiseBinaryOp, operator+=()
|
||||
*/
|
||||
EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op)
|
||||
template<typename OtherDerived>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,sum)
|
||||
operator+(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||
{
|
||||
return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,sum)(derived(), other.derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
|
||||
*
|
||||
|
||||
@@ -73,7 +73,7 @@ operator/(const Scalar& scalar) const
|
||||
/** Overloaded for efficiently multipling with compatible scalar types */
|
||||
template <typename T>
|
||||
EIGEN_DEVICE_FUNC inline
|
||||
typename internal::enable_if<internal::scalar_product_traits<T,Scalar>::Defined,
|
||||
typename internal::enable_if<ScalarBinaryOpTraits<T,Scalar>::Defined,
|
||||
const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,T>, const Derived> >::type
|
||||
operator*(const T& scalar) const
|
||||
{
|
||||
@@ -91,7 +91,7 @@ operator*(const Scalar& scalar, const StorageBaseType& matrix)
|
||||
|
||||
template <typename T>
|
||||
EIGEN_DEVICE_FUNC inline friend
|
||||
typename internal::enable_if<internal::scalar_product_traits<Scalar,T>::Defined,
|
||||
typename internal::enable_if<ScalarBinaryOpTraits<Scalar,T>::Defined,
|
||||
const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,T>, const Derived> >::type
|
||||
operator*(const T& scalar, const StorageBaseType& matrix)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ operator*(const T& scalar, const StorageBaseType& matrix)
|
||||
|
||||
template <typename T>
|
||||
EIGEN_DEVICE_FUNC inline
|
||||
typename internal::enable_if<internal::scalar_product_traits<Scalar,T>::Defined,
|
||||
typename internal::enable_if<ScalarBinaryOpTraits<Scalar,T>::Defined,
|
||||
const CwiseUnaryOp<internal::scalar_quotient2_op<Scalar,T>, const Derived> >::type
|
||||
operator/(const T& scalar) const
|
||||
{
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)
|
||||
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)
|
||||
cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||
{
|
||||
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived());
|
||||
return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,product)(derived(), other.derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise == operator of *this and \a other
|
||||
|
||||
Reference in New Issue
Block a user