void addInPlace(SMat<RT>& A, const SMat<RT>& B) { assert(&B.ring() == &A.ring()); assert(B.numRows() == A.numRows()); assert(B.numColumns() == A.numColumns()); A.addInPlace(B); }
void addInPlace(SMat<RT>&A, const SMat<RT>& B) { M2_ASSERT(&B.ring() == &A.ring()); M2_ASSERT(B.numRows() == A.numRows()); M2_ASSERT(B.numColumns() == A.numColumns()); A.addInPlace(B); }
void subtractInPlace(SMat<RT>& A, const SMat<RT>& B) // A -= B { M2_ASSERT(&B.ring() == &A.ring()); M2_ASSERT(B.numRows() == A.numRows()); M2_ASSERT(B.numColumns() == A.numColumns()); A.subtractInPlace(B); }
void subtractInPlace(SMat<RT>& A, const SMat<RT>& B) // A -= B { assert(&B.ring() == &A.ring()); assert(B.numRows() == A.numRows()); assert(B.numColumns() == A.numColumns()); A.subtractInPlace(B); }
void SMat<CoeffRing>::addInPlace(const SMat<CoeffRing> &B) // return this + B. return NULL of sizes or types do not match. { assert(&B.ring() == &ring()); assert(B.numRows() == numRows()); assert(B.numColumns() == numColumns()); for (size_t c = 0; c < numColumns(); c++) { sparsevec *v = vec_copy(B.columns_[c]); vec_add_to(columns_[c], v); } }
bool SMat<CoeffRing>::is_equal(const SMat &B) const { assert(&ring() == &B.ring()); if (B.numRows() != numRows()) return false; if (B.numColumns() != numColumns()) return false; for (size_t c = 0; c < numColumns(); c++) { sparsevec *v = columns_[c]; sparsevec *w = B.columns_[c]; if (!vec_equals(v, w)) return false; } return true; }
void SMat<CoeffRing>::subtractInPlace(const SMat<CoeffRing> &B) // this -= B. // assumption:the assert statements below: { assert(&B.ring() == &ring()); assert(B.numRows() == numRows()); assert(B.numColumns() == numColumns()); for (size_t c = 0; c < numColumns(); c++) { sparsevec *v = vec_copy(B.columns_[c]); vec_negate(v); vec_add_to(columns_[c], v); } }
void copy_elem(ring_elem &result) { M->ring().to_ring_elem(result, value()); }