/* * Hash code * - a must be normalized (and terminated by the end marker) * - n = number of terms in a (not counting the end marker) */ uint32_t hash_monarray(monomial_t *a, uint32_t n) { uint32_t h, num, den; h = HASH_POLY_SEED + n; while (a->var < max_idx) { q_hash_decompose(&a->coeff, &num, &den); h = jenkins_hash_triple(a->var, num, den, h); a ++; } return h; }
/* * Hash code for P(b, v). * This function is consistent with hash_polynomial defined in polynomials.c: * If P(b, v) = p0 then hash_arith_buffer(b, v) = hash_polynomial(p0). */ uint32_t hash_arith_buffer(arith_buffer_t *b, int32_t *v) { mlist_t *q; uint32_t h, num, den; h = HASH_POLY_SEED + b->nterms; q = b->list; while (q->next != NULL) { // monomial (a_i * x_i) where // a_i is q->coeff and x_i is *v q_hash_decompose(&q->coeff, &num, &den); h = jenkins_hash_triple(*v, num, den, h); q = q->next; v ++; } return h; }