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; }
/** \brief copies all linears from another LinearHolder. \param other the LinearHolder from which to copy all the linears. */ void copy_linears(const LinearHolder & other) { for (unsigned int ii=0; ii<other.num_linears_; ii++) add_linear(other.L_mp_[ii]); }
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; }