aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/src/Core/DenseStorage.h37
-rw-r--r--unsupported/test/matrix_power.cpp4
2 files changed, 35 insertions, 6 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h
index ae86b4d11..67507db28 100644
--- a/Eigen/src/Core/DenseStorage.h
+++ b/Eigen/src/Core/DenseStorage.h
@@ -118,7 +118,11 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt
DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()) {}
DenseStorage(const DenseStorage& other) : m_data(other.m_data) {}
- DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; }
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other) m_data = other.m_data;
+ return *this;
+ }
DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }
static DenseIndex rows(void) {return _Rows;}
@@ -168,7 +172,16 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic
DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {}
- DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; }
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_rows = other.m_rows;
+ m_cols = other.m_cols;
+ }
+ other.swap(*this); return *this;
+ }
DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {}
void swap(DenseStorage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
@@ -190,7 +203,15 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si
DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {}
- DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; }
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_rows = other.m_rows;
+ }
+ return *this;
+ }
DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {}
void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
DenseIndex rows(void) const {return m_rows;}
@@ -211,7 +232,15 @@ template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Si
DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {}
- DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; }
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_cols = other.m_cols;
+ }
+ return *this;
+ }
DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {}
void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
DenseIndex rows(void) const {return _Rows;}
diff --git a/unsupported/test/matrix_power.cpp b/unsupported/test/matrix_power.cpp
index 4c4cac509..58644f84b 100644
--- a/unsupported/test/matrix_power.cpp
+++ b/unsupported/test/matrix_power.cpp
@@ -97,7 +97,7 @@ void testGeneral(const MatrixType& m, double tol)
}
template<typename MatrixType>
-void testSingular(MatrixType m, double tol)
+void testSingular(const MatrixType& m, double tol)
{
const int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>::IsComplex;
typedef typename internal::conditional<IsComplex, TriangularView<MatrixType,Upper>, const MatrixType&>::type TriangularType;
@@ -126,7 +126,7 @@ void testSingular(MatrixType m, double tol)
}
template<typename MatrixType>
-void testLogThenExp(MatrixType m, double tol)
+void testLogThenExp(const MatrixType& m, double tol)
{
typedef typename MatrixType::Scalar Scalar;
Scalar x;