Skip to content

Commit

Permalink
add communicator size check to copy/move assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Apr 21, 2022
1 parent d07bdf4 commit cd61a1d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/distributed/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ Matrix<ValueType, LocalIndexType, GlobalIndexType>::operator=(
const Matrix& other)
{
if (this != &other) {
GKO_ASSERT_EQ(other.get_communicator().size(),
this->get_communicator().size());
this->set_size(other.get_size());
diag_mtx_->copy_from(other.diag_mtx_.get());
offdiag_mtx_->copy_from(other.offdiag_mtx_.get());
Expand All @@ -380,6 +382,8 @@ Matrix<ValueType, LocalIndexType, GlobalIndexType>::operator=(
Matrix&& other) noexcept
{
if (this != &other) {
GKO_ASSERT_EQ(other.get_communicator().size(),
this->get_communicator().size());
this->set_size(other.get_size());
other.set_size({});
diag_mtx_->move_from(other.diag_mtx_.get());
Expand Down

0 comments on commit cd61a1d

Please sign in to comment.