diff options
-rw-r--r-- | Eigen/src/Core/DenseStorageBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Matrix.h | 23 | ||||
-rw-r--r-- | Eigen/src/Core/arch/SSE/PacketMath.h | 6 | ||||
-rw-r--r-- | test/jacobisvd.cpp | 4 |
4 files changed, 25 insertions, 12 deletions
diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index 94f565b1f..57be94d62 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -551,7 +551,7 @@ struct ei_conservative_resize_like_impl const int common_rows = std::min(rows, _this.rows()); const int common_cols = std::min(cols, _this.cols()); tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols); - _this.swap(tmp); + _this.derived().swap(tmp); } static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) @@ -583,7 +583,7 @@ struct ei_conservative_resize_like_impl<Derived,OtherDerived,true> typename Derived::PlainMatrixType tmp(size); const int common_size = std::min<int>(_this.size(),size); tmp.segment(0,common_size) = _this.segment(0,common_size); - _this.swap(tmp); + _this.derived().swap(tmp); } static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 3e5c7b69e..53ab27412 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -152,6 +152,14 @@ class Matrix using Base::coeff; using Base::coeffRef; + /** This is a special case of the templated operator=. Its purpose is to + * prevent a default operator= from hiding the templated operator=. + */ + EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other) + { + return Base::_set(other); + } + /** Copies the value of the expression \a other into \c *this with automatic resizing. * * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized), @@ -167,15 +175,18 @@ class Matrix return Base::_set(other); } - /** This is a special case of the templated operator=. Its purpose is to - * prevent a default operator= from hiding the templated operator=. + /** + * The usage of + * using Base::operator=; + * fails on MSVC. Since the code below is working with GCC and MSVC, we skipped + * the usage of 'using'. This should be done only for operator=. */ - EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other) + template<typename OtherDerived> + EIGEN_STRONG_INLINE Matrix& operator=(const AnyMatrixBase<OtherDerived> &other) { - return Base::_set(other); + return Base::operator=(other); } - using Base::operator =; using Base::operator +=; using Base::operator -=; using Base::operator *=; @@ -292,6 +303,8 @@ class Matrix { Base::_check_template_params(); Base::resize(other.rows(), other.cols()); + // FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to + // go for pure _set() implementations, right? *this = other; } diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index a633c7b7c..f65801137 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -181,9 +181,9 @@ template<> EIGEN_STRONG_INLINE Packet2d ei_pload<double>(const double* from) { template<> EIGEN_STRONG_INLINE Packet4i ei_pload<int>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); } #if (!defined __GNUC__) && (!defined __ICC) -template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_ps(from); } -template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<double>(const double* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_pd(from); } -template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<int>(const int* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); } +template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_ps(from); } +template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<double>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_pd(from); } +template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<int>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); } #else // Fast unaligned loads. Note that here we cannot directly use intrinsics: this would // require pointer casting to incompatible pointer types and leads to invalid code diff --git a/test/jacobisvd.cpp b/test/jacobisvd.cpp index 587bc7572..c8a1495d2 100644 --- a/test/jacobisvd.cpp +++ b/test/jacobisvd.cpp @@ -54,8 +54,8 @@ template<typename MatrixType, unsigned int Options> void svd(const MatrixType& m MatrixUType u = svd.matrixU(); MatrixVType v = svd.matrixV(); - std::cout << "a\n" << a << std::endl; - std::cout << "b\n" << u * sigma * v.adjoint() << std::endl; + //std::cout << "a\n" << a << std::endl; + //std::cout << "b\n" << u * sigma * v.adjoint() << std::endl; VERIFY_IS_APPROX(a, u * sigma * v.adjoint()); VERIFY_IS_UNITARY(u); |