mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
fix a couple of issues related to recent products
This commit is contained in:
parent
1ba35248e9
commit
864171df5c
@ -173,14 +173,16 @@ template<typename Derived> class MapBase
|
|||||||
|
|
||||||
using Base::operator=;
|
using Base::operator=;
|
||||||
using Base::operator*=;
|
using Base::operator*=;
|
||||||
|
using Base::operator+=;
|
||||||
|
using Base::operator-=;
|
||||||
|
|
||||||
template<typename Lhs,typename Rhs>
|
// template<typename Lhs,typename Rhs>
|
||||||
Derived& operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
|
// Derived& operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
|
||||||
{ return Base::operator+=(other); }
|
// { return Base::operator+=(other); }
|
||||||
|
//
|
||||||
template<typename Lhs,typename Rhs>
|
// template<typename Lhs,typename Rhs>
|
||||||
Derived& operator-=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
|
// Derived& operator-=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
|
||||||
{ return Base::operator-=(other); }
|
// { return Base::operator-=(other); }
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
||||||
|
@ -334,7 +334,10 @@ class Matrix
|
|||||||
|
|
||||||
template<typename OtherDerived,typename OtherEvalType>
|
template<typename OtherDerived,typename OtherEvalType>
|
||||||
EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived,OtherEvalType>& func)
|
EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived,OtherEvalType>& func)
|
||||||
{ return Base::operator=(func); }
|
{
|
||||||
|
resize(func.rows(), func.cols());
|
||||||
|
return Base::operator=(func);
|
||||||
|
}
|
||||||
|
|
||||||
using Base::operator +=;
|
using Base::operator +=;
|
||||||
using Base::operator -=;
|
using Base::operator -=;
|
||||||
@ -438,6 +441,7 @@ class Matrix
|
|||||||
EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived,OtherEvalType>& other)
|
EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived,OtherEvalType>& other)
|
||||||
{
|
{
|
||||||
_check_template_params();
|
_check_template_params();
|
||||||
|
resize(other.rows(), other.cols());
|
||||||
other.evalTo(*this);
|
other.evalTo(*this);
|
||||||
}
|
}
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
|
@ -409,15 +409,8 @@ template<typename Derived> class MatrixBase
|
|||||||
const typename ProductReturnType<Derived,OtherDerived>::Type
|
const typename ProductReturnType<Derived,OtherDerived>::Type
|
||||||
operator*(const MatrixBase<OtherDerived> &other) const;
|
operator*(const MatrixBase<OtherDerived> &other) const;
|
||||||
|
|
||||||
/** replaces \c *this by \c *this * \a other.
|
|
||||||
*
|
|
||||||
* \returns a reference to \c *this
|
|
||||||
*/
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator*=(const MultiplierBase<OtherDerived>& other)
|
Derived& operator*=(const MultiplierBase<OtherDerived>& other);
|
||||||
{
|
|
||||||
return *this = *this * other.derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename DiagonalDerived>
|
template<typename DiagonalDerived>
|
||||||
const DiagonalProduct<Derived, DiagonalDerived, DiagonalOnTheRight>
|
const DiagonalProduct<Derived, DiagonalDerived, DiagonalOnTheRight>
|
||||||
|
@ -294,7 +294,7 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
|
|||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline Derived &
|
inline Derived &
|
||||||
MatrixBase<Derived>::operator*=(const MatrixBase<OtherDerived> &other)
|
MatrixBase<Derived>::operator*=(const MultiplierBase<OtherDerived> &other)
|
||||||
{
|
{
|
||||||
return derived() = derived() * other.derived();
|
return derived() = derived() * other.derived();
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,8 @@ template<typename Functor, typename _Scalar,int _Rows,int _Cols,int _Options,int
|
|||||||
{ EvalType res; evalTo(res); dst += res; }
|
{ EvalType res; evalTo(res); dst += res; }
|
||||||
template<typename Dest> inline void _subTo(Dest& dst) const
|
template<typename Dest> inline void _subTo(Dest& dst) const
|
||||||
{ EvalType res; evalTo(res); dst -= res; }
|
{ EvalType res; evalTo(res); dst -= res; }
|
||||||
|
inline int rows() const { return static_cast<const Functor* const>(this)->rows(); }
|
||||||
|
inline int cols() const { return static_cast<const Functor* const>(this)->cols(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
|
@ -228,6 +228,9 @@ struct ei_selfadjoint_product_returntype<Lhs,LhsMode,false,Rhs,0,true>
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: m_lhs(lhs), m_rhs(rhs)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline int rows() const { return m_lhs.rows(); }
|
||||||
|
inline int cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
template<typename Dest> inline void _addTo(Dest& dst) const
|
template<typename Dest> inline void _addTo(Dest& dst) const
|
||||||
{ evalTo(dst,1); }
|
{ evalTo(dst,1); }
|
||||||
template<typename Dest> inline void _subTo(Dest& dst) const
|
template<typename Dest> inline void _subTo(Dest& dst) const
|
||||||
@ -278,6 +281,9 @@ struct ei_selfadjoint_product_returntype<Lhs,LhsMode,false,Rhs,RhsMode,false>
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: 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::Scalar Scalar;
|
||||||
|
|
||||||
typedef typename Lhs::Nested LhsNested;
|
typedef typename Lhs::Nested LhsNested;
|
||||||
|
@ -330,6 +330,9 @@ struct ei_triangular_product_returntype<Mode,LhsIsTriangular,Lhs,false,Rhs,false
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: 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::Scalar Scalar;
|
||||||
|
|
||||||
typedef typename Lhs::Nested LhsNested;
|
typedef typename Lhs::Nested LhsNested;
|
||||||
|
@ -141,6 +141,9 @@ struct ei_triangular_product_returntype<Mode,true,Lhs,false,Rhs,true>
|
|||||||
: m_lhs(lhs), m_rhs(rhs)
|
: m_lhs(lhs), m_rhs(rhs)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline int rows() const { return m_lhs.rows(); }
|
||||||
|
inline int cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
template<typename Dest> inline void _addTo(Dest& dst) const
|
template<typename Dest> inline void _addTo(Dest& dst) const
|
||||||
{ evalTo(dst,1); }
|
{ evalTo(dst,1); }
|
||||||
template<typename Dest> inline void _subTo(Dest& dst) const
|
template<typename Dest> inline void _subTo(Dest& dst) const
|
||||||
|
@ -102,9 +102,13 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m)
|
|||||||
|
|
||||||
VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1) += m1.block(r0,r0,r1,r1).template selfadjointView<UpperTriangular>() * (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<UpperTriangular>() * (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<UpperTriangular>() * m2.block(c0,r0,c1,r1) ), 0);
|
VERIFY_EVALUATION_COUNT(( m3.block(r0,r0,r1,r1) = m1.block(r0,r0,r1,r1).template selfadjointView<UpperTriangular>() * m2.block(c0,r0,c1,r1) ), 0);
|
||||||
VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template selfadjointView<LowerTriangular>() * m2.block(c0,r0,c1,r1) ), 0);
|
|
||||||
|
|
||||||
VERIFY_EVALUATION_COUNT( m3.template selfadjointView<LowerTriangular>().rankUpdate(m2.adjoint()), 0);
|
VERIFY_EVALUATION_COUNT( m3.template selfadjointView<LowerTriangular>().rankUpdate(m2.adjoint()), 0);
|
||||||
|
|
||||||
|
m3.resize(1,1);
|
||||||
|
VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template selfadjointView<LowerTriangular>() * m2.block(c0,r0,c1,r1) ), 0);
|
||||||
|
m3.resize(1,1);
|
||||||
|
VERIFY_EVALUATION_COUNT(( m3 = m1.block(r0,r0,r1,r1).template triangularView<UnitUpperTriangular>() * m2.block(c0,r0,c1,r1) ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_product_notemporary()
|
void test_product_notemporary()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user