Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 0 additions & 126 deletions src/msolve/iofiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,129 +1149,3 @@ static inline void display_gens(FILE *fh, data_gens_ff_t *gens){
display_gens_mpz(fh, gens);
}
}

static inline void get_poly_bin(FILE *file, mpz_upoly_t pol){
if(!fscanf(file, "%d\n", &pol->alloc)){
fprintf(ERRSTREAM, "Issue when reading binary file (alloc = %d)\n", pol->alloc);
exit(1);
}

pol->coeffs = malloc(sizeof(mpz_t) * pol->alloc);
pol->length = pol->alloc;

for(int32_t i = 0; i < pol->length; i++){
mpz_init(pol->coeffs[i]);
if(!mpz_inp_raw(pol->coeffs[i], file)){
fprintf(ERRSTREAM, "An error occurred when reading file (i=%d)\n", i);
exit(1);
}
}
}

static inline void get_poly(FILE *file, mpz_upoly_t pol){
if(!fscanf(file, "%d\n", &pol->alloc)){
fprintf(ERRSTREAM, "Issue when reading binary file (alloc = %d)\n", pol->alloc);
exit(1);
}

pol->coeffs = malloc(sizeof(mpz_t) * pol->alloc);
pol->length = pol->alloc;
for(int32_t i = 0; i < pol->length; i++){
mpz_init(pol->coeffs[i]);
if(!mpz_inp_str(pol->coeffs[i], file, 10)){
fprintf(ERRSTREAM, "An error occurred when reading file (i=%d)\n", i);
exit(1);
}
}
}


static inline void get_single_param_from_file_bin(FILE *file, mpz_param_t param){
get_poly_bin(file, param->elim);

get_poly_bin(file, param->denom);

if(!fscanf(file, "%d\n", &param->nvars)){
fprintf(ERRSTREAM, "Issue when reading binary file (nvars)\n");
exit(1);
}

param->nsols = param->elim->length - 1;
param->dquot = param->elim->length - 1;

param->coords = malloc(sizeof(mpz_upoly_t) * param->nvars);
param->cfs = malloc(sizeof(mpz_t) * param->nvars);

for(int32_t i = 0; i < param->nvars - 1; i++){
get_poly_bin(file, param->coords[i]);

mpz_init(param->cfs[i]);
if(!mpz_inp_raw(param->cfs[i], file)){
fprintf(ERRSTREAM, "An error occurred when reading file (lcm coord i=%d)\n", i);
exit(1);
}

}

}

static inline void get_single_param_from_file(FILE *file, mpz_param_t param){
get_poly(file, param->elim);

get_poly(file, param->denom);
if(!fscanf(file, "%d\n", &param->nvars)){
fprintf(ERRSTREAM, "Issue when reading binary file (nvars)\n");
exit(1);
}

param->nsols = param->elim->length - 1;
param->dquot = param->elim->length - 1;

param->coords = malloc(sizeof(mpz_upoly_t) * param->nvars);
param->cfs = malloc(sizeof(mpz_t) * param->nvars);

for(int32_t i = 0; i < param->nvars - 1; i++){
get_poly(file, param->coords[i]);

mpz_init(param->cfs[i]);

if(!mpz_inp_str(param->cfs[i], file, 10)){
fprintf(ERRSTREAM, "An error occurred when reading file (i=%d)\n", i);
exit(1);
}

}

}

static inline void get_params_from_file_bin(char *fn, mpz_param_array_t lparam){
FILE *file = fopen(fn,"r");
int32_t nb = 0;
if(!fscanf(file, "%d\n", &nb)){
fprintf(ERRSTREAM, "Issue when reading binary file (nb = %d)\n", nb);
exit(1);
}
lparam->nb = nb;

lparam->params = malloc(sizeof(mpz_param_t) * lparam->nb);
for(int32_t i = 0; i < lparam->nb; i++){
get_single_param_from_file_bin(file, lparam->params[i]);
}
fclose(file);
}

static inline void get_params_from_file(char *fn, mpz_param_array_t lparam){
FILE *file = fopen(fn,"r");
int32_t nb = 0;
if(!fscanf(file, "%d\n", &nb)){
fprintf(ERRSTREAM, "Issue when reading binary file (nb = %d)\n", nb);
exit(1);
}
lparam->nb = nb;

lparam->params = malloc(sizeof(mpz_param_t) * lparam->nb);
for(int32_t i = 0; i < lparam->nb; i++){
get_single_param_from_file(file, lparam->params[i]);
}
fclose(file);
}
56 changes: 5 additions & 51 deletions src/msolve/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ static inline void display_help(char *str){


fprintf(OUTSTREAM, "\nAdvanced options:\n\n");
display_option_help('F', "", "FILE", "File name encoding parametrizations in binary format.\n\n");
display_option_help('g', "groebner-basis", "GB", "Prints reduced Groebner bases of input system for\n");
display_option_help_noopt("first prime characteristic w.r.t. grevlex ordering.\n");
display_option_help_noopt("One element per line is printed, commata separated.\n");
Expand Down Expand Up @@ -136,10 +135,6 @@ static inline void display_help(char *str){
display_option_help_noopt("between 1 and #variables-1, and gives the number of\n");
display_option_help_noopt("eliminated variables. The basis with the first block of\n");
display_option_help_noopt("ELIM variables eliminated is then computed.\n");
display_option_help('I', "isolate", "ISOL", "Isolates the real roots (provided some univariate data)\n");
display_option_help_noopt("without re-computing a Gr枚bner basis\n");
display_option_help_noopt("0 - no (default).\n");
display_option_help_noopt("1 - yes.\n");
display_option_help('l', "linear-algebra", "LIN", "Linear algebra variant to be applied:\n");
display_option_help_noopt(" 1 - exact sparse / dense\n");
display_option_help_noopt(" 2 - exact sparse (default)\n");
Expand Down Expand Up @@ -176,8 +171,6 @@ static inline void display_help(char *str){
display_option_help('r', "reduce-gb", "RED", "Reduce Groebner basis.\n");
display_option_help_noopt("0 - no.\n");
display_option_help_noopt("1 - yes (default).\n");
/* display_option_help('R', "", "REF", "Refinement fo real roots.\n"); */
/* display_option_help_noopt("(not implemented yet).\n"); */
display_option_help('s', "", "HTS", "Initial hash table size given\n");
display_option_help_noopt("as power of two.\n");
display_option_help_noopt("17 (default).\n");
Expand Down Expand Up @@ -217,19 +210,15 @@ static void getoptions(
int32_t *lift_matrix,
int32_t *get_param,
int32_t *precision,
int32_t *refine,
int32_t *isolate,
int32_t *generate_pbm_files,
int64_t *seed,
int32_t *info_level,
files_gb *files){
int opt, errflag = 0, fflag = 1;
char *filename = NULL;
char *bin_filename = NULL;
char *out_fname = NULL;
char *bin_out_fname = NULL;
opterr = 1;
char short_options[] = "c:Cd:e:f:F:g:hiI:l:L:m:M:n:N:o:O:p:P:q:r:R:s:St:u:v:V";
char short_options[] = "c:Cd:e:f:g:hil:L:m:M:n:N:o:p:P:q:r:s:St:u:v:V";

/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1.
Expand All @@ -245,7 +234,6 @@ static void getoptions(
{"file", required_argument, NULL, 'f'},
{"groebner-basis", required_argument, NULL, 'g'},
{"help", no_argument, NULL, 'h'},
{"isolate", required_argument, NULL, 'I'},
{"linear-algebra", required_argument, NULL, 'l'},
{"lifting-mulmat", required_argument, NULL, 'L'},
{"normal-form", required_argument, NULL, 'n'},
Expand Down Expand Up @@ -309,15 +297,9 @@ static void getoptions(
*use_signatures = 0;
}
break;
case 'R':
*refine = 1;
break;
case 'i':
*is_gb = 1;
break;
case 'I':
*isolate = strtol(optarg, NULL, 10);
break;
case 's':
*initial_hts = strtol(optarg, NULL, 10);
break;
Expand Down Expand Up @@ -349,16 +331,9 @@ static void getoptions(
fflag = 0;
filename = optarg;
break;
case 'F':
fflag = 0;
bin_filename = optarg;
break;
case 'o':
out_fname = optarg;
break;
case 'O':
bin_out_fname = optarg;
break;
case 'P':
*get_param = strtol(optarg, NULL, 10);
if (*get_param <= 0) {
Expand Down Expand Up @@ -430,9 +405,7 @@ static void getoptions(
exit(1);
}
files->in_file = filename;
files->bin_file = bin_filename;
files->out_file = out_fname;
files->bin_out_file = bin_out_fname;
}


Expand Down Expand Up @@ -467,22 +440,18 @@ int main(int argc, char **argv){
int32_t lift_matrix = 0;
int32_t get_param = 0;
int32_t precision = 64;
int32_t refine = 0; /* not used at the moment */
int32_t isolate = 0; /* not used at the moment */
int64_t seed = -1;

files_gb *files = malloc(sizeof(files_gb));
if(files == NULL) exit(1);
files->in_file = NULL;
files->bin_file = NULL;
files->out_file = NULL;
files->bin_out_file = NULL;
getoptions(argc, argv, &initial_hts, &nr_threads, &max_pairs,
&elim_block_len, &la_option, &use_signatures, &update_ht,
&reduce_gb, &print_gb, &truncate_lifting, &genericity_handling,
&unstable_staircase, &saturate, &colon,
&normal_form, &normal_form_matrix, &is_gb, &lift_matrix, &get_param,
&precision, &refine, &isolate, &generate_pbm,
&precision, &generate_pbm,
&seed, &info_level, files);

/* srand initialization */
Expand All @@ -498,27 +467,12 @@ int main(int argc, char **argv){
fprintf (VERBSTREAM,"is %u\n",true_seed);
}

FILE *fh = NULL;
FILE *bfh = NULL;
if (files->in_file) {
fh = fopen(files->in_file, "r");
}
if (files->bin_file) {
bfh = fopen(files->bin_file, "r");
}

if (fh == NULL && bfh == NULL) {
FILE *fh = fopen(files->in_file, "r");
if (fh == NULL) {
fprintf(ERRSTREAM, "Input file not found.\n");
exit(1);
}
if(fh!=NULL){
fclose(fh);
}
if(bfh != NULL){
fclose(bfh);
}
fh = NULL;
bfh = NULL;
fclose(fh);

/* clear out_file if given */
if(files->out_file != NULL){
Expand Down
2 changes: 0 additions & 2 deletions src/msolve/msolve-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ typedef real_point_struct real_point_t[1];

typedef struct{
char *in_file;
char *bin_file;
char *out_file;
char *bin_out_file;
char *verb_file;
} files_gb;

Expand Down
Loading