virtual bool dot_product(size_t c1, size_t c2, ring_elem &result) const { size_t ncols = n_cols(); if (error_column_bound(c1,ncols) || error_column_bound(c2,ncols)) return false; elem a; mat.get_CoeffRing()->set_zero(a); mat.dot_product(c1,c2,a); mat.get_CoeffRing()->to_ring_elem(result,a); return true; }
virtual size_t lead_row(size_t col, ring_elem &result) const /* returns the largest index row which has a non-zero value in column 'col'. Also sets result to be the entry at this index. returns -1 if the column is 0 */ { elem b; mat.get_CoeffRing()->set_zero(b); size_t ret = mat.lead_row(col, b); if (ret >= 0) mat.get_CoeffRing()->to_ring_elem(result, b); return ret; }
virtual bool get_entry(size_t r, size_t c, ring_elem &result) const // Returns false if (r,c) is out of range or if result is 0. No error // is returned. result <-- this(r,c), and is set to zero if false is returned. { if (r >= 0 && r < n_rows() && c >= 0 && c < n_cols()) { elem a; mat.get_CoeffRing()->set_zero(a); if (mat.get_entry(r,c,a)) { mat.get_CoeffRing()->to_ring_elem(result,a); return true; } } result = mat.get_ring()->zero(); return false; }
virtual bool row2by2(size_t r1, size_t r2, ring_elem a1, ring_elem a2, ring_elem b1, ring_elem b2) /* row(r1) <- a1 * row(r1) + a2 * row(r2), row(r2) <- b1 * row(r1) + b2 * row(r2) */ { size_t nrows = n_rows(); if (error_row_bound(r1,nrows) || error_row_bound(r2,nrows)) return false; if (r1 == r2) return true; elem aa1, aa2, bb1, bb2; mat.get_CoeffRing()->from_ring_elem(aa1,a1); mat.get_CoeffRing()->from_ring_elem(aa2,a2); mat.get_CoeffRing()->from_ring_elem(bb1,b1); mat.get_CoeffRing()->from_ring_elem(bb2,b2); mat.row2by2(r1,r2,aa1,aa2,bb1,bb2); return true; }
virtual bool column2by2(size_t c1, size_t c2, ring_elem a1, ring_elem a2, ring_elem b1, ring_elem b2) /* column(c1) <- a1 * column(c1) + a2 * column(c2), column(c2) <- b1 * column(c1) + b2 * column(c2) */ { size_t ncols = n_cols(); if (error_column_bound(c1,ncols) || error_column_bound(c2,ncols)) return false; if (c1 == c2) return true; elem aa1, aa2, bb1, bb2; mat.get_CoeffRing()->from_ring_elem(aa1,a1); mat.get_CoeffRing()->from_ring_elem(aa2,a2); mat.get_CoeffRing()->from_ring_elem(bb1,b1); mat.get_CoeffRing()->from_ring_elem(bb2,b2); mat.column2by2(c1,c2,aa1,aa2,bb1,bb2); return true; }
virtual bool set_entry(size_t r, size_t c, const ring_elem a) // Returns false if (r,c) is out of range, or the ring of a is wrong. { if (error_row_bound(r,n_rows())) return false; if (error_column_bound(c,n_cols())) return false; elem b; mat.get_CoeffRing()->from_ring_elem(b,a); mat.set_entry(r,c,b); return true; }
virtual bool divide_column(size_t i, ring_elem r) /* column(i) <- column(i) / r */ { size_t ncols = n_cols(); if (error_column_bound(i,ncols)) return false; elem b; mat.get_CoeffRing()->from_ring_elem(b,r); mat.divide_column(i,b); return true; }
virtual bool divide_row(size_t i, ring_elem r) /* row(i) <- row(i) / r */ { size_t nrows = n_rows(); if (error_row_bound(i,nrows)) return false; elem b; mat.get_CoeffRing()->from_ring_elem(b,r); mat.divide_row(i,b); return true; }
virtual bool column_op(size_t i, ring_elem r, size_t j) /* column(i) <- column(i) + r * column(j) */ { size_t ncols = n_cols(); if (error_column_bound(i,ncols) || error_column_bound(j,ncols)) return false; if (i == j) return true; elem b; mat.get_CoeffRing()->from_ring_elem(b,r); mat.column_op(i,b,j); return true; }
virtual bool row_op(size_t i, ring_elem r, size_t j) /* row(i) <- row(i) + r * row(j) */ { size_t nrows = n_rows(); if (error_row_bound(i,nrows) || error_row_bound(j,nrows)) return false; if (i == j) return true; elem b; mat.get_CoeffRing()->from_ring_elem(b,r); mat.row_op(i,b,j); return true; }