mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-31 19:00:35 +08:00
remove operator *= between matrices: too much hassle.
This commit is contained in:
parent
61158b1922
commit
506cc5db12
@ -49,12 +49,5 @@ int main(int, char **)
|
||||
m = m_save;
|
||||
m.alias() = m * m;
|
||||
cout << "And m is now:" << endl << m << endl << "as was expected." << endl;
|
||||
cout << "To make your life easier, operator*= between matrices automatically" << endl
|
||||
<< "creates an alias. So a *= b is equivalent to a.alias() *= b," << endl
|
||||
<< "when a and b are matrices. So, coming back to the original matrix m," << endl
|
||||
<< "if we do m *= m, the matrix m becomes:" << endl;
|
||||
m = m_save;
|
||||
m *= m;
|
||||
cout << m << endl << "as expected." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -206,14 +206,10 @@ class MatrixBase
|
||||
MatrixBase& operator+=(const MatrixConstXpr<Content> &xpr);
|
||||
template<typename Content>
|
||||
MatrixBase& operator-=(const MatrixConstXpr<Content> &xpr);
|
||||
template<typename Content>
|
||||
MatrixBase& operator*=(const MatrixConstXpr<Content> &xpr);
|
||||
template<typename Derived2>
|
||||
MatrixBase& operator+=(const MatrixBase<Derived2> &other);
|
||||
template<typename Derived2>
|
||||
MatrixBase& operator-=(const MatrixBase<Derived2> &other);
|
||||
template<typename Derived2>
|
||||
MatrixBase& operator*=(const MatrixBase<Derived2> &other);
|
||||
|
||||
protected:
|
||||
|
||||
@ -269,12 +265,12 @@ template<typename Derived> class MatrixAlias
|
||||
typedef MatrixRef<MatrixAlias<Derived> > Ref;
|
||||
typedef MatrixXpr<Ref> Xpr;
|
||||
|
||||
MatrixAlias(Derived& matrix) : m_ref(matrix), m_tmp(matrix) {}
|
||||
MatrixAlias(const MatrixAlias& other) : m_ref(other.m_ref), m_tmp(other.m_tmp) {}
|
||||
MatrixAlias(Derived& matrix) : m_aliased(matrix), m_tmp(matrix) {}
|
||||
MatrixAlias(const MatrixAlias& other) : m_aliased(other.m_aliased), m_tmp(other.m_tmp) {}
|
||||
|
||||
~MatrixAlias()
|
||||
{
|
||||
m_ref.xpr() = m_tmp;
|
||||
m_aliased.xpr() = m_tmp;
|
||||
}
|
||||
|
||||
Xpr xpr()
|
||||
@ -324,7 +320,7 @@ template<typename Derived> class MatrixAlias
|
||||
}
|
||||
|
||||
protected:
|
||||
MatrixRef<MatrixBase<Derived> > m_ref;
|
||||
MatrixRef<MatrixBase<Derived> > m_aliased;
|
||||
Derived m_tmp;
|
||||
};
|
||||
|
||||
|
@ -213,24 +213,6 @@ EIGEN_MAKE_MATRIX_OP_EQ(-)
|
||||
|
||||
#undef EIGEN_MAKE_MATRIX_OP_EQ
|
||||
|
||||
template<typename Derived1>
|
||||
template<typename Derived2>
|
||||
MatrixBase<Derived1> &
|
||||
MatrixBase<Derived1>::operator *=(const MatrixBase<Derived2> &mat2)
|
||||
{
|
||||
alias() = *this * mat2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
template<typename Content>
|
||||
MatrixBase<Derived> &
|
||||
MatrixBase<Derived>::operator *=(const MatrixConstXpr<Content> &xpr)
|
||||
{
|
||||
alias() = *this * xpr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#endif // EIGEN_MATRIXOPS_H
|
||||
|
@ -123,8 +123,6 @@ template<typename Content> class MatrixXpr
|
||||
MatrixXpr& operator+=(const MatrixBase<Derived> &matrix);
|
||||
template<typename Derived>
|
||||
MatrixXpr& operator-=(const MatrixBase<Derived> &matrix);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void operator=(const MatrixXpr &other)
|
||||
|
Loading…
x
Reference in New Issue
Block a user