diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index e643144ff..20103408b 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -173,14 +173,16 @@ template class MapBase using Base::operator=; using Base::operator*=; + using Base::operator+=; + using Base::operator-=; - template - Derived& operator+=(const Flagged, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other) - { return Base::operator+=(other); } - - template - Derived& operator-=(const Flagged, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other) - { return Base::operator-=(other); } +// template +// Derived& operator+=(const Flagged, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other) +// { return Base::operator+=(other); } +// +// template +// Derived& operator-=(const Flagged, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other) +// { return Base::operator-=(other); } template Derived& operator+=(const MatrixBase& other) diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index c4adc1c33..8937596f2 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -334,7 +334,10 @@ class Matrix template EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue& func) - { return Base::operator=(func); } + { + resize(func.rows(), func.cols()); + return Base::operator=(func); + } using Base::operator +=; using Base::operator -=; @@ -438,6 +441,7 @@ class Matrix EIGEN_STRONG_INLINE Matrix(const ReturnByValue& other) { _check_template_params(); + resize(other.rows(), other.cols()); other.evalTo(*this); } /** Destructor */ diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index ac2b2532f..b881c09c3 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -409,15 +409,8 @@ template class MatrixBase const typename ProductReturnType::Type operator*(const MatrixBase &other) const; - /** replaces \c *this by \c *this * \a other. - * - * \returns a reference to \c *this - */ template - Derived& operator*=(const MultiplierBase& other) - { - return *this = *this * other.derived(); - } + Derived& operator*=(const MultiplierBase& other); template const DiagonalProduct diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index b46440ec0..ff45cba3c 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -294,7 +294,7 @@ MatrixBase::operator*(const MatrixBase &other) const template template inline Derived & -MatrixBase::operator*=(const MatrixBase &other) +MatrixBase::operator*=(const MultiplierBase &other) { return derived() = derived() * other.derived(); } diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h index 72f4a8f43..58b205edc 100644 --- a/Eigen/src/Core/ReturnByValue.h +++ b/Eigen/src/Core/ReturnByValue.h @@ -76,6 +76,8 @@ template inline void _subTo(Dest& dst) const { EvalType res; evalTo(res); dst -= res; } + inline int rows() const { return static_cast(this)->rows(); } + inline int cols() const { return static_cast(this)->cols(); } }; template diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index 5644e2fab..48d368ea4 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -228,6 +228,9 @@ struct ei_selfadjoint_product_returntype : m_lhs(lhs), m_rhs(rhs) {} + inline int rows() const { return m_lhs.rows(); } + inline int cols() const { return m_lhs.cols(); } + template inline void _addTo(Dest& dst) const { evalTo(dst,1); } template inline void _subTo(Dest& dst) const @@ -278,6 +281,9 @@ struct ei_selfadjoint_product_returntype : m_lhs(lhs), m_rhs(rhs) {} + inline int rows() const { return m_lhs.rows(); } + inline int cols() const { return m_lhs.cols(); } + typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Nested LhsNested; diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix.h b/Eigen/src/Core/products/TriangularMatrixMatrix.h index 39a2bc4c5..b97eaeabf 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix.h @@ -330,6 +330,9 @@ struct ei_triangular_product_returntype : m_lhs(lhs), m_rhs(rhs) {} + inline int rows() const { return m_lhs.rows(); } + inline int cols() const { return m_lhs.cols(); } + template inline void _addTo(Dest& dst) const { evalTo(dst,1); } template inline void _subTo(Dest& dst) const diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index 478bc2521..62f61672f 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -102,9 +102,13 @@ template void product_notemporary(const MatrixType& m) VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1) += m1.block(r0,r0,r1,r1).template selfadjointView() * (s1*m2.block(c0,r0,c1,r1)) ), 0); VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1) = m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(c0,r0,c1,r1) ), 0); - VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(c0,r0,c1,r1) ), 0); VERIFY_EVALUATION_COUNT( m3.template selfadjointView().rankUpdate(m2.adjoint()), 0); + + m3.resize(1,1); + VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(c0,r0,c1,r1) ), 0); + m3.resize(1,1); + VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template triangularView() * m2.block(c0,r0,c1,r1) ), 0); } void test_product_notemporary()