mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fixed conservativeResize.
Fixed multiple overloads for operator=. Removed debug output.
This commit is contained in:
parent
376341de4a
commit
325da2ea3c
@ -551,7 +551,7 @@ struct ei_conservative_resize_like_impl
|
|||||||
const int common_rows = std::min(rows, _this.rows());
|
const int common_rows = std::min(rows, _this.rows());
|
||||||
const int common_cols = std::min(cols, _this.cols());
|
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);
|
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)
|
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);
|
typename Derived::PlainMatrixType tmp(size);
|
||||||
const int common_size = std::min<int>(_this.size(),size);
|
const int common_size = std::min<int>(_this.size(),size);
|
||||||
tmp.segment(0,common_size) = _this.segment(0,common_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)
|
static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
|
||||||
|
@ -152,6 +152,14 @@ class Matrix
|
|||||||
using Base::coeff;
|
using Base::coeff;
|
||||||
using Base::coeffRef;
|
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.
|
/** 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),
|
* *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);
|
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 -=;
|
using Base::operator -=;
|
||||||
using Base::operator *=;
|
using Base::operator *=;
|
||||||
@ -292,6 +303,8 @@ class Matrix
|
|||||||
{
|
{
|
||||||
Base::_check_template_params();
|
Base::_check_template_params();
|
||||||
Base::resize(other.rows(), other.cols());
|
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;
|
*this = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)); }
|
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)
|
#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 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) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_pd(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) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_si128(reinterpret_cast<const Packet4i*>(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
|
#else
|
||||||
// Fast unaligned loads. Note that here we cannot directly use intrinsics: this would
|
// 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
|
// require pointer casting to incompatible pointer types and leads to invalid code
|
||||||
|
@ -54,8 +54,8 @@ template<typename MatrixType, unsigned int Options> void svd(const MatrixType& m
|
|||||||
MatrixUType u = svd.matrixU();
|
MatrixUType u = svd.matrixU();
|
||||||
MatrixVType v = svd.matrixV();
|
MatrixVType v = svd.matrixV();
|
||||||
|
|
||||||
std::cout << "a\n" << a << std::endl;
|
//std::cout << "a\n" << a << std::endl;
|
||||||
std::cout << "b\n" << u * sigma * v.adjoint() << std::endl;
|
//std::cout << "b\n" << u * sigma * v.adjoint() << std::endl;
|
||||||
|
|
||||||
VERIFY_IS_APPROX(a, u * sigma * v.adjoint());
|
VERIFY_IS_APPROX(a, u * sigma * v.adjoint());
|
||||||
VERIFY_IS_UNITARY(u);
|
VERIFY_IS_UNITARY(u);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user