mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-03 06:50:57 +08:00
Ensure that (potentially aligned) stack objects are passed by reference.
This commit is contained in:
parent
7c99b38b7c
commit
51b361b3bb
@ -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;}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user