diff --git a/src/Core/MatrixBase.h b/src/Core/MatrixBase.h index 1fd6e3971..bdf1a1c0b 100644 --- a/src/Core/MatrixBase.h +++ b/src/Core/MatrixBase.h @@ -31,9 +31,6 @@ template class MatrixBase static const int RowsAtCompileTime = Derived::RowsAtCompileTime, ColsAtCompileTime = Derived::ColsAtCompileTime; - template - void _copy_helper(const MatrixBase& other); - public: static const int SizeAtCompileTime = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic @@ -51,20 +48,13 @@ template class MatrixBase { return static_cast(this)->_ref(); } template - Derived& operator=(const MatrixBase& other) - { - assert(rows() == other.rows() && cols() == other.cols()); - _copy_helper(other); - return *static_cast(this); - } + Derived& operator=(const MatrixBase& other); //special case of the above template operator=, in order to prevent the compiler //from generating a default operator= (issue hit with g++ 4.1) Derived& operator=(const MatrixBase& other) { - assert(rows() == other.rows() && cols() == other.cols()); - _copy_helper(other); - return *static_cast(this); + return this->operator=(other); } template Cast cast() const; diff --git a/src/Core/CopyHelper.h b/src/Core/OperatorEquals.h similarity index 74% rename from src/Core/CopyHelper.h rename to src/Core/OperatorEquals.h index 8c5fc0c13..685193f27 100644 --- a/src/Core/CopyHelper.h +++ b/src/Core/OperatorEquals.h @@ -24,10 +24,10 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#ifndef EIGEN_COPYHELPER_H -#define EIGEN_COPYHELPER_H +#ifndef EIGEN_OPERATOREQUALS_H +#define EIGEN_OPERATOREQUALS_H -template struct CopyHelperUnroller +template struct OperatorEqualsUnroller { static const int col = (UnrollCount-1) / Rows; static const int row = (UnrollCount-1) % Rows; @@ -35,13 +35,13 @@ template struct CopyHelperUnroller template static void run(Derived1 &dst, const Derived2 &src) { - CopyHelperUnroller::run(dst, src); + OperatorEqualsUnroller::run(dst, src); dst.write(row, col) = src.read(row, col); } }; // prevent buggy user code from causing an infinite recursion -template struct CopyHelperUnroller +template struct OperatorEqualsUnroller { template static void run(Derived1 &dst, const Derived2 &src) @@ -51,7 +51,7 @@ template struct CopyHelperUnroller } }; -template struct CopyHelperUnroller<1, Rows> +template struct OperatorEqualsUnroller<1, Rows> { template static void run(Derived1 &dst, const Derived2 &src) @@ -60,7 +60,7 @@ template struct CopyHelperUnroller<1, Rows> } }; -template struct CopyHelperUnroller +template struct OperatorEqualsUnroller { template static void run(Derived1 &dst, const Derived2 &src) @@ -72,14 +72,17 @@ template struct CopyHelperUnroller template template -void MatrixBase::_copy_helper(const MatrixBase& other) +Derived& MatrixBase + ::operator=(const MatrixBase& other) { + assert(rows() == other.rows() && cols() == other.cols()); if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 25) - CopyHelperUnroller::run(*this, other); + OperatorEqualsUnroller::run(*this, other); else - for(int i = 0; i < rows(); i++) - for(int j = 0; j < cols(); j++) + for(int j = 0; j < cols(); j++) //traverse in column-dominant order + for(int i = 0; i < rows(); i++) write(i, j) = other.read(i, j); + return *static_cast(this); } -#endif // EIGEN_COPYHELPER_H +#endif // EIGEN_OPERATOREQUALS_H