aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-09-02 16:56:48 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-09-02 16:56:48 -0400
commitec20d583179bb2f01686c1c6fc0079ddee8ae4e2 (patch)
tree6cb1e80049601dd584485e4a56ba25da7e681044 /Eigen/src/Core
parentcc375e2f79561da0c3e0e8c3184bd51dee334641 (diff)
* add serious unit test for swap
* fix my stupidity in Matrix::swap()
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/Matrix.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 2fc38c812..cdc76c120 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -651,13 +651,12 @@ class Matrix
m_storage.data()[1] = y;
}
- template<typename MatrixType, typename OtherDerived, bool IsSameType, bool IsDynamicSize>
+ template<typename MatrixType, typename OtherDerived, bool IsSameType>
friend struct ei_matrix_swap_impl;
};
template<typename MatrixType, typename OtherDerived,
- bool IsSameType = ei_is_same_type<MatrixType, OtherDerived>::ret,
- bool IsDynamicSize = MatrixType::SizeAtCompileTime==Dynamic>
+ bool IsSameType = ei_is_same_type<MatrixType, OtherDerived>::ret>
struct ei_matrix_swap_impl
{
static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
@@ -667,10 +666,11 @@ struct ei_matrix_swap_impl
};
template<typename MatrixType, typename OtherDerived>
-struct ei_matrix_swap_impl<MatrixType, OtherDerived, true, true>
+struct ei_matrix_swap_impl<MatrixType, OtherDerived, true>
{
static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
{
+ ei_assert(matrix.rows() == other.rows() && matrix.cols() == other.cols());
matrix.m_storage.swap(other.derived().m_storage);
}
};
@@ -679,6 +679,7 @@ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int
template<typename OtherDerived>
inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(const MatrixBase<OtherDerived>& other)
{
+
ei_matrix_swap_impl<Matrix, OtherDerived>::run(*this, *const_cast<MatrixBase<OtherDerived>*>(&other));
}