Example #1
0
/*-------------------------------------------------------------------------*/
void
poly_sizeopt_run(poly_sizeopt_t *data, mpz_t ad, mpz_t p, mpz_t d)
{
	double pol_norm;
	double alpha_proj;
	int status;
	curr_poly_t *c = (curr_poly_t *)(data->internal);

	mpz_set(c->gmp_d, d);
	mpz_set(c->gmp_p, p);
	mpz_neg(c->gmp_lina[0], c->gmp_d);
	mpz_set(c->gmp_lina[1], c->gmp_p);

	status = pol_expand(c, data->gmp_N, ad, p, d, 
			data->max_stage1_norm, data->degree);
	if (status != 2) {
		if (status == 0)
			fprintf(stderr, "expand failed\n");
		return;
	}

	optimize_initial(c, data->degree, &pol_norm, 0);

	stage2_root_score(data->degree, c->gmp_a, 100, &alpha_proj, 1);

	if (pol_norm * exp(alpha_proj) <= data->max_sizeopt_norm) {
		data->callback(data->degree, c->gmp_a, c->gmp_lina, 
				pol_norm, alpha_proj, 
				data->callback_data);
	}
}
Example #2
0
/*-------------------------------------------------------------------------*/
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);
}