diff options
author | 2011-11-17 17:57:45 -0500 | |
---|---|---|
committer | 2011-11-17 17:57:45 -0500 | |
commit | de22ad117cb5324e3e1d0700dde7466921fdf9ca (patch) | |
tree | 0827effa945ee99039c5714332e71a4b5cb52aa8 | |
parent | 08c0edae86215629074027b9d20aa84792a75472 (diff) |
bug #157 - Implemented *= /= * / operations for VectorwiseOp (e.g. mat.colwise())
-rw-r--r-- | Eigen/src/Core/VectorwiseOp.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h index 20f688157..b61234b57 100644 --- a/Eigen/src/Core/VectorwiseOp.h +++ b/Eigen/src/Core/VectorwiseOp.h @@ -444,6 +444,26 @@ template<typename ExpressionType, int Direction> class VectorwiseOp return const_cast<ExpressionType&>(m_matrix); } + /** Multiplies the vector \a other to each subvector of \c *this */ + template<typename OtherDerived> + ExpressionType& operator*=(const DenseBase<OtherDerived>& other) + { + EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) + for(Index j=0; j<subVectors(); ++j) + subVector(j).array() *= other.derived().array(); + return const_cast<ExpressionType&>(m_matrix); + } + + /** Divides the vector \a other to each subvector of \c *this */ + template<typename OtherDerived> + ExpressionType& operator/=(const DenseBase<OtherDerived>& other) + { + EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) + for(Index j=0; j<subVectors(); ++j) + subVector(j).array() /= other.derived(); + return const_cast<ExpressionType&>(m_matrix); + } + /** Returns the expression of the sum of the vector \a other to each subvector of \c *this */ template<typename OtherDerived> EIGEN_STRONG_INLINE CwiseBinaryOp<internal::scalar_sum_op<Scalar>, @@ -466,6 +486,28 @@ template<typename ExpressionType, int Direction> class VectorwiseOp return m_matrix - extendedTo(other.derived()); } + /** Returns the expression of the multiplication of the vector \a other to each subvector of \c *this */ + template<typename OtherDerived> EIGEN_STRONG_INLINE + CwiseBinaryOp<internal::scalar_product_op<Scalar>, + const ExpressionTypeNestedCleaned, + const typename ExtendedType<OtherDerived>::Type> + operator*(const DenseBase<OtherDerived>& other) const + { + EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived); + return m_matrix * extendedTo(other.derived()); + } + + /** Returns the expression of the division between each subvector of \c *this and the vector \a other */ + template<typename OtherDerived> + CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, + const ExpressionTypeNestedCleaned, + const typename ExtendedType<OtherDerived>::Type> + operator/(const DenseBase<OtherDerived>& other) const + { + EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived); + return m_matrix / extendedTo(other.derived()); + } + /////////// Geometry module /////////// #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS |