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 transpose(const SMat<RT>& A, SMat<RT>& result) { // result should be the 0 matrix of the correct size. M2_ASSERT(&A != &result); // these cannot be aliased! M2_ASSERT(result.numRows() == A.numColumns()); M2_ASSERT(result.numColumns() == A.numRows()); throw exc::engine_error("'transpose' not writtten for sparse mutable matrices"); //TODO: MES: write this!! }
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>::setFromSubmatrix(const SMat &A, M2_arrayint cols) { coeffR = A.coeffR; initialize(A.numRows(), cols->len, NULL); for (size_t r = 0; r < nrows_; r++) for (size_t c = 0; c < cols->len; c++) { elem f; coeffR->init(f); // coeffR->init(f); A.get_entry(r, cols->array[c], f); set_entry(r, c, f); } }
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); } }