diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index fdc6577fb..d744a15a4 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -106,7 +106,7 @@ struct ei_assign_novec_CompleteUnrolling inline static void run(Derived1 &dst, const Derived2 &src) { - dst.coeffRef(row, col) = src.coeff(row, col); + dst.copyCoeff(row, col, src); ei_assign_novec_CompleteUnrolling::run(dst, src); } }; @@ -125,7 +125,7 @@ struct ei_assign_novec_InnerUnrolling const bool rowMajor = int(Derived1::Flags)&RowMajorBit; const int row = rowMajor ? row_or_col : Index; const int col = rowMajor ? Index : row_or_col; - dst.coeffRef(row, col) = src.coeff(row, col); + dst.copyCoeff(row, col, src); ei_assign_novec_InnerUnrolling::run(dst, src, row_or_col); } }; @@ -154,7 +154,7 @@ struct ei_assign_innervec_CompleteUnrolling inline static void run(Derived1 &dst, const Derived2 &src) { - dst.template writePacket(row, col, src.template packet(row, col)); + dst.template copyPacket(row, col, src); ei_assign_innervec_CompleteUnrolling::size, Stop>::run(dst, src); } @@ -173,7 +173,7 @@ struct ei_assign_innervec_InnerUnrolling { const int row = int(Derived1::Flags)&RowMajorBit ? row_or_col : Index; const int col = int(Derived1::Flags)&RowMajorBit ? Index : row_or_col; - dst.template writePacket(row, col, src.template packet(row, col)); + dst.template copyPacket(row, col, src); ei_assign_innervec_InnerUnrolling::size, Stop>::run(dst, src, row_or_col); } @@ -209,9 +209,9 @@ struct ei_assign_impl for(int i = 0; i < innerSize; i++) { if(int(Derived1::Flags)&RowMajorBit) - dst.coeffRef(j, i) = src.coeff(j, i); + dst.copyCoeff(j, i, src); else - dst.coeffRef(i, j) = src.coeff(i, j); + dst.copyCoeff(i, j, src); } } }; @@ -256,9 +256,9 @@ struct ei_assign_impl for(int i = 0; i < innerSize; i+=packetSize) { if(int(Derived1::Flags)&RowMajorBit) - dst.template writePacket(j, i, src.template packet(j, i)); + dst.template copyPacket(j, i, src); else - dst.template writePacket(i, j, src.template packet(i, j)); + dst.template copyPacket(i, j, src); } } }; @@ -302,11 +302,11 @@ struct ei_assign_impl for(int index = 0; index < alignedSize; index += packetSize) { - dst.template writePacket(index, src.template packet(index)); + dst.template copyPacket(index, src); } for(int index = alignedSize; index < size; index++) - dst.coeffRef(index) = src.coeff(index); + dst.copyCoeff(index, src); } }; @@ -344,18 +344,18 @@ struct ei_assign_impl for (int index = 0; index(i, index, src.template packet(i, index)); + dst.template copyPacket(i, index, src); else - dst.template writePacket(index, i, src.template packet(index, i)); + dst.template copyPacket(index, i, src); } // do the non-vectorizable part of the assignment for (int index = alignedInnerSize; index::writePacket derived().template writePacket(index,x); } +template +template +inline void MatrixBase::copyCoeff(int row, int col, const MatrixBase& other) +{ + ei_internal_assert(row >= 0 && row < rows() + && col >= 0 && col < cols()); + derived().coeffRef(row, col) = other.derived().coeff(row, col); +} + +template +template +inline void MatrixBase::copyCoeff(int index, const MatrixBase& other) +{ + ei_internal_assert(index >= 0 && index < size()); + derived().coeffRef(index) = other.derived().coeff(index); +} + +template +template +inline void MatrixBase::copyPacket(int row, int col, const MatrixBase& other) +{ + ei_internal_assert(row >= 0 && row < rows() + && col >= 0 && col < cols()); + derived().template writePacket(row, col, + other.derived().template packet(row, col)); +} + +template +template +inline void MatrixBase::copyPacket(int index, const MatrixBase& other) +{ + ei_internal_assert(index >= 0 && index < size()); + derived().template writePacket(index, + other.derived().template packet(index)); +} #endif // EIGEN_COEFFS_H diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 4b2c26341..f5ffbed56 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -253,6 +253,15 @@ template class MatrixBase Scalar& coeffRef(int index); Scalar& operator[](int index); + template + void copyCoeff(int row, int col, const MatrixBase& other); + template + void copyCoeff(int index, const MatrixBase& other); + template + void copyPacket(int row, int col, const MatrixBase& other); + template + void copyPacket(int index, const MatrixBase& other); + template PacketScalar packet(int row, int col) const; template diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 846ec2c8d..158624617 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -170,7 +170,7 @@ public: const OrientationType& orientation, const MatrixBase &scale); /** \sa MatrixBase::inverse() */ - const Inverse inverse() const + const MatrixType inverse() const { return m_matrix.inverse(); } protected: