diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/MatrixBase.h | 22 | ||||
-rw-r--r-- | src/MatrixXpr.h | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/MatrixBase.h b/src/MatrixBase.h index d49ce8c21..5859a14cc 100644 --- a/src/MatrixBase.h +++ b/src/MatrixBase.h @@ -247,6 +247,11 @@ template<typename Derived> class MatrixAlias m_aliased.xpr() = m_tmp; } + Ref ref() + { + return Ref(*this); + } + Xpr xpr() { return Xpr(ref()); @@ -270,11 +275,6 @@ template<typename Derived> class MatrixAlias return m_tmp.write(row, col); } - Ref ref() - { - return Ref(*this); - } - MatrixXpr<MatrixRow<Xpr> > row(int i) { return xpr().row(i); }; MatrixXpr<MatrixCol<Xpr> > col(int i) { return xpr().col(i); }; MatrixXpr<MatrixMinor<Xpr> > minor(int row, int col) { return xpr().minor(row, col); }; @@ -285,21 +285,21 @@ template<typename Derived> class MatrixAlias } template<typename XprContent> - void operator=(const MatrixXpr<XprContent> &xpr) + void operator=(const MatrixXpr<XprContent> &other) { - ref().xpr() = xpr; + xpr() = other; } template<typename XprContent> - void operator+=(const MatrixXpr<XprContent> &xpr) + void operator+=(const MatrixXpr<XprContent> &other) { - ref().xpr() += xpr; + xpr() += other; } template<typename XprContent> - void operator-=(const MatrixXpr<XprContent> &xpr) + void operator-=(const MatrixXpr<XprContent> &other) { - ref().xpr() -= xpr; + xpr() -= other; } protected: diff --git a/src/MatrixXpr.h b/src/MatrixXpr.h index a42f84af6..fe890d16c 100644 --- a/src/MatrixXpr.h +++ b/src/MatrixXpr.h @@ -70,6 +70,8 @@ template<typename Content> class MatrixXpr return *this; } + //special case of the above template operator=. Strangely, g++ 4.1 failed to use + //that template when OtherContent == Content MatrixXpr& operator=(const MatrixXpr& other) { assert(rows() == other.rows() && cols() == other.cols()); |