/*-------------------------------------------------------------------------*/ void poly_rootopt_run(poly_rootopt_t *data, mpz_t * alg_coeffs, mpz_t * rat_coeffs, double sizeopt_norm, double projective_alpha) { uint32 i; stage2_curr_data_t *s = (stage2_curr_data_t *)(data->internal); curr_poly_t *c = &s->curr_poly; dd_precision_t precision = 0; uint32 precision_changed = 0; if (!dd_precision_is_ieee()) { precision_changed = 1; precision = dd_set_precision_ieee(); } mpz_set(c->gmp_lina[0], rat_coeffs[0]); mpz_set(c->gmp_lina[1], rat_coeffs[1]); mpz_neg(c->gmp_d, rat_coeffs[0]); mpz_set(c->gmp_p, rat_coeffs[1]); for (i = 0; i <= data->degree; i++) mpz_set(c->gmp_a[i], alg_coeffs[i]); if (sizeopt_norm == 0) { /* size optimization possibly did not run previously; check poly and get the norm */ if (check_poly(c, c->gmp_a, c->gmp_lina[0], data->gmp_N, data->degree) != 1) { goto finished; } optimize_initial(c, data->degree, &sizeopt_norm, 1); stage2_root_score(data->degree, c->gmp_a, 100, &projective_alpha, 1); } if (sizeopt_norm * exp(projective_alpha) <= data->max_sizeopt_norm) root_sieve_run(data, sizeopt_norm, projective_alpha); finished: if (precision_changed) dd_clear_precision(precision); }
/*-------------------------------------------------------------------------*/ static void optimize(curr_poly_t *c, poly_stage2_t *data, root_sieve_t *rs, assess_t *assess, stage2_stat_t *stats) { int err; double skewness; double pol_norm; double alpha_proj; double log_max_norm_2 = log(data->max_norm_2); profile_start(PROF_ALL); while (1) { err = read_a5pd(c, data); if (err < 0) { if (feof(data->infile)) break; continue; } if (!pol_expand(c, data->gmp_N)) { mpz_out_str(stdout, 10, c->gmp_a[5]); fprintf(stderr, "expand failed\n"); continue; } profile_start(PROF_INITIAL_OPTIMIZE); optimize_1(c, &skewness, &pol_norm, &alpha_proj); profile_stop(PROF_INITIAL_OPTIMIZE); if (pol_norm * exp(alpha_proj) > data->max_norm_1) continue; root_sieve_run(c, log_max_norm_2, data, rs, assess, stats, skewness, pol_norm, alpha_proj); } profile_stop(PROF_ALL); }