add operators *= and /= (bis)

This commit is contained in:
Gael Guennebaud 2010-01-05 15:41:01 +01:00
parent 39209edd71
commit 1837b65b28

View File

@ -145,6 +145,9 @@ template<typename Derived> class ArrayBase
template<typename OtherDerived>
Derived& operator*=(const ArrayBase<OtherDerived>& other);
template<typename OtherDerived>
Derived& operator/=(const ArrayBase<OtherDerived>& other);
template<typename OtherDerived>
inline bool operator==(const ArrayBase<OtherDerived>& other) const
{ return cwiseEqual(other).all(); }
@ -162,7 +165,7 @@ template<typename Derived> class ArrayBase
protected:
ArrayBase() : Base() {}
private:
explicit ArrayBase(int);
ArrayBase(int,int);
@ -197,4 +200,32 @@ ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other)
return derived();
}
/** replaces \c *this by \c *this * \a other coefficient wise.
*
* \returns a reference to \c *this
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
ArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other)
{
SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived> tmp(derived());
tmp = other.derived();
return derived();
}
/** replaces \c *this by \c *this / \a other coefficient wise.
*
* \returns a reference to \c *this
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other)
{
SelfCwiseBinaryOp<ei_scalar_quotient_op<Scalar>, Derived> tmp(derived());
tmp = other.derived();
return derived();
}
#endif // EIGEN_ARRAYBASE_H