Exemplo n.º 1
0
	/**
	 \brief add a projection to the solver.
	 \param proj the new projection to add.
	 */
	void add_projection(vec_mp proj)
	{
		if (this->num_projections==0) {
			this->pi = (vec_mp *) br_malloc(sizeof(vec_mp));
		}
		else {
			this->pi = (vec_mp *) br_realloc(pi,(this->num_projections+1) *sizeof(vec_mp));
		}

		init_vec_mp(pi[num_projections],0);
		vec_cp_mp(pi[num_projections], proj);

		if (this->MPType==2){
			if (this->num_projections==0) {
				this->pi_full_prec = (vec_mp *) br_malloc(sizeof(vec_mp));
			}
			else {
				this->pi_full_prec = (vec_mp *) br_realloc(pi_full_prec,(this->num_projections+1) *sizeof(vec_mp));
			}

			init_vec_mp2(pi_full_prec[num_projections],0,1024);
			vec_cp_mp(pi_full_prec[num_projections], proj);
		}
		num_projections++;

	}
Exemplo n.º 2
0
int LinearHolder::add_linear(vec_mp new_linear)
{

	if (num_linears_!=0 && L_mp_==NULL) {
		printf("trying to add linear to linear holder with non-zero num_linears and NULL container!\n");
		br_exit(9711);
	}

	if (num_linears_==0 && L_mp_!=NULL) {
		printf("trying to add linear to linear holder with num_linears==0 and non-NULL container!\n");
		br_exit(9711);
	}


	if (num_linears_==0) {
		L_mp_ = (vec_mp *)br_malloc(sizeof(vec_mp));
	}
	else{
		L_mp_ = (vec_mp *)br_realloc(L_mp_, (num_linears_+1) * sizeof(vec_mp));
	}

	init_vec_mp2(L_mp_[num_linears_], new_linear->size,new_linear->curr_prec);
	L_mp_[num_linears_]->size = new_linear->size;
	vec_cp_mp(L_mp_[num_linears_], new_linear);

	this->num_linears_++;


	return num_linears_-1;
}
Exemplo n.º 3
0
int PointHolder::add_point(vec_mp new_point)
{

	if (num_pts_!=0 && this->pts_mp_==NULL) {
		printf("trying to add point to PointHolder with non-zero num_points and NULL container!\n");
		br_exit(9713);
	}

	if (num_pts_==0 && this->pts_mp_!=NULL) {
		printf("trying to add point to PointHolder with num_points==0 and non-NULL container!\n");
		br_exit(9713);
	}


	if (num_pts_==0) {
		pts_mp_ = (vec_mp *)br_malloc(sizeof(vec_mp));
	}
	else{
		pts_mp_ = (vec_mp *)br_realloc(pts_mp_, (num_pts_+1) * sizeof(vec_mp));
	}

	init_vec_mp2(pts_mp_[num_pts_], new_point->size, new_point->curr_prec);
	pts_mp_[num_pts_]->size = new_point->size;
	vec_cp_mp(pts_mp_[num_pts_], new_point);

	num_pts_++;

	return num_pts_-1;
}
Exemplo n.º 4
0
	/**
	 \brief add a projection to the set, and get its index.
	 
	 Add a projection to the set, and get its index.  Does not test for uniqueness of the projection, assumes it is not in there yet.
	 
	 \return the index of the added projection
	 \param proj the projection to add.
	 
	 */
	int add_projection(vec_mp proj){
		
		if (this->num_projections_==0) {
			projections_ = (vec_mp *) br_malloc(sizeof(vec_mp));
		}
		else{
			this->projections_ = (vec_mp *)br_realloc(this->projections_, (this->num_projections_+1) * sizeof(vec_mp));
		}
		
		
		init_vec_mp2(this->projections_[num_projections_],num_natural_variables_,T_->AMP_max_prec);
		this->projections_[num_projections_]->size = num_natural_variables_;
		
		
		if (proj->size != num_natural_variables_) {
			vec_mp tempvec;
			init_vec_mp2(tempvec,num_natural_variables_,T_->AMP_max_prec); tempvec->size = num_natural_variables_;
			for (int kk=0; kk<num_natural_variables_; kk++) {
				set_mp(&tempvec->coord[kk], &proj->coord[kk]);
			}
			vec_cp_mp(projections_[num_projections_], tempvec);
			clear_vec_mp(tempvec);
		}
		else
		{
			vec_cp_mp(projections_[num_projections_], proj);
		}
		

		num_projections_++;
		
		return num_projections_;
	}
	void copy(const multilintolin_eval_data_mp & other)
	{
		SolverMultiplePrecision::copy(other);
		
		
		if (this->num_linears==0) {
			current_linear = (vec_mp *) br_malloc(other.num_linears*sizeof(vec_mp));
			old_linear = (vec_mp *) br_malloc(other.num_linears*sizeof(vec_mp));
		}
		else
		{
			current_linear = (vec_mp *) br_realloc(current_linear, other.num_linears*sizeof(vec_mp));
			old_linear = (vec_mp *) br_realloc(old_linear, other.num_linears*sizeof(vec_mp));
		}
		
		for (int ii=0; ii<other.num_linears; ii++) {
			init_vec_mp(current_linear[ii],0);
			init_vec_mp(old_linear[ii],0);
			vec_cp_mp(current_linear[ii],other.current_linear[ii]);
			vec_cp_mp(old_linear[ii],other.old_linear[ii]);
		}
		
		
		
		if (this->MPType==2) {
			if (this->num_linears==0) {
				current_linear_full_prec = (vec_mp *) br_malloc(other.num_linears*sizeof(vec_mp));
				old_linear_full_prec = (vec_mp *) br_malloc(num_linears*sizeof(vec_mp));
			}
			else
			{
				current_linear_full_prec = (vec_mp *) br_realloc(current_linear_full_prec, other.num_linears*sizeof(vec_mp));
				old_linear_full_prec = (vec_mp *) br_realloc(old_linear_full_prec, other.num_linears*sizeof(vec_mp));
			}
			
			for (int ii=0; ii<other.num_linears; ii++) {
				init_vec_mp2(current_linear_full_prec[ii],0,1024);
				init_vec_mp2(old_linear_full_prec[ii],0,1024);
				vec_cp_mp(current_linear_full_prec[ii],other.current_linear_full_prec[ii]);
				vec_cp_mp(old_linear_full_prec[ii],other.old_linear_full_prec[ii]);
			}
		}
		
		this->num_linears= other.num_linears;
	} // re: copy
Exemplo n.º 6
0
	/**
	 \brief add a projection to the solver.
	 \param proj the new projection to add.
	 */
	void add_projection(vec_d proj)
	{
		if (this->num_projections==0) {
			this->pi = (vec_d *) br_malloc(sizeof(vec_d));
		}
		else {
			this->pi = (vec_d *) br_realloc(pi,(this->num_projections+1) *sizeof(vec_d));
		}

		init_vec_d(pi[num_projections],0);
		vec_cp_d(pi[num_projections], proj);

		num_projections++;
	}
Exemplo n.º 7
0
void WitnessSet::only_first_vars(int num_vars)
{
	
	vec_mp tempvec;  init_vec_mp2(tempvec, num_vars, 1024);
	tempvec->size = num_vars;
	
	for (unsigned int ii=0; ii<num_points(); ii++) {
		vec_mp & curr_point = point(ii);
		
		for (int jj=0; jj<num_vars; jj++) {
			set_mp(&tempvec->coord[jj], &curr_point->coord[jj]);
		}
		
		change_size_vec_mp(curr_point, num_vars);  curr_point->size = num_vars;
		vec_cp_mp(curr_point, tempvec);
	}
	
	
	this->num_vars_ = num_vars;
	
	int patch_size_counter = 0, trim_from_here =  0;
	for (unsigned int ii=0; ii<num_patches(); ii++) {
		patch_size_counter += patch(ii)->size;
		if (patch_size_counter == num_vars)
		{
			trim_from_here = ii+1;
		}
	}
	
	if (trim_from_here==0) {
		std::cerr << "problem: the sum of the patch sizes never equalled the number of variables to trim to...\nhence, the trimming operation could not complete." << std::endl;
		this->print_to_screen();
		deliberate_segfault();
	}
	
	for (unsigned int ii=trim_from_here; ii<num_patches(); ii++) {
		clear_vec_mp(patch(ii));
	}
	
	patch_mp_ = (vec_mp *) br_realloc(patch_mp_, trim_from_here* sizeof(vec_mp));
	num_patches_ = trim_from_here;
	
	for (unsigned int ii=0; ii<num_linears(); ii++) {
		linear(ii)->size = num_vars;
	}
	
	clear_vec_mp(tempvec);
	return;
}
Exemplo n.º 8
0
	void copy(const VertexSet &other)
	{
		set_tracker_config(other.T());
		
		
		this->curr_projection_ = other.curr_projection_;
		if (this->num_projections_==0 && other.num_projections_>0) {
			projections_ = (vec_mp *) br_malloc(other.num_projections_*sizeof(vec_mp));
		}
		else if(this->num_projections_>0 && other.num_projections_>0) {
			projections_ = (vec_mp *) br_realloc(projections_,other.num_projections_*sizeof(vec_mp));
		}
		else if (this->num_projections_>0 && other.num_projections_==0){
			for (int ii=0; ii<this->num_projections_; ii++) {
				clear_vec_mp(projections_[ii]);
			}
			free(projections_);
		}
		
		for (int ii=0; ii<other.num_projections_; ii++) {
			if (ii>=this->num_projections_){
				init_vec_mp2(projections_[ii],1,1024); projections_[ii]->size = 1;
			}
			vec_cp_mp(projections_[ii],other.projections_[ii]);
		}
		
		this->num_projections_ = other.num_projections_;
		
		
		curr_input_index_ = other.curr_input_index_;
		filenames_ = other.filenames_;
		
		
		this->num_vertices_ = other.num_vertices_;
		this->num_natural_variables_ = other.num_natural_variables_;
		
		this->vertices_ = other.vertices_;
		
		vec_cp_mp(this->checker_1_,other.checker_1_);
		vec_cp_mp(this->checker_2_,other.checker_2_);
		
	}
Exemplo n.º 9
0
int PatchHolder::add_patch(vec_mp new_patch)
{

	if (num_patches_!=0 && patch_mp_==NULL) {
		printf("trying to add patch to witness set with non-zero num_patches and NULL container!\n");
		deliberate_segfault();
	}

	if (num_patches_==0 && patch_mp_!=NULL) {
		printf("trying to add point to witness set with num_points==0 and non-NULL container!\n");
		deliberate_segfault();
	}


	if (num_patches_==0) {
		patch_mp_ = (vec_mp *)br_malloc(sizeof(vec_mp));
	}
	else{
		patch_mp_ = (vec_mp *)br_realloc(patch_mp_, (num_patches_+1) * sizeof(vec_mp));
	}

	init_vec_mp2(patch_mp_[num_patches_], new_patch->size,new_patch->curr_prec);
	patch_mp_[num_patches_]->size = new_patch->size;
	vec_cp_mp(patch_mp_[num_patches_], new_patch);

	this->num_patches_++;


	int burnsome = 0;
	for (unsigned int ii=0; ii<this->num_patches_; ii++) {
		burnsome += this->patch_mp_[ii]->size;
	}


	return num_patches_-1;
}
Exemplo n.º 10
0
int sphere_eval_data_d::setup(SphereConfiguration & config,
							  const WitnessSet & W,
							  SolverConfiguration & solve_options)
{
	
	SLP_memory = config.SLP_memory;
	
	// set up the vectors to hold the two linears.
	
	
	mp_to_d(radius, config.radius);
	vec_mp_to_d(center, config.center);
    
    if (this->center->size < W.num_variables()) {
        int old_size = this->center->size;
        increase_size_vec_d(this->center, W.num_variables());
        this->center->size = W.num_variables();
        
        for (int ii=old_size; ii<W.num_variables(); ii++) {
            set_zero_d(&this->center->coord[ii]);
        }
    }
    
    
	if (this->num_static_linears==0) {
		static_linear = (vec_d *) br_malloc(W.num_linears()*sizeof(vec_d));
	}
	else
	{
		static_linear = (vec_d *) br_realloc(static_linear, W.num_linears()*sizeof(vec_d));
	}
	
	for (unsigned int ii=0; ii<W.num_linears(); ii++) {
		init_vec_d(static_linear[ii],0);
		vec_mp_to_d(static_linear[ii],W.linear(ii));
	}
	num_static_linears = W.num_linears();
	
    num_natural_vars = W.num_natural_variables();
	num_variables = W.num_variables();
	
	
	
	for (int ii=0; ii<2; ii++) {
		vec_mp_to_d(starting_linear[ii],config.starting_linear[ii]);
	}
	
	verbose_level(solve_options.verbose_level());
	
	SolverDoublePrecision::setup(config.SLP, config.randomizer());
	
	generic_setup_patch(&patch,W);
	
	if (solve_options.use_gamma_trick==1)
		get_comp_rand_d(this->gamma); // set gamma to be random complex value
	else
		set_one_d(this->gamma);
	
	
	
	
	if (this->MPType==2)
	{
		this->BED_mp->setup(config, W, solve_options);
		rat_to_d(this->gamma, this->BED_mp->gamma_rat);
	}
	
	return 0;
}
Exemplo n.º 11
0
int sphere_eval_data_mp::setup(SphereConfiguration & config,
							   const WitnessSet & W,
							   SolverConfiguration & solve_options)
{
	
	
	if (config.randomizer().use_count()==0) {
		std::cout << "don't have randomizer set up!" << std::endl;
		br_exit(-97621);
	}
	
	if (!config.have_mem) {
		std::cout << "don't have memory!" << std::endl;
		br_exit(-3231);
	}
	
	this->SLP_memory = config.SLP_memory;
	
	num_natural_vars = W.num_natural_variables();
	num_variables = W.num_variables();
	
	
	// set up the vectors to hold the linears.
	if (this->num_static_linears==0) {
		static_linear = (vec_mp *) br_malloc(W.num_linears()*sizeof(vec_mp));
	}
	else
	{
		static_linear = (vec_mp *) br_realloc(static_linear, W.num_linears()*sizeof(vec_mp));
	}
	
	for (unsigned int ii=0; ii<W.num_linears(); ii++) {
		init_vec_mp(static_linear[ii],0);
		vec_cp_mp(static_linear[ii],W.linear(ii));
	}
	
	
	
	set_mp(this->radius, config.radius);
	vec_cp_mp(this->center, config.center);
	if (this->center->size < W.num_variables()) {
        int old_size = this->center->size;
        increase_size_vec_mp(this->center, W.num_variables());
        this->center->size = W.num_variables();
        
        for (int ii=old_size; ii<W.num_variables(); ii++) {
            set_zero_mp(&this->center->coord[ii]);
        }
    }
    
    
	if (this->MPType==2) {
		
		set_mp(this->radius_full_prec, config.radius);
		vec_cp_mp(this->center_full_prec, config.center);
        if (this->center_full_prec->size < W.num_variables()) {
            int old_size = this->center_full_prec->size;
            increase_size_vec_mp(this->center_full_prec, W.num_variables());
            this->center_full_prec->size = W.num_variables();
            
            for (int ii=old_size; ii<W.num_variables(); ii++) {
                set_zero_mp(&this->center_full_prec->coord[ii]);
            }
        }
        
        
		
		if (this->num_static_linears==0) {
			static_linear_full_prec = (vec_mp *) br_malloc(W.num_linears()*sizeof(vec_mp));
		}
		else
		{
			static_linear_full_prec = (vec_mp *) br_realloc(static_linear_full_prec, W.num_linears()*sizeof(vec_mp));
		}
		
		for (unsigned int ii=0; ii<W.num_linears(); ii++) {
			init_vec_mp2(static_linear_full_prec[ii],0,1024);
			
			vec_cp_mp(static_linear_full_prec[ii], W.linear(ii));
		}
	}
	
	this->num_static_linears = W.num_linears();
	
	
	
	
	
	for (int ii=0; ii<2; ii++) {
		vec_cp_mp( this->starting_linear[ii], config.starting_linear[ii]);
		
		if (MPType==2) {
			vec_cp_mp(this->starting_linear_full_prec[ii], config.starting_linear[ii]);
		}
	}
	
	
	
	
	
	// the usual
	
	verbose_level(solve_options.verbose_level());
	
	SolverMultiplePrecision::setup(config.SLP, config.randomizer());
	
	generic_setup_patch(&patch,W);
	
	if (solve_options.use_gamma_trick==1)
		get_comp_rand_mp(this->gamma); // set gamma to be random complex value
	else{
		set_one_mp(this->gamma);
	}
	
	comp_d temp;
	if (this->MPType==2) {
		if (solve_options.use_gamma_trick==1){
			get_comp_rand_rat(temp, this->gamma, this->gamma_rat, 64, solve_options.T.AMP_max_prec, 0, 0);
		}
		else{
			set_one_mp(this->gamma);
			set_one_rat(this->gamma_rat);
		}
	}
	
	

	
	return 0;
}