/* * Check whether p1 - p2 is a non-zero constant * - p1 and p2 must be normalized. */ bool disequal_monarrays(monomial_t *p1, monomial_t *p2) { int32_t v1, v2; v1 = p1->var; v2 = p2->var; if ((v1 == const_idx && v2 == const_idx && q_eq(&p1->coeff, &p2->coeff)) || (v1 != const_idx && v2 != const_idx)) { // same constant term (may be zero in both polynomials) return false; } // skip constants if (v1 == const_idx) p1++; if (v2 == const_idx) p2++; // check whether non-constant monomials are equal return equal_monarrays(p1, p2); }
/* * Check whether f and g are equal */ static bool equal_normal_forms(normal_form_t *f, normal_form_t *g) { return f->hash == g->hash && f->nterms == g->nterms && equal_monarrays(f->mono, g->mono); }
static bool equal_poly_buffers(poly_buffer_t *bx, poly_buffer_t *by) { return poly_buffer_nterms(bx) == poly_buffer_nterms(by) && equal_monarrays(poly_buffer_mono(bx), poly_buffer_mono(by)); }