Skip to content

Commit

Permalink
eckit::linalg::SparseMatrix improved
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Aug 20, 2024
1 parent ba71237 commit e4172ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/eckit/linalg/SparseMatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ SparseMatrix& SparseMatrix::operator=(const SparseMatrix& other) {
}


SparseMatrix& SparseMatrix::operator=(SparseMatrix&& other) {
swap(other);
return *this;
}


SparseMatrix::~SparseMatrix() {
reset();
}
Expand Down
10 changes: 7 additions & 3 deletions src/eckit/linalg/SparseMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SparseMatrix {
Size innerSize() const { return nonZeros(); }

/// @returns outer size is number of rows + 1
Size outerSize() const { return static_cast<Size>(rows_ + 1); }
Size outerSize() const { return rows_ + 1; }

size_t allocSize() const { return sizeofData() + sizeofOuter() + sizeofInner(); }

Expand All @@ -88,7 +88,7 @@ class SparseMatrix {
Size rows_ = 0; ///< Number of rows
Size cols_ = 0; ///< Number of columns

void print(std::ostream& os) const;
void print(std::ostream&) const;

friend std::ostream& operator<<(std::ostream& os, const Shape& p) {
p.print(os);
Expand Down Expand Up @@ -141,11 +141,15 @@ class SparseMatrix {
/// Copy constructor
SparseMatrix(const SparseMatrix&);

/// Destructor
~SparseMatrix();

/// Assignment operator (allocates and copies data)
SparseMatrix& operator=(const SparseMatrix&);

/// Assignment operator (moves data)
SparseMatrix& operator=(SparseMatrix&&);

public:
/// Prune entries with exactly the given value
SparseMatrix& prune(Scalar = 0);
Expand Down Expand Up @@ -239,7 +243,7 @@ class SparseMatrix {
const_iterator& operator=(const_iterator&&) = default;

bool operator!=(const const_iterator& other) const { return !operator==(other); }
bool operator==(const const_iterator& other) const;
bool operator==(const const_iterator&) const;

const Scalar& operator*() const;

Expand Down

0 comments on commit e4172ff

Please sign in to comment.