/* * Random polynomial: * - use variables defined in table */ static polynomial_t *random_poly(poly_buffer_t *b, poly_table_t *table) { rational_t q; uint32_t i, n; int32_t x, a; q_init(&q); reset_poly_buffer(b); a = random_constant(); q_set32(&q, a); poly_buffer_add_const(b, &q); n = random_nterms(); for (i=0; i<n; i++) { a = random_coeff(); x = random_var(table); assert(x > 0); q_set32(&q, a); poly_buffer_add_monomial(b, x, &q); } normalize_poly_buffer(b); q_clear(&q); return poly_buffer_get_poly(b); }
static void init_tests(void) { uint32_t i; int32_t x; for (i=0; i<NUM_TESTS; i++) { x = random_var(); test[i] = var_pp(x); } // force some tests to have the empty power product i = random() % NUM_TESTS; test[i] = empty_pp; i = random() % NUM_TESTS; test[i] = empty_pp; }