Example #1
0
void WitnessSet::sort_for_real(tracker_config_t * T)
{
	

	
	
	int *real_indicator = new int[num_points()];
	int counter = 0;
	
	vec_mp result; init_vec_mp(result,num_natty_vars_-1);
	result->size = num_natty_vars_-1;
	
	for (unsigned int ii=0; ii<num_points(); ii++) {
		vec_mp & curr_point = point(ii);
		for (int jj=1; jj<num_natty_vars_; jj++) {
			div_mp(&result->coord[jj-1], &curr_point->coord[jj], &curr_point->coord[0]);
		}
		real_indicator[ii] = checkForReal_mp(result, T->real_threshold);
		
		if (real_indicator[ii]==1) {
			counter++;
		}
	}
	
	
	vec_mp *tempvec = (vec_mp *)br_malloc(counter * sizeof(vec_mp));
	
	counter = 0;  // reset
	for (unsigned int ii=0; ii<num_points(); ii++) {
		vec_mp & curr_point = point(ii);
		if (real_indicator[ii]==1) {
			
			init_vec_mp2(tempvec[counter],this->num_vars_,1024); tempvec[counter]->size = this->num_vars_;
			vec_cp_mp(tempvec[counter],curr_point);
			counter++;
		}
		else{
			
		}
	}
	
	clear_vec_mp(result);
	
	
	for (unsigned int ii=0; ii<num_points(); ii++) {
		clear_vec_mp(point(ii));
	}
	free(pts_mp_);
	
	pts_mp_ = tempvec;
	num_pts_ = counter;
	
	delete[] real_indicator;
	return;
}
Example #2
0
	/**
	 \brief reset to empty state.
	 */
	void clear()
	{

		if (this->num_projections>0) {
			for (int ii=0; ii<num_projections; ii++) {
				clear_vec_mp(pi[ii]);
			}
			free(pi);
		}

		clear_mp(v_target);
		clear_mp(u_target);

		clear_mp(crit_val_left);
		clear_mp(crit_val_right);

		clear_mp(u_start);
		clear_mp(v_start);

		clear_mp(half);
		clear_mp(one);
		clear_mp(zero);


		if (this->MPType==2){

			if (this->num_projections>0) {
				for (int ii=0; ii<num_projections; ii++) {
					clear_vec_mp(pi_full_prec[ii]);
				}
				free(pi_full_prec);
			}

			clear_mp(v_target_full_prec);
			clear_mp(u_target_full_prec);

			clear_mp(crit_val_left_full_prec);
			clear_mp(crit_val_right_full_prec);

			clear_mp(u_start_full_prec);
			clear_mp(v_start_full_prec);

			clear_mp(half_full_prec);
			clear_mp(one_full_prec);
			clear_mp(zero_full_prec);

		}



	} // re: clear
Example #3
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;
}
Example #4
0
	void clear()
	{
		clear_vec_mp(checker_1_);
		clear_vec_mp(checker_2_);
		
		clear_mp(diff_);
		
		mpf_clear(abs_);
		mpf_clear(zerothresh_);
		
		for (int ii=0; ii<num_projections_; ii++) {
			clear_vec_mp(projections_[ii]);
		}
		free(projections_);
	}
Example #5
0
void WitnessSet::write_dehomogenized_coordinates(boost::filesystem::path filename) const
{

	
	vec_mp result; init_vec_mp(result,1);
	
	
	FILE *OUT = safe_fopen_write(filename.c_str()); // open the output file.
	
	fprintf(OUT,"%zu\n\n",num_points()); // print the header line
	for (unsigned int ii=0; ii<num_points(); ++ii) {
		if (this->num_synth_vars()>0) {
			dehomogenize(&result,point(ii), num_natty_vars_);
		}
		else{
			dehomogenize(&result,point(ii));
		}
		
		for (int jj=0; jj<num_natty_vars_-1; jj++) {
			print_mp(OUT, 0, &result->coord[jj]);
			fprintf(OUT, "\n");
		}
		fprintf(OUT,"\n");
	}
	
	fclose(OUT);
	
	clear_vec_mp(result);
	return;
}
Example #6
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_;
	}
int write_member_points_sc(vec_mp point_to_write)
{
	FILE *OUT = NULL;
	int ii;
	
	
	remove("member_points");
	OUT = safe_fopen_write("member_points");
	
	
	vec_mp result;
	init_vec_mp(result,0);
	dehomogenize(&result,point_to_write);
	
	fprintf(OUT,"2\n\n");
	for(ii=0;ii<result->size;ii++)
	{
		print_mp(OUT,0,&result->coord[ii]);  fprintf(OUT,"\n");
	}
	
	
	comp_mp temp; init_mp(temp);
	fprintf(OUT,"\n");
	for(ii=0;ii<result->size;ii++)
	{
		conjugate_mp(temp, &result->coord[ii]);
		print_mp(OUT,0,temp);  fprintf(OUT,"\n");
	}
	fclose(OUT);
	
	clear_vec_mp(result);  clear_mp(temp);
	
	return 0;
}
int write_member_points_singlept(vec_mp point_to_write)
{
	FILE *OUT = NULL;
	
	
	
	OUT = safe_fopen_write("member_points");
	
	
	vec_mp result;
	init_vec_mp(result,0);
	dehomogenize(&result,point_to_write);
	
	fprintf(OUT,"1\n\n");
	for(int ii=0; ii<result->size; ii++){
		print_mp(OUT,0,&result->coord[ii]);
		fprintf(OUT,"\n");
	}
	
	
	fclose(OUT);
	
	
	clear_vec_mp(result);
	
	return 0;
}
Example #9
0
void WitnessSet::read_patches_from_file(boost::filesystem::path filename)
{
	
	FILE *IN = safe_fopen_read(filename);
	
	WitnessSet::reset_patches();
	int curr_num_patches;
	fscanf(IN,"%d\n",&curr_num_patches);
	
	vec_mp temp_patch; init_vec_mp2(temp_patch,1,1024); temp_patch->size = 1;
	for (int ii=0; ii<curr_num_patches; ii++) {
		int curr_size;
		fscanf(IN,"%d\n",&curr_size);
		change_size_vec_mp(temp_patch,curr_size); temp_patch->size = curr_size;
		
		for (int jj=0; jj<curr_size; jj++) {
			mpf_inp_str(temp_patch->coord[jj].r, IN, 10);
			mpf_inp_str(temp_patch->coord[jj].i, IN, 10);
			scanRestOfLine(IN);
		}
		
		WitnessSet::add_patch(temp_patch);
	}
	
	clear_vec_mp(temp_patch);
	fclose(IN);
	
	return;
}
Example #10
0
void WitnessSet::print_to_screen() const
{
	
	vec_mp dehom;  init_vec_mp(dehom,1); dehom->size = 1;
	
	std::stringstream varname;
	
	std::cout << "witness set has " << num_vars_ << " total variables, " << num_natty_vars_ << " natural variables." << std::endl;
	
	
	std::cout << "dim " << dim_ << ", comp " << comp_num_ << std::endl;
	std::cout << "input file name " << input_filename_ << std::endl;

	
	printf("******\n%zu points\n******\n",num_points());
	std::cout << color::green();
	for (unsigned ii=0; ii<num_points(); ii++) {
		
		dehomogenize(&dehom, point(ii), num_natty_vars_);
		
		varname << "point_" << ii;
		
		print_point_to_screen_matlab(dehom,varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << color::blue();
	printf("******\n%zu linears\n******\n",num_linears());
	
	for (unsigned ii=0; ii<num_linears(); ii++) {
		varname << "linear_" << ii;
		print_point_to_screen_matlab(linear(ii),varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << color::cyan();
	printf("******\n%zu patches\n******\n",num_patches());
	
	for (unsigned ii=0; ii<num_patches(); ii++) {
		varname << "patch_" << ii;
		print_point_to_screen_matlab(patch(ii),varname.str());
		varname.str("");
	}
	std::cout << color::console_default();
	
	std::cout << "variable names:\n";
	for (unsigned ii=0; ii< num_var_names(); ii++) {
		std::cout << name(ii) << "\n";
	}
	printf("\n\n");
	
	
	clear_vec_mp(dehom);
}
Example #11
0
	/**
	 reset this object to an empty state.
	 */
	void reset_linears()
	{
		for (unsigned int ii =0; ii<num_linears_; ii++)
			clear_vec_mp(L_mp_[ii]);

		if (num_linears_>0) {
			free(L_mp_);
		}

		num_linears_ = 0;
		L_mp_ = NULL;
	}
Example #12
0
	/**
	 \brief resets the patch holder to empty.

	 Reset the PatchHolder to 0 patches.
	 */
	void reset_patches()
	{
		for (unsigned int ii =0; ii<num_patches_; ii++)
			clear_vec_mp(patch_mp_[ii]);

		if (num_patches_>0) {
			free(patch_mp_);
		}

		num_patches_ = 0;
		patch_mp_ = NULL;
	}
	void clear()
	{
		
		
		for (int ii=0; ii<num_linears; ii++) {
			clear_vec_mp(current_linear[ii]);
			clear_vec_mp(old_linear[ii]);
		}
		free(current_linear);
		free(old_linear);
		
		
		if (this->MPType == 2) {
			for (int ii=0; ii<num_linears; ii++) {
				clear_vec_mp(current_linear_full_prec[ii]);
				clear_vec_mp(old_linear_full_prec[ii]);
			}
			free(current_linear_full_prec);
			free(old_linear_full_prec);
		}
		
		
		
	} // re: clear
Example #14
0
	/**
	 reset the set to empty.
	 */
	void reset()
	{
		for (int ii=0; ii<num_projections_; ii++) {
			clear_vec_mp(projections_[ii]);
		}
		num_projections_ = 0;
		
		filenames_.resize(0);
		
		vertices_.resize(0);
		num_vertices_ = 0;
		
		clear();
		init();
	}
Example #15
0
	void clear()
	{

		clear_mp(v_target);
		clear_mp(u_target);
		clear_mp(crit_val_left);
		clear_mp(crit_val_right);

		if (num_projections>0) {
			for (int ii=0; ii<num_projections; ii++) {
				clear_vec_mp(pi[ii]);
			}
			free(pi);
		}

	}
Example #16
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_);
		
	}
Example #17
0
void WitnessSet::write_dehomogenized_coordinates(boost::filesystem::path filename,std::set<unsigned int> indices) const
{
	
	for (auto ii=indices.begin(); ii!=indices.end(); ++ii) {
		if (*ii >= this->num_points()) {
			std::cout << "requested to print out-of-range point index " << *ii << " to a dehomogenized file." << std::endl;
			std::cout << "[this WitnessSet contains " << num_points() << " points.]" << std::endl;
			br_exit(66190);
		}
	}
	
	
	
	
	vec_mp result; init_vec_mp(result,1);
	
	
	FILE *OUT = safe_fopen_write(filename.c_str()); // open the output file.
	
	fprintf(OUT,"%lu\n\n",indices.size()); // print the header line
	for (auto ii=indices.begin(); ii!=indices.end(); ++ii) {
		if (this->num_synth_vars()>0) {
			dehomogenize(&result,this->point(*ii), num_natty_vars_);
		}
		else{
			dehomogenize(&result,this->point(*ii));
		}
		
		for (int jj=0; jj<num_natty_vars_-1; jj++) {
			print_mp(OUT, 0, &result->coord[jj]);
			fprintf(OUT, "\n");
		}
		fprintf(OUT,"\n");
	}
	
	fclose(OUT);
	
	clear_vec_mp(result);
	return;
}
Example #18
0
void WitnessSet::receive(int source, ParallelismConfig & mpi_config)
{
    MPI_Status statty_mc_gatty;
    
	int *buffer = new int[8];
    
    
    MPI_Recv(buffer, 8, MPI_INT, WITNESS_SET, source, mpi_config.comm(), &statty_mc_gatty);
    
    set_dimension(buffer[0]);
    comp_num_ = buffer[1];
    incid_num_ = buffer[2];
    num_vars_ = buffer[3];
    num_natty_vars_ = buffer[4];
    unsigned int temp_num_pts = buffer[5];
    unsigned int temp_num_linears = buffer[6];
    unsigned int temp_num_patches = buffer[7];
    
	delete [] buffer;
	
    vec_mp tempvec; init_vec_mp2(tempvec,0,1024);
    
    for (unsigned int ii=0; ii<temp_num_linears; ii++) {
        receive_vec_mp(tempvec,source);
        add_linear(tempvec);
    }
    
    for (unsigned int ii=0; ii<temp_num_patches; ii++) {
        receive_vec_mp(tempvec,source);
        add_patch(tempvec);
    }
    
	for (unsigned int ii=0; ii<temp_num_pts; ii++) {
        receive_vec_mp(tempvec,source);
        add_point(tempvec);
    }
    
    clear_vec_mp(tempvec);
    return;
}
	void clear()
	{
		
		if (num_additional_linears>0) {
			for (int ii=0; ii<num_additional_linears; ii++) {
				clear_vec_mp(additional_linears_terminal[ii]);
			}
			free(additional_linears_terminal);
			
			for (int ii=0; ii<num_additional_linears; ii++) {
				clear_vec_mp(additional_linears_starting[ii]);
			}
			free(additional_linears_starting);
		}
		
		
	
		
		if (num_jac_equations>0) {
			if (side_ == nullspace_handedness::LEFT) {
				for (int ii=0; ii<num_jac_equations; ii++) {
					for (int jj=0; jj<max_degree; jj++) {
						clear_vec_mp(starting_linears[ii][jj]);
					}
					free(starting_linears[ii]);
				}
			}
			else
			{
				for (int ii=0; ii<randomizer()->num_rand_funcs(); ii++) {
					for (int jj=0; jj<randomizer()->randomized_degree(ii)-1; jj++) {
						clear_vec_mp(starting_linears[ii][jj]);
					}
					free(starting_linears[ii]);
				}
			}
			
			free(starting_linears);
		}
		
		
		
		
		if (num_v_linears>0) {
			for (int ii=0; ii<num_v_linears; ii++) {
				clear_vec_mp(v_linears[ii]);
			}
			free(v_linears);
		}
		
		
		clear_vec_mp(v_patch);
		
		clear_mat_mp(jac_with_proj);
		

		
		
		if (num_projections>0) {
			for (int ii=0; ii<num_projections; ii++) {
				clear_vec_mp(target_projection[ii]);
			}
			free(target_projection);
		}
		
		
		
		if (this->MPType==2) {
			
			if (num_additional_linears>0) {
				for (int ii=0; ii<num_additional_linears; ii++) {
					clear_vec_mp(additional_linears_terminal_full_prec[ii]);
				}
				free(additional_linears_terminal_full_prec);
				
				for (int ii=0; ii<num_additional_linears; ii++) {
					clear_vec_mp(additional_linears_starting_full_prec[ii]);
				}
				free(additional_linears_starting_full_prec);
			}
			
			
			
			
			if (num_jac_equations>0) {
				if (side_ == nullspace_handedness::LEFT) {
					for (int ii=0; ii<num_jac_equations; ii++) {
						for (int jj=0; jj<max_degree; jj++) {
							clear_vec_mp(starting_linears_full_prec[ii][jj]);
						}
						free(starting_linears_full_prec[ii]);
					}
				}
				else
				{
					for (int ii=0; ii<randomizer()->num_rand_funcs(); ii++) {
						for (int jj=0; jj<randomizer()->randomized_degree(ii)-1; jj++) {
							clear_vec_mp(starting_linears_full_prec[ii][jj]);
						}
						free(starting_linears_full_prec[ii]);
					}
				}
				
				free(starting_linears_full_prec);
			}
			
			
			
			
			for (int ii=0; ii<num_v_linears; ii++)
				clear_vec_mp(v_linears_full_prec[ii]);
			
			free(v_linears_full_prec);
			
			clear_vec_mp(v_patch_full_prec);
			clear_mat_mp(jac_with_proj_full_prec);

			
			
			if (num_projections>0) {
				for (int ii=0; ii<num_projections; ii++) {
					clear_vec_mp(target_projection_full_prec[ii]);
				}
				free(target_projection_full_prec);
			}
		}
		
		clear_deriv(SLP_derivative);
		delete this->SLP_derivative;
		
	} // re: clear
//this derived from basic_eval_d
int sphere_eval_mp(point_mp funcVals, point_mp parVals, vec_mp parDer, mat_mp Jv, mat_mp Jp, point_mp current_variable_values, comp_mp pathVars, void const *ED)
{ // evaluates a special homotopy type, built for bertini_real
	
	//	print_comp_mp_matlab(pathVars,"pathvars");
	
	
	sphere_eval_data_mp *BED = (sphere_eval_data_mp *)ED; // to avoid having to cast every time
	
	BED->SLP_memory.set_globals_to_this();
	
	int ii, jj, mm; // counters
	int offset;
	comp_mp one_minus_s, gamma_s;
	comp_mp temp, temp2;
	comp_mp func_val_sphere, func_val_start;
	init_mp(one_minus_s);  init_mp(gamma_s);
	init_mp(temp);  init_mp(temp2);
	init_mp(func_val_start);
	init_mp(func_val_sphere);
	
	set_one_mp(one_minus_s);
	sub_mp(one_minus_s, one_minus_s, pathVars);  // one_minus_s = (1 - s)
	mul_mp(gamma_s, BED->gamma, pathVars);       // gamma_s = gamma * s
	
	
	vec_mp patchValues; init_vec_mp(patchValues, 0);
	vec_mp temp_function_values; init_vec_mp(temp_function_values,0);
	vec_mp AtimesF; init_vec_mp(AtimesF,BED->randomizer()->num_rand_funcs()); AtimesF->size = BED->randomizer()->num_rand_funcs();// declare  // initialize
	
	
	
	mat_mp temp_jacobian_functions; init_mat_mp(temp_jacobian_functions,BED->randomizer()->num_base_funcs(),BED->num_variables);
	temp_jacobian_functions->rows = BED->randomizer()->num_base_funcs(); temp_jacobian_functions->cols = BED->num_variables;
	mat_mp temp_jacobian_parameters; init_mat_mp(temp_jacobian_parameters,0,0);
	mat_mp Jv_Patch; init_mat_mp(Jv_Patch, 0, 0);
	mat_mp AtimesJ; init_mat_mp(AtimesJ,BED->randomizer()->num_rand_funcs(),BED->num_variables);
	AtimesJ->rows = BED->randomizer()->num_rand_funcs(); AtimesJ->cols = BED->num_variables;
	
	
	//set the sizes
	change_size_vec_mp(funcVals,BED->num_variables); funcVals->size = BED->num_variables;
	change_size_mat_mp(Jv, BED->num_variables, BED->num_variables); Jv->rows = Jv->cols = BED->num_variables; //  -> this should be square!!!
	
	for (ii=0; ii<BED->num_variables; ii++)
		for (jj=0; jj<BED->num_variables; jj++)
			set_zero_mp(&Jv->entry[ii][jj]);
	
	
	
	// evaluate the SLP to get the system's whatnot.
	evalProg_mp(temp_function_values, parVals, parDer, temp_jacobian_functions, temp_jacobian_parameters, current_variable_values, pathVars, BED->SLP);
	
	
	// evaluate the patch
	patch_eval_mp(patchValues, parVals, parDer, Jv_Patch, Jp, current_variable_values, pathVars, &BED->patch);  // Jp is ignored
	
	
	// we assume that the only parameter is s = t and setup parVals & parDer accordingly.
	// note that you can only really do this AFTER you are done calling other evaluators.
	// set parVals & parDer correctly
	
	// i.e. these must remain here, or below.  \/
	change_size_point_mp(parVals, 1);
	change_size_vec_mp(parDer, 1);
	change_size_mat_mp(Jp, BED->num_variables, 1); Jp->rows = BED->num_variables; Jp->cols = 1;
	for (ii=0; ii<BED->num_variables; ii++)
		set_zero_mp(&Jp->entry[ii][0]);
	
	
	parVals->size = parDer->size = 1;
	set_mp(&parVals->coord[0], pathVars); // s = t
	set_one_mp(&parDer->coord[0]);       // ds/dt = 1
	
	
	
	///////////////////////////
	//
	// the original (randomized) functions.
	//
	///////////////////////////////////
	
	BED->randomizer()->randomize(AtimesF,AtimesJ,temp_function_values,temp_jacobian_functions,&current_variable_values->coord[0]);
	
	
	for (ii=0; ii<AtimesF->size; ii++)  // for each function, after (real orthogonal) randomization
		set_mp(&funcVals->coord[ii], &AtimesF->coord[ii]);
	
	
	for (ii = 0; ii < BED->randomizer()->num_rand_funcs(); ii++)
		for (jj = 0; jj < BED->num_variables; jj++)
			set_mp(&Jv->entry[ii][jj],&AtimesJ->entry[ii][jj]);
	
	//Jp is 0 for the equations.
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	///////////////////
	//
	//  the sphere equation.
	//
	//////////////////////////
	
	offset = BED->randomizer()->num_rand_funcs();
	
	mul_mp(func_val_sphere, BED->radius, BED->radius);
	neg_mp(func_val_sphere, func_val_sphere);
	mul_mp(func_val_sphere, func_val_sphere, &current_variable_values->coord[0]);
	mul_mp(func_val_sphere, func_val_sphere, &current_variable_values->coord[0]);
	//f_sph = -r^2*h^2
	
	
	
	for (int ii=1; ii<BED->num_natural_vars; ii++) {
		mul_mp(temp2, &BED->center->coord[ii-1], &current_variable_values->coord[0]); // temp2 = c_{i-1}*h
		
		sub_mp(temp, &current_variable_values->coord[ii], temp2);  // temp = x_i - h*c_{i-1}
		mul_mp(temp2, temp, temp);                                 // temp2 = (x_i - h*c_{i-1})^2
		add_mp(func_val_sphere, func_val_sphere, temp2);           // f_sph += (x_i - h*c_{i-1})^2
	}
	
	
	
	set_one_mp(func_val_start);
	for (mm=0; mm<2; ++mm) {
		dot_product_mp(temp, BED->starting_linear[mm], current_variable_values);
		mul_mp(func_val_start, func_val_start, temp);
		//f_start *= L_i (x)
	}
	
	
	// combine the function values
	mul_mp(temp, one_minus_s, func_val_sphere);
	mul_mp(temp2, gamma_s, func_val_start);
	add_mp(&funcVals->coord[offset], temp, temp2);
	// f = (1-t) f_sph + gamma t f_start
	
	
	
	
	//// / / / / / /    now the derivatives wrt x
	
	//  first we store the derivatives of the target function, the sphere.  then we will add the part for the linear product start.
	
	
	
	//ddx for sphere
	
	
	
	for (int ii=1; ii<BED->num_natural_vars; ii++) {
		mul_mp(temp2, &BED->center->coord[ii-1], &current_variable_values->coord[0]); // temp2 = c_{i-1}*h
		sub_mp(temp, &current_variable_values->coord[ii], temp2) // temp = x_i - c_{i-1}*h
		mul_mp(&Jv->entry[offset][ii], BED->two, temp); // Jv = 2*(x_i - c_{i-1}*h)
		mul_mp(&Jv->entry[offset][ii], &Jv->entry[offset][ii], one_minus_s); // Jv = (1-t)*2*(x_i - c_{i-1}*h)
		
		
		mul_mp(temp2, &BED->center->coord[ii-1], temp);  // temp2 = c_{i-1} * ( x_i - c_{i-1} * h )
		add_mp(&Jv->entry[offset][0], &Jv->entry[offset][0], temp2); // Jv[0] += c_{i-1} * ( x_i - c_{i-1} * h )
	}
	// multiply these entries by (1-t)
	
	
	// the homogenizing var deriv
	mul_mp(temp, &current_variable_values->coord[0], BED->radius);
	mul_mp(temp, temp, BED->radius);  // temp = r^2 h
	
	add_mp(&Jv->entry[offset][0], &Jv->entry[offset][0], temp); // Jv[0] = \sum_{i=1}^n {c_{i-1} * ( x_i - c_{i-1} * h )} + r^2 h
	neg_mp(&Jv->entry[offset][0], &Jv->entry[offset][0]); // Jv[0] = -Jv[0]
	mul_mp(&Jv->entry[offset][0], &Jv->entry[offset][0], BED->two);  // Jv[0] *= 2
	mul_mp(&Jv->entry[offset][0], &Jv->entry[offset][0], one_minus_s);  // Jv[0] *= (1-t)
	
	// f = \sum{ ( x_i - c_{i-1} * h )^2 } - r^2 h^2
	//Jv = -2(1-t) (  \sum_{i=1}^n {  c_{i-1} * ( x_i - c_{i-1} * h )  } + r^2 h )
	
	
	// a hardcoded product rule for the two linears.
	for (int ii=0; ii<BED->num_variables; ii++) {
		
		dot_product_mp(temp, BED->starting_linear[0], current_variable_values);
		mul_mp(temp, temp, &BED->starting_linear[1]->coord[ii]);
		
		dot_product_mp(temp2, BED->starting_linear[1], current_variable_values);
		mul_mp(temp2, temp2, &BED->starting_linear[0]->coord[ii]);
		
		add_mp(temp, temp, temp2);
		mul_mp(temp2, temp, gamma_s);
		
		//temp2 = gamma s * (L_1(x) * L_0[ii] + L_0(x) * L_1[ii])
		
		//temp2 now has the value of the derivative of the start system wrt x_i
		
		add_mp(&Jv->entry[offset][ii], &Jv->entry[offset][ii], temp2);
	}
	
	
	
	// finally, the Jp entry for sphere equation's homotopy.
	//Jp = -f_sph + gamma f_start
	neg_mp(&Jp->entry[offset][0], func_val_sphere);
	mul_mp(temp, BED->gamma, func_val_start);
	add_mp(&Jp->entry[offset][0], &Jp->entry[offset][0], temp);
	
	
	
	
	
	
	
	//////////////
	//
	// function values for the static linears
	//
	////////////////////
	
	offset++;
	for (mm=0; mm<BED->num_static_linears; ++mm) {
		dot_product_mp(&funcVals->coord[mm+offset], BED->static_linear[mm], current_variable_values);
	}
	
	for (mm=0; mm<BED->num_static_linears; ++mm) {
		for (ii=0; ii<BED->num_variables; ii++) {
			set_mp(&Jv->entry[offset+mm][ii], &BED->static_linear[mm]->coord[ii]);
		}
	}
	
	//Jp is 0 for the static linears
	
	
	
	//////////////
	//
	// the entries for the patch equations.
	//
	////////////////////
	if (offset+BED->num_static_linears != BED->num_variables-BED->patch.num_patches) {
		std::cout << color::red() << "mismatch in offset!\nleft: " <<
		offset+BED->num_static_linears << " right " << BED->num_variables-BED->patch.num_patches << color::console_default() << std::endl;
		mypause();
	}
	
	offset = BED->num_variables-BED->patch.num_patches;
	for (ii=0; ii<BED->patch.num_patches; ii++)
		set_mp(&funcVals->coord[ii+offset], &patchValues->coord[ii]);
	
	
	for (ii = 0; ii<BED->patch.num_patches; ii++)  // for each patch equation
	{  // Jv = Jv_Patch
		for (jj = 0; jj<BED->num_variables; jj++) // for each variable
			set_mp(&Jv->entry[ii+offset][jj], &Jv_Patch->entry[ii][jj]);
	}
	
	//Jp is 0 for the patch.
	
	
	
	
	
	// done!  yay!
	
	if (BED->verbose_level()==16 || BED->verbose_level()==-16) {
		//uncomment to see screen output of important variables at each solve step.
		
		print_comp_matlab(pathVars, "t_mp");
		print_comp_matlab(BED->gamma, "gamma_mp");
		print_point_to_screen_matlab(current_variable_values,"currvars_mp");
		print_point_to_screen_matlab(funcVals,"F_mp");
		print_matrix_to_screen_matlab(Jv,"Jv_mp");
		print_matrix_to_screen_matlab(Jp,"Jp_mp");
		
		
	}
	
	
	BED->SLP_memory.set_globals_null();
	
	clear_mp(temp);
	clear_mp(temp2);
	clear_mp(gamma_s);
	clear_mp(one_minus_s);
	clear_mp(func_val_sphere);
	clear_mp(func_val_start);
	
	clear_vec_mp(patchValues);
	clear_vec_mp(temp_function_values);
	clear_vec_mp(AtimesF);
	
	
	clear_mat_mp(temp_jacobian_functions);
	clear_mat_mp(temp_jacobian_parameters);
	clear_mat_mp(Jv_Patch);
	clear_mat_mp(AtimesJ);
	
	
	
	
	return 0;
}
Example #21
0
int WitnessSet::Parse(const boost::filesystem::path witness_set_file, const int num_vars)
{
	
	
	
	
	FILE *IN = safe_fopen_read(witness_set_file);
	
	
	int temp_num_patches, patch_size, temp_num_linears, temp_num_points, num_vars_in_linears;
	
	
	fscanf(IN, "%d %d %d", &temp_num_points, &dim_, &comp_num_); scanRestOfLine(IN);
	
	
	
	this->num_vars_ = num_vars;
	this->num_natty_vars_ = num_vars;
	
	
	vec_mp temp_vec;  init_vec_mp2(temp_vec, num_vars,1024); temp_vec->size = num_vars;
	
	for (int ii=0; ii < temp_num_points; ii++) {
		
		//read the witness points into memory
		for (int jj=0; jj < num_vars; ++jj) {
			mpf_inp_str(temp_vec->coord[jj].r, IN, 10); // 10 is the base
			mpf_inp_str(temp_vec->coord[jj].i, IN, 10);
			
			scanRestOfLine(IN);
		}
		
		add_point(temp_vec);
	}
	
	
	
	
	
	fscanf(IN, "%d %d", &temp_num_linears, &num_vars_in_linears);  scanRestOfLine(IN);
	
	
	for (int ii=0; ii < temp_num_linears; ii++) {
		change_size_vec_mp(temp_vec,num_vars_in_linears);
		temp_vec->size = num_vars_in_linears;
		
		//read the witness linears into memory
		for (int jj=0; jj < num_vars_in_linears; jj++) {
			mpf_inp_str(temp_vec->coord[jj].r, IN, 10);
			mpf_inp_str(temp_vec->coord[jj].i, IN, 10);
			scanRestOfLine(IN);
		}
		
		add_linear(temp_vec);
	}
	
	
	
	
	fscanf(IN, "%d %d", &temp_num_patches, &patch_size); scanRestOfLine(IN);
	
	if (temp_num_patches>1) {
		std::cerr << temp_num_patches << " patches detected.  this probably indicates a problem." << std::endl;
		std::cerr << "the file being read: " << witness_set_file << std::endl;
		std::cerr << "trying to read " << num_vars << " variables." << std::endl;
		mypause();
	}
	
	
	for (int ii=0; ii < temp_num_patches; ii++) {
		
		change_size_vec_mp(temp_vec,patch_size);
		temp_vec->size = patch_size;
		
		//read the patch into memory
		for (int jj=0; jj < patch_size; jj++) {
			mpf_inp_str(temp_vec->coord[jj].r, IN, 10);
			mpf_inp_str(temp_vec->coord[jj].i, IN, 10);
			scanRestOfLine(IN);
		}
		
		add_patch(temp_vec);
	}
	
	fclose(IN);
	
	
	clear_vec_mp(temp_vec);
	
	return 0;
}
Example #22
0
void WitnessSet::sort_for_inside_sphere(comp_mp radius, vec_mp center)
{
	
	
	
	
	int num_good_pts = 0;
	
	
	std::vector<int> is_ok;
	
	vec_mp temp_vec; init_vec_mp(temp_vec,0);
	comp_mp temp; init_mp(temp);
	
	for (unsigned int ii = 0; ii<num_points(); ++ii) {
		
		
		
		dehomogenize(&temp_vec, point(ii),num_natty_vars_);
		temp_vec->size = center->size;
		
		norm_of_difference(temp->r, temp_vec, center);
		if ( mpf_cmp(temp->r, radius->r) < 0   ){
			is_ok.push_back(1);
			num_good_pts++;
		}
		else
		{
			is_ok.push_back(0);
		}
		
		
		
	}
	
	
	
	vec_mp *transferme = (vec_mp *)br_malloc(num_good_pts*sizeof(vec_mp));
	int counter = 0;
	for (unsigned int ii=0; ii<num_points(); ++ii) {
		if (is_ok[ii]==1) {
			init_vec_mp2(transferme[counter],0,1024);  transferme[counter]->size = 0;
			vec_cp_mp(transferme[counter], point(ii));
			counter++;
		}
	}
	
	if (counter!= num_good_pts) {
		printf("counter mismatch\n");
		br_exit(271);
	}
	
	for (unsigned int ii=0; ii<num_points(); ii++) {
		clear_vec_mp(point(ii));
	}
	free(pts_mp_);
	
	
	num_pts_ = num_good_pts;
	pts_mp_ = transferme;
	
	clear_vec_mp(temp_vec);
	clear_mp(temp);
	return;
}
Example #23
0
// T is necessary for the tolerances.
void WitnessSet::sort_for_unique(tracker_config_t * T)
{
	
	if (num_vars_==0) {
		throw std::logic_error("sorting witness set with 0 variables for uniqueness");
	}
	
	int curr_uniqueness;
	int num_good_pts = 0;
	std::vector<int> is_unique;
	
	for (unsigned int ii = 0; ii<num_points(); ++ii) {
		vec_mp &curr_point = point(ii);
		
		curr_uniqueness = 1;
		
		int prev_size_1 = curr_point->size;  curr_point->size = num_natty_vars_; // cache and change to natural number
		
		for (unsigned int jj=ii+1; jj<num_points(); ++jj) {
			vec_mp & inner_point = point(jj);
			int prev_size_2 = inner_point->size; inner_point->size = num_natty_vars_; // cache and change to natural number
			if ( isSamePoint_homogeneous_input(curr_point,inner_point,T->final_tol_times_mult) ){
				curr_uniqueness = 0;
			}
			inner_point->size = prev_size_2; // restore
		}
		curr_point->size = prev_size_1; // restore
		
		if (curr_uniqueness==1) {
			is_unique.push_back(1);
			num_good_pts++;
		}
		else {
			is_unique.push_back(0);
		}
		
	}
	
	
	
	vec_mp *transferme = (vec_mp *)br_malloc(num_good_pts*sizeof(vec_mp));
	int counter = 0;
	for (unsigned int ii=0; ii<num_points(); ++ii) {
		if (is_unique[ii]==1) {
			
			init_vec_mp2(transferme[counter],num_vars_,1024);  transferme[counter]->size = num_vars_;
			vec_cp_mp(transferme[counter], point(ii));
			counter++;
		}
	}
	
	if (counter!= num_good_pts) {
		std::logic_error("counter mismatch");
	}
	
	if (num_points()>0) {
		for (unsigned int ii=0; ii<num_points(); ii++) {
			clear_vec_mp(point(ii));
		}
		free(pts_mp_);
	}
	
	
	num_pts_ = num_good_pts;
	pts_mp_ = transferme;
	
	return;
}
int check_issoln_sphere_mp(endgame_data_t *EG,
						   tracker_config_t *T,
						   void const *ED)
{
	sphere_eval_data_mp *BED = (sphere_eval_data_mp *)ED; // to avoid having to cast every time
	BED->SLP_memory.set_globals_to_this();
	int ii;
	
	for (ii = 0; ii < T->numVars; ii++)
	{
		if (!(mpfr_number_p(EG->PD_mp.point->coord[ii].r) && mpfr_number_p(EG->PD_mp.point->coord[ii].i)))
		{
			printf("got not a number\n");
			print_point_to_screen_matlab(EG->PD_mp.point,"bad solution");
			return 0;
		}
	}
	
	
	mpf_t n1, n2, zero_thresh, max_rat;
	mpf_init(n1); mpf_init(n2); mpf_init(zero_thresh); mpf_init(max_rat);
	
	mpf_set_d(max_rat, MAX(T->ratioTol,0.99999));
	
	point_mp f; init_point_mp(f, 1);f->size = 1;
	eval_struct_mp e; init_eval_struct_mp(e, 0, 0, 0);
	
	
	int num_digits = prec_to_digits((int) mpf_get_default_prec());
	// setup threshold based on given threshold and precision
	if (num_digits > 300)
		num_digits = 300;
	num_digits -= 4;
	double my_guarantor = MAX(T->funcResTol, 1e-8);
	double tol = MAX(my_guarantor, pow(10,-num_digits));
	mpf_set_d(zero_thresh, tol);
	
	//this one guaranteed by entry condition
	//	sphere_eval_mp(e.funcVals, e.parVals, e.parDer, e.Jv, e.Jp, EG->PD_mp.point, EG->PD_mp.time, ED);
	evalProg_mp(e.funcVals, e.parVals, e.parDer, e.Jv, e.Jp, EG->PD_mp.point, EG->PD_mp.time, BED->SLP);
	//	print_point_to_screen_matlab(e.funcVals,"howfaroff");
	
	if (EG->last_approx_prec < 64)
	{ // copy to _mp
		vec_mp temp_vec;  init_vec_mp(temp_vec,0);
		point_d_to_mp(temp_vec, EG->last_approx_d);
		evalProg_mp(f, e.parVals, e.parDer, e.Jv, e.Jp, temp_vec, EG->PD_mp.time, BED->SLP);
		clear_vec_mp(temp_vec);
	}
	else
	{
		evalProg_mp(f, e.parVals, e.parDer, e.Jv, e.Jp, EG->last_approx_mp, EG->PD_mp.time, BED->SLP);
	}
	
	// compare the function values
	int isSoln = 1;
	for (ii = 0; ii < BED->SLP->numFuncs && isSoln; ii++)
	{
		mpf_abs_mp(n1, &e.funcVals->coord[ii]);
		mpf_abs_mp(n2, &f->coord[ii]);
		
		if ( (mpf_cmp(zero_thresh, n1) <= 0) &&  (mpf_cmp(n1, n2) <= 0) )
		{ // compare ratio
			mpf_mul(n2, max_rat, n2);
			if (mpf_cmp(n1, n2) > 0){
				isSoln = 0;
				printf("labeled as non_soln due to max_rat (mp) 1\n");
			}
		}
		else if ( (mpf_cmp(zero_thresh, n2) <= 0) &&  (mpf_cmp(n2, n1) <= 0) )
		{ // compare ratio
			mpf_mul(n1, max_rat, n1);
			if (mpf_cmp(n2, n1) > 0){
				isSoln = 0;
				printf("labeled as non_soln due to max_rat (mp) 2\n");
			}
		}
	}
	
	
	
	if (!isSoln) {
		
		print_point_to_screen_matlab(e.funcVals,"terminal_func_vals");
		printf("tol was %le\nmax_rat was ",tol);
		mpf_out_str(NULL,10,15,max_rat);
		std::cout << "\n";
	}
	
	
	
	mpf_clear(n1); mpf_clear(n2); mpf_clear(zero_thresh); mpf_clear(max_rat);
	
	
	clear_eval_struct_mp(e);
	clear_vec_mp(f);
	
	BED->SLP_memory.set_globals_null();
	return isSoln;
	
}
Example #25
0
int UbermasterProcess::main_loop()
{
	
	boost::timer::auto_cpu_timer t;
	
	
	program_options.splash_screen();
	
	
	//parse the options
	program_options.startup(); // tests for existence of necessary files, etc.
	
	//if desired, display the options
	if (program_options.verbose_level()>=3)
		program_options.display_current_options();
	
	
	
	
	parse_preproc_data("preproc_data", &solve_options.PPD);
	
	
	
	int num_vars = get_num_vars_PPD(solve_options.PPD);
	
	
	NumericalIrreducibleDecomposition witness_data;
	witness_data.populate(&solve_options.T);
	

	WitnessSet W = witness_data.choose(program_options);
	
	if (W.num_points()==0) {
		std::cout << "no witness points, cannot decompose anything..." << std::endl;
		return 1;
	}
	
	
	
	
	W.get_variable_names(num_vars);
	W.set_input_filename(program_options.input_filename());
	
	
		
	
	if (program_options.verbose_level()>=1) {
		W.print_to_screen();
	}
	
	
	
	
	
	
	VertexSet V(num_vars);
	
	V.set_tracker_config(&solve_options.T);
	
	V.set_same_point_tolerance(1e1*solve_options.T.real_threshold);

	
	vec_mp *pi = (vec_mp *) br_malloc(W.dimension()*sizeof(vec_mp ));
	for (int ii=0; ii<W.dimension(); ii++) {
		init_vec_mp2(pi[ii],W.num_variables(), solve_options.T.AMP_max_prec);
		pi[ii]->size = W.num_variables();
	}
	get_projection(pi, program_options, W.num_variables(), W.dimension());
	
    for (int ii=0; ii<W.dimension(); ii++) {
        V.add_projection(pi[ii]);
    }
    
	
	if (program_options.primary_mode()==BERTINIREAL) {
		bertini_real(W,pi,V);
		
	}
	else if(program_options.primary_mode()==CRIT)
	{
		critreal(W,pi,V);
	}
	
	
	

	
	
	for (int ii=0; ii<W.dimension(); ii++)
		clear_vec_mp(pi[ii]);
	free(pi);
	
	
	// dismiss the workers
	int sendme = TERMINATE;
	MPI_Bcast(&sendme, 1, MPI_INT, 0, MPI_COMM_WORLD);
	return SUCCESSFUL;
}
Example #26
0
int compute_crit_nullspace_right(SolverOutput & solve_out, // the returned value
						   const WitnessSet & W,
						   std::shared_ptr<SystemRandomizer> randomizer,
						   vec_mp *pi, // an array of projections, the number of which is the target dimensions
						   int ambient_dim,
						   BertiniRealConfig & program_options,
						   SolverConfiguration & solve_options,
						   NullspaceConfiguration *ns_config)
{
	//many of the 1's here should be replaced by the number of patch equations, or the number of variable_groups
	
	
	
	
	
	// get the max degree of the derivative functions.  this is unique to the left nullspace formulation, as the functions become mixed together
	int max_degree;
	
	
	nullspace_config_setup_right(ns_config,
						   pi,
						   ambient_dim,
						   &max_degree,
						   randomizer,
						   W,
						   solve_options);
	
	
	
	
	
	if (max_degree==0) {
		// this will probably need tweaking when the dimension is higher than 1.  but who really is going to decompose a linear surface?
		solve_out.copy_patches(W);
		ns_concluding_modifications(solve_out, W, ns_config);
		
		
		std::cout << "the highest degree of any derivative equation is 0.  Returning empty SolverOutput." << std::endl;
		//then there cannot possibly be any critical points, with respect to ANY projection.  simply return an empty but complete set.
		
		return 0;
	}
	
	
	
	
	
	
	//
	///
	/////        end setup
	////////
	//////////////
	///////////////////////////
	
	
	
	
	
	
	int offset;
	WitnessSet Wtemp, Wtemp2;
	
	
	//  2.  Do a bunch of homotopies in $x$, each set of which will be followed by a single linear solve in $v$.
	if (program_options.verbose_level()>=3) {
		std::cout << "building up linprod start system for left nullspace" << std::endl;
	}
	
	// setup for the multilin moves
	//  these are for feeding into the multilin solver -- and that's it.  the majority will be overridden in the while loop as the start x linears
	vec_mp *multilin_linears = (vec_mp *) br_malloc(W.num_linears()*sizeof(vec_mp)); // target dim is the number of linears in the input witness set
	for (unsigned int ii=0; ii<W.num_linears(); ii++) {
		init_vec_mp2(multilin_linears[ii],W.num_variables(), solve_options.T.AMP_max_prec);
		multilin_linears[ii]->size = W.num_variables();
		vec_cp_mp(multilin_linears[ii], W.linear(ii));
	}
	
	MultilinConfiguration ml_config(solve_options,randomizer);
	
	
	
	// this is for performing the matrix inversion to get ahold of the $v$ values corresponding to $x$
	mat_mp tempmat;  init_mat_mp2(tempmat, ns_config->num_v_vars, ns_config->num_v_vars,solve_options.T.AMP_max_prec);
	tempmat->rows = tempmat->cols = ns_config->num_v_vars;
	
	offset = ns_config->num_v_vars-1;
	for (int jj=0; jj<ns_config->num_v_vars; jj++)
		set_mp(&tempmat->entry[offset][jj], &ns_config->v_patch->coord[jj]);
	
	
	// for holding the result of the matrix inversion
	vec_mp result; init_vec_mp2(result,ns_config->num_v_vars,solve_options.T.AMP_max_prec);  result->size = ns_config->num_v_vars;
	
	// use this for the matrix inversion
	vec_mp invert_wrt_me;
	init_vec_mp2(invert_wrt_me,ns_config->num_v_vars,solve_options.T.AMP_max_prec); invert_wrt_me->size = ns_config->num_v_vars;
	for (int ii=0; ii<ns_config->num_v_vars-1; ii++)
		set_zero_mp(&invert_wrt_me->coord[ii]); // set zero
	
	set_one_mp(&invert_wrt_me->coord[ns_config->num_v_vars-1]); // the last entry is set to 1 for the patch equation
	
	
	
	
	
	
	vec_mp temppoint;  init_vec_mp2(temppoint, ns_config->num_natural_vars +ns_config->num_synth_vars + ns_config->num_v_vars,solve_options.T.AMP_max_prec);
	temppoint->size = ns_config->num_natural_vars + ns_config->num_synth_vars + ns_config->num_v_vars;
	
	
	WitnessSet W_step_one;
	W_step_one.set_num_variables(W.num_variables());
	W_step_one.set_num_natural_variables(W.num_natural_variables());
	W_step_one.copy_patches(W);
	W_step_one.copy_names(W);
	
	
	WitnessSet W_linprod;
	W_linprod.set_num_variables(ns_config->num_natural_vars + ns_config->num_v_vars + ns_config->num_synth_vars);
	W_linprod.set_num_natural_variables(W.num_natural_variables());
	
	
	if (program_options.quick_run()<=1)
		solve_options.robust = true;
	else
		solve_options.robust = false;
	
	
	
	
	
	for (int ii=0; ii<randomizer->num_rand_funcs(); ii++) {
		
		int differentiated_degree = randomizer->randomized_degree(ii)-1; // the -1 is for differentiating.  this could be 0.
		
		if (differentiated_degree==0) {
			continue;
		}
		else{
			for (int jj=0; jj<differentiated_degree; jj++) {
				
				//copy in the linear for the solve
				vec_cp_mp(multilin_linears[0], ns_config->starting_linears[ii][jj]);
				
				// the remainder of the linears are left alone (stay stationary).
				
				if (program_options.verbose_level()>=6) {
					std::cout << "moving FROM this set:\n";
					for (unsigned int ii=0; ii<W.num_linears(); ii++) {
						print_point_to_screen_matlab(W.linear(ii),"L");
					}
					std::cout << "\nTO this set:\n";
					for (unsigned int ii=0; ii<W.num_linears(); ii++) {
						print_point_to_screen_matlab(multilin_linears[ii],"ELL");
					}
				}
				
				
				
				// actually solve WRT the linears
				
				
				SolverOutput fillme;
				multilin_solver_master_entry_point(W,         // WitnessSet
												   fillme, // the new data is put here!
												   multilin_linears,
												   ml_config,
												   solve_options);
				
				WitnessSet Wtemp;
				fillme.get_noninfinite_w_mult_full(Wtemp); // should be ordered
				
				W_step_one.merge(Wtemp, &solve_options.T);
				
				Wtemp.reset();
			}
			
			
			
			int curr_index = 0;
			for (int kk=0; kk<ns_config->num_v_vars; kk++) { // subtract one from upper limit because of the patch equation
				if (kk!=ii) {
					
					for (int mm=0; mm<ns_config->num_v_vars; mm++){
						set_mp(&tempmat->entry[curr_index][mm], &ns_config->v_linears[kk]->coord[mm]);}
					
					curr_index++;
				}
			}
			
			
			// invert the matrix for the v variables.
			matrixSolve_mp(result, tempmat,  invert_wrt_me);
			
			//set the bottom part of the temppoint, which will be a startpoint for the nullspace call later.
			offset = ns_config->num_natural_vars+ns_config->num_synth_vars;
			for (int mm=0; mm<ns_config->num_v_vars; mm++)
				set_mp(&temppoint->coord[mm+offset], &result->coord[mm]);
			
			
			//set the top part, x, of the start point, and copy it in.
			for (unsigned int kk=0; kk<W_step_one.num_points(); kk++) {
				for (int mm=0; mm<ns_config->num_natural_vars+ns_config->num_synth_vars; mm++) {
					set_mp(&temppoint->coord[mm], & W_step_one.point(kk)->coord[mm]);
				}
				W_linprod.add_point(temppoint);
			}
			
			
			
			W_step_one.reset();
			W_step_one.set_num_variables(W.num_variables());
			W_step_one.set_num_natural_variables(W.num_natural_variables());
			W_step_one.copy_patches(W);  // necessary?
			W_step_one.copy_names(W); // necessary?
		}
		
		
		
		
		
		
		
	}
	
	
	for (int ii=0; ii<1; ii++)
		clear_vec_mp(multilin_linears[ii]);
	free(multilin_linears);
	
	clear_vec_mp(temppoint);
	
	
	
	int num_before = W_linprod.num_points();
	W_linprod.sort_for_unique(&solve_options.T);
	if (num_before - W_linprod.num_points()>0) {
		std::cout << "there were non-unique start points" << std::endl;
		mypause();
	}
	
	
	
	W_linprod.set_num_natural_variables(ns_config->num_v_vars+ns_config->num_synth_vars);
	W_linprod.copy_patches(W);
	W_linprod.copy_names(W);
	
	//set some solver options
	
	if (program_options.quick_run()<=0)
		solve_options.robust = true;
	else
		solve_options.robust = false;
	
	
	
	solve_options.use_midpoint_checker = 0;
	
	
	
	if (program_options.verbose_level()>=6)
		ns_config->print();
	
	
	
	if (program_options.verbose_level()>=3) {
		std::cout << "running nullspace right method" << std::endl;
	}
	
	
	
	
	nullspacejac_solver_master_entry_point(solve_options.T.MPType,
										   W_linprod, // carries with it the start points, but not the linears.
										   solve_out,   // the created data goes in here.
										   ns_config,
										   solve_options);
	
	
	ns_concluding_modifications(solve_out, W, ns_config);
	
	
	clear_mat_mp(tempmat);
	clear_vec_mp(invert_wrt_me);
	clear_vec_mp(result);
	
	
	return SUCCESSFUL;
}