aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-07-20 10:35:47 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-07-20 10:35:47 +0200
commita551107ccea8fe027d2672cb82f6b70e741bb996 (patch)
tree0fe2b75eda258f9b455a5ff10cab4d79981aee68 /Eigen
parent32b08ac971b2ab66cf83360a9e2d42a99bfe3b70 (diff)
bugfix for a = a * b; when a has to be resized
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/Matrix.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 5301f4849..32b526ef3 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -536,6 +536,9 @@ class Matrix
resizeLike(other);
}
+ template<typename MatrixType, typename OtherDerived, bool EvalBeforeAssigning = (int(OtherDerived::Flags) & EvalBeforeAssigningBit) != 0>
+ struct ei_matrix_set_selector;
+
/** \internal 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),
@@ -550,8 +553,8 @@ class Matrix
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix& _set(const MatrixBase<OtherDerived>& other)
{
- _resize_to_match(other);
- return Base::operator=(other);
+ ei_matrix_set_selector<Matrix,OtherDerived>::run(*this,other.derived());
+ return *this;
}
/** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which
@@ -600,6 +603,20 @@ class Matrix
}
};
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+template<typename MatrixType, typename OtherDerived>
+struct Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ei_matrix_set_selector<MatrixType,OtherDerived,true>
+{
+ static void run(MatrixType& dst, const OtherDerived& src) { dst._set_noalias(src.eval()); }
+};
+
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+template<typename MatrixType, typename OtherDerived>
+struct Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ei_matrix_set_selector<MatrixType,OtherDerived,false>
+{
+ static void run(MatrixType& dst, const OtherDerived& src) { dst._set_noalias(src); }
+};
+
/** \defgroup matrixtypedefs Global matrix typedefs
*
* \ingroup Core_Module