mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Add free-function swap.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
820e8a45fb
commit
b396a6fbb2
@@ -829,6 +829,8 @@ class SparseMatrix : public SparseCompressedBase<SparseMatrix<Scalar_, Options_,
|
||||
std::swap(m_innerNonZeros, other.m_innerNonZeros);
|
||||
m_data.swap(other.m_data);
|
||||
}
|
||||
/** Free-function swap. */
|
||||
friend EIGEN_DEVICE_FUNC void swap(SparseMatrix& a, SparseMatrix& b) { a.swap(b); }
|
||||
|
||||
/** Sets *this to the identity matrix.
|
||||
* This function also turns the matrix into compressed mode, and drop any reserved memory. */
|
||||
|
||||
@@ -278,6 +278,7 @@ class SparseVector : public SparseCompressedBase<SparseVector<Scalar_, Options_,
|
||||
std::swap(m_size, other.m_size);
|
||||
m_data.swap(other.m_data);
|
||||
}
|
||||
friend EIGEN_DEVICE_FUNC void swap(SparseVector& a, SparseVector& b) { a.swap(b); }
|
||||
|
||||
template <int OtherOptions>
|
||||
inline void swap(SparseMatrix<Scalar, OtherOptions, StorageIndex>& other) {
|
||||
@@ -285,6 +286,14 @@ class SparseVector : public SparseCompressedBase<SparseVector<Scalar_, Options_,
|
||||
std::swap(m_size, other.m_innerSize);
|
||||
m_data.swap(other.m_data);
|
||||
}
|
||||
template <int OtherOptions>
|
||||
friend EIGEN_DEVICE_FUNC void swap(SparseVector& a, SparseMatrix<Scalar, OtherOptions, StorageIndex>& b) {
|
||||
a.swap(b);
|
||||
}
|
||||
template <int OtherOptions>
|
||||
friend EIGEN_DEVICE_FUNC void swap(SparseMatrix<Scalar, OtherOptions, StorageIndex>& a, SparseVector& b) {
|
||||
b.swap(a);
|
||||
}
|
||||
|
||||
inline SparseVector& operator=(const SparseVector& other) {
|
||||
if (other.isRValue()) {
|
||||
|
||||
Reference in New Issue
Block a user