mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Matrix::conservativeResize, resize only when necessary.
This commit is contained in:
parent
04dc63776a
commit
21d2533723
@ -707,6 +707,8 @@ struct ei_conservative_resize_like_impl
|
||||
{
|
||||
static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
|
||||
|
||||
// Note: Here is space for improvement. Basically, for conservativeResize(int,int),
|
||||
// neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
|
||||
// dimensions is dynamic, one could use either conservativeResize(int rows, NoChange_t) or
|
||||
@ -728,6 +730,8 @@ struct ei_conservative_resize_like_impl<Derived,OtherDerived,true>
|
||||
{
|
||||
static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
|
||||
|
||||
// segment(...) will check whether Derived/OtherDerived are vectors!
|
||||
typename MatrixBase<Derived>::PlainMatrixType tmp(other);
|
||||
const int common_size = std::min<int>(_this.size(),tmp.size());
|
||||
|
Loading…
Reference in New Issue
Block a user