/* * Copy the content of buffer b into f */ static void set_normal_form(normal_form_t *f, poly_buffer_t *b) { monomial_t *mono; uint32_t i, n; n = poly_buffer_nterms(b); mono = poly_buffer_mono(b); assert(n <= f->size); for (i=0; i<n; i++) { f->mono[i].var = mono[i].var; q_set(&f->mono[i].coeff, &mono[i].coeff); } f->mono[i].var = max_idx; // end marker f->nterms = n; f->hash = hash_monarray(f->mono, n); }
/* * Hash code for polynomial p * - p must be normalized. */ uint32_t hash_polynomial(polynomial_t *p) { return hash_monarray(p->mono, p->nterms); }