bool CSRMatrix::eq(const MatrixBase &other) const { unsigned row = this->nrows(); if (row != other.nrows() or this->ncols() != other.ncols()) return false; if (is_a<CSRMatrix>(other)) { const CSRMatrix &o = down_cast<const CSRMatrix &>(other); if (this->p_[row] != o.p_[row]) return false; for (unsigned i = 0; i <= row; i++) if (this->p_[i] != o.p_[i]) return false; for (unsigned i = 0; i < this->p_[row]; i++) if ((this->j_[i] != o.j_[i]) or neq(*this->x_[i], *(o.x_[i]))) return false; return true; } else { return this->MatrixBase::eq(other); } }
void DenseMatrix::add_matrix(const MatrixBase &other, MatrixBase &result) const { SYMENGINE_ASSERT(row_ == result.nrows() and col_ == result.ncols()); if (is_a<DenseMatrix>(other) and is_a<DenseMatrix>(result)) { const DenseMatrix &o = static_cast<const DenseMatrix &>(other); DenseMatrix &r = static_cast<DenseMatrix &>(result); add_dense_dense(*this, o, r); } }
bool MatrixBase::eq(const MatrixBase &other) const { if (this->nrows() != other.nrows() || this->ncols() != other.ncols()) return false; for (unsigned i = 0; i < this->nrows(); i++) for (unsigned j = 0; j < this->ncols(); j++) if(neq(this->get(i, j), other.get(i, j))) return false; return true; }