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; }
void loadPosition() { FILE *file; int32_t base = 10; printf("Lade Position\n"); file = fopen("minRe.val", "r"); if (file != NULL) { mpf_inp_str(mandelRange.minRe, file, base); } if (file != NULL) { file = fopen("maxRe.val", "r"); mpf_inp_str(mandelRange.maxRe, file, base); } fclose(file); if (file != NULL) { file = fopen("minIm.val", "r"); mpf_inp_str(mandelRange.minIm,file, base); } fclose(file); file = fopen("iter.val", "rb"); if (file != NULL) { fread(&maxIterations, sizeof(maxIterations), 1, file); } fclose(file); file = fopen("bits.val", "rb"); if (file != NULL) { fread(&gmpBit, sizeof(gmpBit), 1, file); setBits(gmpBit); } fclose(file); printf("Position geladen\n"); }
ats_void_type atslib_mpf_inp_str_exn ( ats_mpf_ptr_type x , ats_ptr_type file , ats_int_type base ) { size_t n = mpf_inp_str(x, (FILE*)file, base) ; if (n == 0) { ats_exit_errmsg (1, "exit(ATS): [mpf_inp_str] failed.\n") ; } // end of [if] return ; } // end of [atslib_mpf_inp_str_exn]
void readpi(mpf_t pi) { char *filename; FILE *file; if ( (filename = (char *) malloc(50*sizeof(char))) == NULL ) perror("readpi"); sprintf(filename, "factoriales/pi.dat"); file = fopen(filename, "r"); mpf_init(pi); mpf_inp_str(pi, file, 10); fclose(file); }
void load_floating_points(int *numPoints, complex_vector **points, int numVars, char *PtsFile) /***************************************************************\ * USAGE: load points from PtsFile * \***************************************************************/ { int i, j, rV, base = 10; FILE *IN = fopen(PtsFile, "r"); // error checking - file must exist if (IN == NULL) { printf("\nERROR: '%s' does not exist!\n", PtsFile); errExit(ERROR_FILE_NOT_EXIST); } // read in the number of points rV = fscanf(IN, "%d", numPoints); // error checking if (rV != 1) { printf("\nERROR: Unable to read the number of points stored in '%s'.\n", PtsFile); errExit(ERROR_FILE_NOT_EXIST); } else if (*numPoints <= 0) { printf("ERROR: The number of points in '%s' must be positive!\n", PtsFile); errExit(ERROR_CONFIGURATION); } // allocate points *points = (complex_vector *)errMalloc((*numPoints) * sizeof(complex_vector)); // read in the points for (i = 0; i < *numPoints; i++) { // setup points[i] initialize_vector((*points)[i], numVars); for (j = 0; j < numVars; j++) { // setup real part rV = mpf_inp_str((*points)[i]->coord[j]->re, IN, base); // error checking if (rV == 0) { printf("\nERROR: Unable to read in %d floating point vectors from '%s'.\n", *numPoints, PtsFile); errExit(ERROR_FILE_NOT_EXIST); } // setup imag part rV = mpf_inp_str((*points)[i]->coord[j]->im, IN, base); // error checking if (rV == 0) { printf("\nERROR: Unable to read in %d floating point vectors from '%s'.\n", *numPoints, PtsFile); errExit(ERROR_FILE_NOT_EXIST); } } } // close file fclose(IN); return; }
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; }