Skip to content

Commit 4ccf1ea

Browse files
authored
Merge pull request #270 from jerebertho/fix_f4sat_printf
Fix f4sat printf
2 parents 1f2d3a1 + 675237a commit 4ccf1ea

8 files changed

Lines changed: 55 additions & 47 deletions

File tree

src/msolve/hilbert.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ build_matrixn_colon(int32_t *lmb, long dquot, int32_t bld,
17701770
int32_t err = 0;
17711771
tbr = core_nf(tbr, st, mul, bs, &err);
17721772
if (err) {
1773-
printf("Problem with normalform, stopped computation.\n");
1773+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
17741774
exit(1);
17751775
}
17761776
/* printf ("reductions\n"); */
@@ -1953,7 +1953,7 @@ build_matrixn_colon(int32_t *lmb, long dquot, int32_t bld,
19531953
/* st, gens->vnames, 0); */
19541954
success = core_nf(&tbr, &bht, &st, mul, bs);
19551955
if (!success) {
1956-
printf("Problem with normalform, stopped computation.\n");
1956+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
19571957
exit(1);
19581958
}
19591959
/* printf ("reduction\n"); */
@@ -2002,7 +2002,7 @@ build_matrixn_colon(int32_t *lmb, long dquot, int32_t bld,
20022002
/* st, gens->vnames, 0); */
20032003
int success = core_nf(&tbr, &bht, &st, mul, bs);
20042004
if (!success) {
2005-
printf("Problem with normalform, stopped computation.\n");
2005+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
20062006
exit(1);
20072007
}
20082008
/* printf ("reductions\n"); */
@@ -2217,7 +2217,7 @@ build_matrixn_colon_no_zero(int32_t *lmb, long dquot, int32_t bld,
22172217
int32_t err = 0;
22182218
tbr = core_nf(tbr, st, mul, bs, &err);
22192219
if (err) {
2220-
printf("Problem with normalform, stopped computation.\n");
2220+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
22212221
exit(1);
22222222
}
22232223
/* printf ("reductions\n"); */
@@ -3076,7 +3076,7 @@ static inline void build_matrixn_unstable_from_bs_trace_application(sp_matfglm_t
30763076
int32_t err = 0;
30773077
tbr = core_nf(tbr, md, mul, bs, &err);
30783078
if (err) {
3079-
printf("Problem with normalform, stopped computation.\n");
3079+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
30803080
exit(1);
30813081
}
30823082
free(mul);

src/msolve/iofiles.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static int32_t get_nvars(const char *fn)
380380
char * line = NULL;
381381
char * line2 = NULL;
382382
size_t len;
383-
nvars_t nvars = -1;
383+
nvars_t nvars = -1;
384384

385385
/* number of variables is read from first line, it is 1 + (number of commata) */
386386
if (getline(&line, &len, fh) != -1)
@@ -523,7 +523,7 @@ static void get_variables(FILE *fh, char * line, int max_line_size,
523523
if (fgets(line, max_line_size, fh) != NULL) {
524524
tmp = line;
525525
} else {
526-
printf("Bad file format (variable names).\n");
526+
fprintf(stderr,"Bad file format (variable names).\n");
527527
/* free(vnames);
528528
* free(line); */
529529
fclose(fh);
@@ -612,11 +612,11 @@ static void remove_trailing_delim(char *line, ssize_t *len, char delim) {
612612
}
613613
}
614614

615-
static void get_nterms_and_all_nterms(FILE *fh,
615+
static void get_nterms_and_all_nterms(FILE *fh,
616616
int max_line_size, data_gens_ff_t *gens,
617617
int32_t *nr_gens, nelts_t *nterms, nelts_t *all_nterms){
618618

619-
char *line = NULL;
619+
char *line = NULL;
620620
size_t size;
621621
ssize_t len;
622622
for (int32_t i = 0; i < *nr_gens; i++) {
@@ -873,7 +873,7 @@ static void get_coeffs_and_exponents_ff32(FILE *fh, nelts_t all_nterms,
873873
size_t size;
874874
ssize_t len;
875875

876-
char *line = NULL;
876+
char *line = NULL;
877877
if(getline(&line, &size, fh) !=-1){
878878
}
879879
if(getline(&line, &size, fh) !=-1){
@@ -909,7 +909,7 @@ static void get_coeffs_and_exponents_mpz(FILE *fh, nelts_t all_nterms,
909909
size_t size;
910910
ssize_t len;
911911

912-
char *line = NULL;
912+
char *line = NULL;
913913
if(getline(&line, &size, fh) !=-1){
914914
}
915915
if(getline(&line, &size, fh) !=-1){
@@ -978,11 +978,11 @@ static inline void get_data_from_file(char *fn, int32_t *nr_vars,
978978
int32_t *nr_gens, data_gens_ff_t *gens){
979979
*nr_vars = get_nvars(fn);
980980
if (*nr_vars == -1)
981-
printf("Bad file format (first line).\n");
981+
fprintf(stderr,"Bad file format (first line).\n");
982982

983983
*nr_gens = get_ngenerators(fn);
984984
if (*nr_gens == -1)
985-
printf("Bad file format (generators).\n");
985+
fprintf(stderr,"Bad file format (generators).\n");
986986

987987
const int max_line_size = 1073741824;
988988
char *line = (char *)malloc((nelts_t)max_line_size * sizeof(char));

src/msolve/lifting-gb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ static int32_t gb_modular_trace_learning(gb_modpoly_t modgbs,
722722
st->f4_qq_round = 1;
723723
bs = core_gba(bs_qq, st, &err, fc);
724724
if (err) {
725-
printf("Problem with F4, stopped computation.\n");
725+
fprintf(stderr,"Problem with F4, stopped computation.\n");
726726
exit(1);
727727
}
728728

@@ -1773,7 +1773,7 @@ gb_modpoly_t *groebner_qq(
17731773
return NULL;
17741774
}
17751775
if (success == 0) {
1776-
printf("Bad input data, stopped computation.\n");
1776+
fprintf(stderr,"Bad input data, stopped computation.\n");
17771777
exit(1);
17781778
}
17791779

@@ -1783,7 +1783,7 @@ gb_modpoly_t *groebner_qq(
17831783
gb_modpoly_t *modgbsp = malloc(sizeof(gb_modpoly_t));
17841784
modgbsp = core_groebner_qq(modgbsp, bs, msd, md, &err, field_char, print_gb);
17851785
if (err) {
1786-
printf("Problem with groebner_qq, stopped computation (%d).\n", err);
1786+
fprintf(stderr,"Problem with groebner_qq, stopped computation (%d).\n", err);
17871787
exit(1);
17881788
}
17891789

@@ -1948,7 +1948,7 @@ int64_t export_groebner_qq(
19481948
int err = 0;
19491949

19501950
gb_modpoly_t *modgbsp = malloc(sizeof(gb_modpoly_t));
1951-
modgbsp =
1951+
modgbsp =
19521952
core_groebner_qq(modgbsp, bs, msd, md, &err, field_char,
19531953
2/* if set to 1, only the LM of the Gbs are correct */);
19541954
if (err) {

src/msolve/msolve.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,14 +3998,14 @@ int core_msolve(
39983998
st->gfc);
39993999
}
40004000
if (!success) {
4001-
printf("Bad input data, stopped computation.\n");
4001+
fprintf(stderr,"Bad input data, stopped computation.\n");
40024002
exit(1);
40034003
}
40044004
/* compute a gb for initial generators */
40054005
success = core_sba_schreyer(&bs, &bht, &st);
40064006

40074007
if (!success) {
4008-
printf("Problem with sba, stopped computation.\n");
4008+
fprintf(stderr,"Problem with sba, stopped computation.\n");
40094009
exit(1);
40104010
}
40114011
int64_t nb = export_results_from_gba(bld, blen, bexp,
@@ -4068,7 +4068,7 @@ int core_msolve(
40684068
0 /*truncate_lifting */, info_level);
40694069

40704070
if (!success) {
4071-
printf("Bad input data, stopped computation.\n");
4071+
fprintf(stderr,"Bad input data, stopped computation.\n");
40724072
exit(1);
40734073
}
40744074

@@ -4094,7 +4094,7 @@ int core_msolve(
40944094
success = core_f4sat(bs, sat, st, &error);
40954095

40964096
if (!success) {
4097-
printf("Problem with f4sat, stopped computation.\n");
4097+
fprintf(stderr,"Problem with f4sat, stopped computation.\n");
40984098
exit(1);
40994099
}
41004100
int64_t nb = export_results_from_gba(bld, blen, bexp,
@@ -4166,7 +4166,7 @@ int core_msolve(
41664166
st->gfc);
41674167
}
41684168
if (!success) {
4169-
printf("Bad input data, stopped computation.\n");
4169+
fprintf(stderr,"Bad input data, stopped computation.\n");
41704170
exit(1);
41714171
}
41724172

@@ -4192,7 +4192,7 @@ int core_msolve(
41924192
bs = core_gba(bs, st, &err, gens->field_char);
41934193

41944194
if (err) {
4195-
printf("Problem with F4, stopped computation.\n");
4195+
fprintf(stderr,"Problem with F4, stopped computation.\n");
41964196
exit(1);
41974197
}
41984198
}
@@ -4226,7 +4226,7 @@ int core_msolve(
42264226
tbr = core_nf(tbr, st, mul, bs, &err);
42274227

42284228
if (err) {
4229-
printf("Problem with normalform, stopped computation.\n");
4229+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
42304230
exit(1);
42314231
}
42324232
/* print reduced element in tbr, last one is the input element */
@@ -4546,7 +4546,7 @@ int core_msolve(
45464546

45474547
st->gfc = gens->field_char;
45484548
if (!success) {
4549-
printf("Bad input data, stopped computation.\n");
4549+
fprintf(stderr,"Bad input data, stopped computation.\n");
45504550
exit(1);
45514551
}
45524552

@@ -4585,7 +4585,7 @@ int core_msolve(
45854585
tbr = core_nf(tbr, st, mul, bs, &err);
45864586

45874587
if (err) {
4588-
printf("Problem with normalform, stopped computation.\n");
4588+
fprintf(stderr,"Problem with normalform, stopped computation.\n");
45894589
exit(1);
45904590
}
45914591
/* print all reduced elements in tbr, first normal_form ones
@@ -4959,7 +4959,9 @@ int core_msolve(
49594959
sat_qq->lmps[k] = k; /* fix input element in tbr */
49604960
}
49614961

4962-
printf("LEARNING PHASE -- PART 1\n");
4962+
if (info_level){
4963+
fprintf(stdout,"LEARNING PHASE -- PART 1\n");
4964+
}
49634965
f4sat_trace_learning_phase_1(
49644966
trace,
49654967
tht,
@@ -4988,7 +4990,9 @@ int core_msolve(
49884990

49894991
lp->p[0] = prime;
49904992

4991-
printf("LEARNING PHASE -- PART 2\n");
4993+
if (info_level){
4994+
fprintf(stdout,"LEARNING PHASE -- PART 2\n");
4995+
}
49924996
f4sat_trace_learning_phase_2(
49934997
trace,
49944998
tht,

src/neogb/f4.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void free_f4_julia_result_data(
8080
int64_t len = 0;
8181
for (i = 0; i < ngens; ++i) {
8282
len += (int64_t)lens[i];
83-
}
83+
}
8484

8585
(*freep)(lens);
8686
lens = NULL;
@@ -407,7 +407,7 @@ static int32_t initialize_f4(
407407
*lbsp = bs;
408408
*matp = mat;
409409
*lmdp = md;
410-
410+
411411
return done;
412412
}
413413

@@ -690,7 +690,7 @@ bs_t *core_f4(
690690
/* let's start the f4 rounds, we are done when no more spairs
691691
are left in the pairset or if we found a constant in the basis. */
692692
print_round_information_header(stdout, md);
693-
693+
694694
/* reset error */
695695
*errp = 0;
696696
while (!done) {
@@ -815,15 +815,15 @@ int64_t export_f4(
815815
return 1;
816816
}
817817
if (success == 0) {
818-
printf("Bad input data, stopped computation.\n");
818+
fprintf(stderr,"Bad input data, stopped computation.\n");
819819
exit(1);
820820
}
821821

822822
int err = 0;
823823
bs = core_f4(bs, md, &err, field_char);
824824

825825
if (err) {
826-
printf("Problem with F4, stopped computation.\n");
826+
fprintf(stderr,"Problem with F4, stopped computation.\n");
827827
exit(1);
828828
}
829829

src/neogb/f4sat.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static inline int is_pure_power(
4343
const len_t ebl = ht->ebl;
4444
const len_t evl = ht->evl;
4545
const len_t nv = ht->nv;
46-
46+
4747
for (i = 1; i < ebl; ++i) {
4848
if (ev[i] == 0) {
4949
ctr++;
@@ -69,7 +69,7 @@ static inline int is_zero_dimensional(
6969
len_t i;
7070

7171
len_t ctr = 0;
72-
72+
7373
const len_t nv = ht->nv;
7474
const len_t lml = bs->lml;
7575

@@ -78,7 +78,7 @@ static inline int is_zero_dimensional(
7878
ctr ++;
7979
}
8080
}
81-
81+
8282
if (ctr == nv) {
8383
return 1;
8484
}
@@ -94,7 +94,9 @@ static int is_already_saturated(
9494
md_t *st
9595
)
9696
{
97-
printf("testing if system is already saturated: ");
97+
if(st->info_level){
98+
printf("testing if system is already saturated: ");
99+
}
98100
double rrt0, rrt1;
99101
rrt0 = realtime();
100102

@@ -120,7 +122,7 @@ static int is_already_saturated(
120122
memcpy(lmps, bs->lmps, (unsigned long)lml * sizeof(bl_t));
121123
int8_t *red = (int8_t *)malloc((unsigned long)bs->sz * sizeof(int8_t));
122124
memcpy(red, bs->red, (unsigned long)bs->sz * sizeof(int8_t));
123-
125+
124126
ps_t *ps = st->ps;
125127

126128
cf32_t *cf = (cf32_t *)malloc(
@@ -137,7 +139,7 @@ static int is_already_saturated(
137139
bs->hm[bs->ld] = hm;
138140

139141
update_basis_f4(ps, bs, bht, st, 1);
140-
142+
141143
/* suppress infolevel printing in the test step */
142144
int32_t infolevel = st->info_level;
143145
st->info_level = 0;
@@ -201,10 +203,12 @@ static int is_already_saturated(
201203
*bhtp = bht;
202204
*shtp = sht;
203205

204-
if (is_constant == 1) {
206+
if (st->info_level){
207+
if (is_constant == 1) {
205208
printf("yes.");
206-
} else {
209+
} else {
207210
printf("no.");
211+
}
208212
}
209213

210214
rrt1 = realtime();

src/neogb/io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void import_input_data(
407407
}
408408
/* maybe some input elements are invalid, so reset ngens here */
409409
ngens = ctr;
410-
410+
411411
/* set total degree of input polynomials */
412412
deg_t deg = 0;
413413
if (st->nev) {
@@ -831,7 +831,7 @@ int32_t check_and_set_meta_data(
831831
/* elimination block order? If so, store the blocks length */
832832
st->nev = elim_block_len >= 0 ? elim_block_len : 0;
833833
if (st->nev >= st->nvars) {
834-
printf("error: Too large elimination block.\n");
834+
fprintf(stderr,"error: Too large elimination block.\n");
835835
exit(1);
836836
}
837837
/* set hash table size */
@@ -1119,7 +1119,7 @@ int32_t check_and_set_meta_data_trace(
11191119
return check_and_set_meta_data(st, lens, exps, cfs, invalid_gens,
11201120
field_char, mon_order, elim_block_len, nr_vars, nr_gens,
11211121
nr_nf, ht_size, nr_threads, max_nr_pairs, reset_hash_table,
1122-
la_option, use_signatures, reduce_gb, pbm_file, truncate_lifting,
1122+
la_option, use_signatures, reduce_gb, pbm_file, truncate_lifting,
11231123
info_level);
11241124
}
11251125

0 commit comments

Comments
 (0)