Fix bug #684: optimize vectorization of array-scalar and scalar-array

This commit is contained in:
Gael Guennebaud
2013-10-18 14:56:36 +02:00
parent a6bff116f9
commit a0e8577b49
2 changed files with 43 additions and 6 deletions

View File

@@ -162,16 +162,16 @@ operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>&
*
* \sa operator+(), operator-=()
*/
inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const Derived>
inline const CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>
operator-(const Scalar& scalar) const
{
return *this + (-scalar);
return CwiseUnaryOp<internal::scalar_sub_op<Scalar>, const Derived>(derived(), internal::scalar_sub_op<Scalar>(scalar));;
}
friend inline const CwiseUnaryOp<internal::scalar_add_op<Scalar>, const CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> >
friend inline const CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>
operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS<Derived>& other)
{
return (-other) + scalar;
return CwiseUnaryOp<internal::scalar_rsub_op<Scalar>, const Derived>(other.derived(), internal::scalar_rsub_op<Scalar>(scalar));;
}
/** \returns an expression of the coefficient-wise && operator of *this and \a other