From 1ba3cf5f00c32e44bec715f772cefaf219ca1dfb Mon Sep 17 00:00:00 2001 From: safey Date: Thu, 22 Jan 2026 17:06:57 +0100 Subject: [PATCH 01/12] fixes choice of linear form in the non-radical case --- src/fglm/fglm_core.c | 5 ++++- src/msolve/msolve.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/fglm/fglm_core.c b/src/fglm/fglm_core.c index 7bb52c6d..14e8ec5c 100644 --- a/src/fglm/fglm_core.c +++ b/src/fglm/fglm_core.c @@ -1154,7 +1154,6 @@ static inline int invert_table_polynomial (param_t *param, if (lambda == 0) { nmod_poly_set_coeff_ui (data_bms->BMS->R0,i, data->res[(length-i-1)*block_size+ncoord]); - } else { uint64_t coeff= (lambda*data->res[(length-i-1)*block_size]) % prime; @@ -1165,6 +1164,8 @@ static inline int invert_table_polynomial (param_t *param, } + nmod_poly_zero(data_bms->BMS->R1); + nmod_poly_mul (data_bms->Z1,data_bms->BMS->R0,data_bms->BMS->V1); nmod_poly_shift_right (data_bms->Z1,data_bms->Z1,length); nmod_poly_xgcd (data_bms->BMS->R0,data_bms->BMS->R1,data_bms->Z2,param->elim, @@ -1186,6 +1187,7 @@ static inline void divide_table_polynomials (param_t *param, szmat_t length= data_bms->BMS->V1->length-1; nmod_poly_zero (data_bms->BMS->R0); nmod_poly_fit_length(data_bms->BMS->R0, length); + nmod_poly_zero(data_bms->BMS->R1); for (long i = 0; i < length; i++){ if (lambda == 0) { @@ -1268,6 +1270,7 @@ int compute_parametrizations_non_shape_position_case(param_t *param, fprintf(stdout, "invC1="); nmod_poly_fprint_pretty (stdout, data_bms->Z2, "x"); fprintf (stdout,"\n"); #endif + long dec = 0; for(long nc = 0; nc < nvars - 1 ; nc++){ diff --git a/src/msolve/msolve.c b/src/msolve/msolve.c index c4a9b6be..e6c5d072 100644 --- a/src/msolve/msolve.c +++ b/src/msolve/msolve.c @@ -1586,6 +1586,23 @@ static int32_t check_for_single_element_groebner_basis( return empty_solution_set; } +/* + * returns 1 if the parametrizations are the same else it returns 0 + * */ +static int equal_param(param_t *param, param_t *test_param){ + for(int i = 0; i < param->nvars-1; i++){ + if(param->coords[i]->length != test_param->coords[i]->length){ + return 0; + } + for(int32_t j = 0; j < param->coords[i]->length; j++){ + if(param->coords[i]->coeffs[j] != test_param->coords[i]->coeffs[j]){ + return 0; + } + } + } + return 1; +} + static int32_t *initial_modular_step( sp_matfglm_t **bmatrix, int32_t **bdiv_xn, @@ -1695,6 +1712,19 @@ static int32_t *initial_modular_step( *bparam = nmod_fglm_compute_trace_data(*bmatrix, fc, bs->ht->nv, *bsz, *nlins_ptr, linvars, lineqs_ptr[0], squvars, md->info_level, bdata_fglm, bdata_bms, success, md); + if((*bparam)->elim->length - 1 != dquot){ + param_t **test_nmod_param = + (param_t **)malloc(sizeof(param_t *)); + *test_nmod_param = nmod_fglm_compute_trace_data(*bmatrix, fc, bs->ht->nv, + *bsz, *nlins_ptr, linvars, lineqs_ptr[0], squvars, + 0, bdata_fglm, bdata_bms, success, md); + int boo = equal_param(*bparam, *test_nmod_param); + if(boo == 0){ + *success = 0; + } + free_fglm_param(test_nmod_param[0]); + free(test_nmod_param); + } } *dim = 0; *dquot_ori = dquot; @@ -2212,6 +2242,7 @@ int msolve_trace_qq(mpz_param_t *mpz_paramp, prime = next_prime(rand() % (1303905301 - (1 << 30) + 1) + (1 << 30)); } primeinit = prime; + primeinit = 1246353599; lp->p[0] = primeinit; if(info_level && gens->field_char == 0){ fprintf(stdout, "Initial prime is %d\n", lp->p[0]); From 63bc9bf419001b72ae629527c222553f5436201f Mon Sep 17 00:00:00 2001 From: safey Date: Thu, 22 Jan 2026 17:12:38 +0100 Subject: [PATCH 02/12] brings back initial random prime --- src/msolve/msolve.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/msolve/msolve.c b/src/msolve/msolve.c index e6c5d072..17ff6507 100644 --- a/src/msolve/msolve.c +++ b/src/msolve/msolve.c @@ -2242,7 +2242,6 @@ int msolve_trace_qq(mpz_param_t *mpz_paramp, prime = next_prime(rand() % (1303905301 - (1 << 30) + 1) + (1 << 30)); } primeinit = prime; - primeinit = 1246353599; lp->p[0] = primeinit; if(info_level && gens->field_char == 0){ fprintf(stdout, "Initial prime is %d\n", lp->p[0]); From 024ba83e734b87d62439cad28d92db53df46e2d9 Mon Sep 17 00:00:00 2001 From: safey Date: Fri, 23 Jan 2026 08:21:49 +0100 Subject: [PATCH 03/12] adds test file --- input_files/choice-linear-form-qq.ms | 11 +++++++++++ output_files/choice-linear-form-qq.res | 26 ++++++++++++++++++++++++++ test/diff/diff_choice-linear-forms.sh | 5 +++++ 3 files changed, 42 insertions(+) create mode 100644 input_files/choice-linear-form-qq.ms create mode 100644 output_files/choice-linear-form-qq.res create mode 100755 test/diff/diff_choice-linear-forms.sh diff --git a/input_files/choice-linear-form-qq.ms b/input_files/choice-linear-form-qq.ms new file mode 100644 index 00000000..21a609ae --- /dev/null +++ b/input_files/choice-linear-form-qq.ms @@ -0,0 +1,11 @@ +_xx[1], _xx[2], _xx[3], _xx[4], _xx[5], _xx[6], _xx[7], _xx[8] +0 +-_xx[1]+_xx[2], +-_xx[1]+_xx[4], +-_xx[1]+_xx[5], +_xx[1]+_xx[6], +-_xx[1]+_xx[7], +-_xx[3]*_xx[6]+_xx[2]*_xx[7]+_xx[1], +-_xx[4]*_xx[7]-_xx[1]+_xx[3], +-_xx[5]*_xx[6]+_xx[2]*_xx[8]-_xx[1]+_xx[6]-_xx[8], +-_xx[4]*_xx[6]+_xx[5]*_xx[6]-_xx[2]*_xx[8]+_xx[4]*_xx[8]+_xx[2]-_xx[5] diff --git a/output_files/choice-linear-form-qq.res b/output_files/choice-linear-form-qq.res new file mode 100644 index 00000000..ff593ec7 --- /dev/null +++ b/output_files/choice-linear-form-qq.res @@ -0,0 +1,26 @@ +[0, [0, +9, +3, +['_xx[1]', '_xx[2]', '_xx[3]', '_xx[4]', '_xx[5]', '_xx[6]', '_xx[7]', '_xx[8]', 'A'], +[1,4,9,16,25,36,49,64,1], +[1, +[[2, [0, 37, 1]], +[1, [37, 2]], +[ +[[1, [0, 1]], +1], +[[1, [0, 1]], +1], +[[1, [0, 0]], +1], +[[1, [0, 1]], +1], +[[1, [0, 1]], +1], +[[1, [0, -1]], +1], +[[1, [0, 1]], +1], +[[1, [0, -3]], +2] +]]]]]: diff --git a/test/diff/diff_choice-linear-forms.sh b/test/diff/diff_choice-linear-forms.sh new file mode 100755 index 00000000..6850588a --- /dev/null +++ b/test/diff/diff_choice-linear-forms.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +file=choice-linear-form-qq + +source test/diff/diff_source.sh From 6c582d1b3c4f2a54a8e3d00ef6bb47a4e891e143 Mon Sep 17 00:00:00 2001 From: safey Date: Fri, 23 Jan 2026 08:24:29 +0100 Subject: [PATCH 04/12] fixes name of diff file --- .../{diff_choice-linear-forms.sh => diff_choice-linear-form.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/diff/{diff_choice-linear-forms.sh => diff_choice-linear-form.sh} (100%) diff --git a/test/diff/diff_choice-linear-forms.sh b/test/diff/diff_choice-linear-form.sh similarity index 100% rename from test/diff/diff_choice-linear-forms.sh rename to test/diff/diff_choice-linear-form.sh From 039bf94b885c4932a453b03e9d9de9a7228cffdc Mon Sep 17 00:00:00 2001 From: safey Date: Fri, 23 Jan 2026 08:29:30 +0100 Subject: [PATCH 05/12] updates Makefile.am and configure.ac --- Makefile.am | 1 + configure.ac | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Makefile.am b/Makefile.am index c92c86cc..ea2c76a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,7 @@ checkdiff = test/diff/diff_cp_d_3_n_4_p_2.sh \ test/diff/diff_reals_dim0-chgvar.sh \ test/diff/diff_reals_dim0-extract.sh \ test/diff/diff_reals_dim0-swapvar.sh \ + test/diff/diff_choice-linear-form.sh \ test/diff/diff_bug_empty_tracer.sh \ test/diff/diff_bug_2nd_prime_bad.sh \ test/diff/diff_bug_68.sh \ diff --git a/configure.ac b/configure.ac index 5a4c6020..a5855fc4 100644 --- a/configure.ac +++ b/configure.ac @@ -202,6 +202,9 @@ AC_CONFIG_LINKS([ input_files/radical_shape-qq.ms:input_files/radical_shape-qq.ms output_files/radical_shape-qq.res:output_files/radical_shape-qq.res test/diff/diff_radical_shape-qq.sh:test/diff/diff_radical_shape-qq.sh + input_files/choice-linear-form-qq.ms:input_files/choice-linear-form-qq.ms + output_files/choice-linear-form-qq.res:output_files/choice-linear-form-qq.res + test/diff/diff_choice-linear-form.sh:test/diff/diff_choice-linear-form.sh input_files/reals_dim0.ms:input_files/reals_dim0.ms output_files/reals_dim0.res:output_files/reals_dim0.res output_files/reals_dim0.p256.res:output_files/reals_dim0.p256.res From f84a4735f041214160b9f55138fc150ed7d7f2ea Mon Sep 17 00:00:00 2001 From: safey Date: Fri, 23 Jan 2026 09:40:22 +0100 Subject: [PATCH 06/12] one more test --- Makefile.am | 1 + configure.ac | 3 ++ .../choice-linear-form-qq-real-roots.ms | 11 ++++ .../choice-linear-form-qq-real-roots.res | 3 ++ .../diff_choice-linear-form-real-roots.sh | 50 +++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 input_files/choice-linear-form-qq-real-roots.ms create mode 100644 output_files/choice-linear-form-qq-real-roots.res create mode 100755 test/diff/diff_choice-linear-form-real-roots.sh diff --git a/Makefile.am b/Makefile.am index ea2c76a6..b04db6f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,7 @@ checkdiff = test/diff/diff_cp_d_3_n_4_p_2.sh \ test/diff/diff_reals_dim0-extract.sh \ test/diff/diff_reals_dim0-swapvar.sh \ test/diff/diff_choice-linear-form.sh \ + test/diff/diff_choice-linear-form-real-roots.sh \ test/diff/diff_bug_empty_tracer.sh \ test/diff/diff_bug_2nd_prime_bad.sh \ test/diff/diff_bug_68.sh \ diff --git a/configure.ac b/configure.ac index a5855fc4..4e7a0a21 100644 --- a/configure.ac +++ b/configure.ac @@ -205,6 +205,9 @@ AC_CONFIG_LINKS([ input_files/choice-linear-form-qq.ms:input_files/choice-linear-form-qq.ms output_files/choice-linear-form-qq.res:output_files/choice-linear-form-qq.res test/diff/diff_choice-linear-form.sh:test/diff/diff_choice-linear-form.sh + input_files/choice-linear-form-qq-real-roots.ms:input_files/choice-linear-form-qq-real-roots.ms + output_files/choice-linear-form-qq-real-roots.res:output_files/choice-linear-form-qq-real-roots.res + test/diff/diff_choice-linear-form-real-roots.sh:test/diff/diff_choice-linear-form-real-roots.sh input_files/reals_dim0.ms:input_files/reals_dim0.ms output_files/reals_dim0.res:output_files/reals_dim0.res output_files/reals_dim0.p256.res:output_files/reals_dim0.p256.res diff --git a/input_files/choice-linear-form-qq-real-roots.ms b/input_files/choice-linear-form-qq-real-roots.ms new file mode 100644 index 00000000..21a609ae --- /dev/null +++ b/input_files/choice-linear-form-qq-real-roots.ms @@ -0,0 +1,11 @@ +_xx[1], _xx[2], _xx[3], _xx[4], _xx[5], _xx[6], _xx[7], _xx[8] +0 +-_xx[1]+_xx[2], +-_xx[1]+_xx[4], +-_xx[1]+_xx[5], +_xx[1]+_xx[6], +-_xx[1]+_xx[7], +-_xx[3]*_xx[6]+_xx[2]*_xx[7]+_xx[1], +-_xx[4]*_xx[7]-_xx[1]+_xx[3], +-_xx[5]*_xx[6]+_xx[2]*_xx[8]-_xx[1]+_xx[6]-_xx[8], +-_xx[4]*_xx[6]+_xx[5]*_xx[6]-_xx[2]*_xx[8]+_xx[4]*_xx[8]+_xx[2]-_xx[5] diff --git a/output_files/choice-linear-form-qq-real-roots.res b/output_files/choice-linear-form-qq-real-roots.res new file mode 100644 index 00000000..bea02a67 --- /dev/null +++ b/output_files/choice-linear-form-qq-real-roots.res @@ -0,0 +1,3 @@ +[0, [1, +[[[-1, -1], [-1, -1], [0, 0], [-1, -1], [-1, -1], [1, 1], [-1, -1], [3 / 2, 3 / 2]], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]] +]]: diff --git a/test/diff/diff_choice-linear-form-real-roots.sh b/test/diff/diff_choice-linear-form-real-roots.sh new file mode 100755 index 00000000..ce544eee --- /dev/null +++ b/test/diff/diff_choice-linear-form-real-roots.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +file=choice-linear-form-qq-real-roots + + +$(pwd)/msolve -f input_files/$file.ms -o test/diff/$file.res \ + -d 0 -l 2 -t 1 +if [ $? -gt 0 ]; then + exit 1 +fi + +diff test/diff/$file.res output_files/$file.res +if [ $? -gt 0 ]; then + exit 2 +fi + +$(pwd)/msolve -f input_files/$file.ms -o test/diff/$file.res \ + -d 0 -l 2 -t 2 +if [ $? -gt 0 ]; then + exit 21 +fi + +diff test/diff/$file.res output_files/$file.res +if [ $? -gt 0 ]; then + exit 22 +fi + +$(pwd)/msolve -f input_files/$file.ms -o test/diff/$file.res \ + -d 0 -l 44 -t 1 +if [ $? -gt 0 ]; then + exit 41 +fi + +diff test/diff/$file.res output_files/$file.res +if [ $? -gt 0 ]; then + exit 42 +fi + +$(pwd)/msolve -f input_files/$file.ms -o test/diff/$file.res \ + -d 0 -l 44 -t 2 +if [ $? -gt 0 ]; then + exit 61 +fi + +diff test/diff/$file.res output_files/$file.res +if [ $? -gt 0 ]; then + exit 62 +fi + +rm test/diff/$file.res From 995ab9692aee3ed9b52044b051b97465b9961906 Mon Sep 17 00:00:00 2001 From: Mohab Safey El Din Date: Sat, 24 Jan 2026 08:20:30 +0100 Subject: [PATCH 07/12] Update Makefile.am Co-authored-by: jerebertho <94358310+jerebertho@users.noreply.github.com> --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index b04db6f3..489fec6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,7 +48,7 @@ checkdiff = test/diff/diff_cp_d_3_n_4_p_2.sh \ test/diff/diff_reals_dim0-chgvar.sh \ test/diff/diff_reals_dim0-extract.sh \ test/diff/diff_reals_dim0-swapvar.sh \ - test/diff/diff_choice-linear-form.sh \ + test/diff/diff_choice-linear-form-qq.sh \ test/diff/diff_choice-linear-form-real-roots.sh \ test/diff/diff_bug_empty_tracer.sh \ test/diff/diff_bug_2nd_prime_bad.sh \ From 5371a6f2643878119b0a03adf1dbffdb8a3bcf23 Mon Sep 17 00:00:00 2001 From: Mohab Safey El Din Date: Sat, 24 Jan 2026 08:20:50 +0100 Subject: [PATCH 08/12] Update Makefile.am Co-authored-by: jerebertho <94358310+jerebertho@users.noreply.github.com> --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 489fec6f..f3e27587 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ checkdiff = test/diff/diff_cp_d_3_n_4_p_2.sh \ test/diff/diff_reals_dim0-extract.sh \ test/diff/diff_reals_dim0-swapvar.sh \ test/diff/diff_choice-linear-form-qq.sh \ - test/diff/diff_choice-linear-form-real-roots.sh \ + test/diff/diff_choice-linear-form-qq-real-roots.sh \ test/diff/diff_bug_empty_tracer.sh \ test/diff/diff_bug_2nd_prime_bad.sh \ test/diff/diff_bug_68.sh \ From fad68eebf5ab699167549cf0a06ff1ebd4d6c6db Mon Sep 17 00:00:00 2001 From: Mohab Safey El Din Date: Sat, 24 Jan 2026 08:21:11 +0100 Subject: [PATCH 09/12] Update configure.ac Co-authored-by: jerebertho <94358310+jerebertho@users.noreply.github.com> --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4e7a0a21..fdc95d5a 100644 --- a/configure.ac +++ b/configure.ac @@ -204,7 +204,7 @@ AC_CONFIG_LINKS([ test/diff/diff_radical_shape-qq.sh:test/diff/diff_radical_shape-qq.sh input_files/choice-linear-form-qq.ms:input_files/choice-linear-form-qq.ms output_files/choice-linear-form-qq.res:output_files/choice-linear-form-qq.res - test/diff/diff_choice-linear-form.sh:test/diff/diff_choice-linear-form.sh + test/diff/diff_choice-linear-form-qq.sh:test/diff/diff_choice-linear-form-qq.sh input_files/choice-linear-form-qq-real-roots.ms:input_files/choice-linear-form-qq-real-roots.ms output_files/choice-linear-form-qq-real-roots.res:output_files/choice-linear-form-qq-real-roots.res test/diff/diff_choice-linear-form-real-roots.sh:test/diff/diff_choice-linear-form-real-roots.sh From e3b2361e14becf1f8ef57b9572468d806d741195 Mon Sep 17 00:00:00 2001 From: Mohab Safey El Din Date: Sat, 24 Jan 2026 08:21:30 +0100 Subject: [PATCH 10/12] Update configure.ac Co-authored-by: jerebertho <94358310+jerebertho@users.noreply.github.com> --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fdc95d5a..ec886f73 100644 --- a/configure.ac +++ b/configure.ac @@ -207,7 +207,7 @@ AC_CONFIG_LINKS([ test/diff/diff_choice-linear-form-qq.sh:test/diff/diff_choice-linear-form-qq.sh input_files/choice-linear-form-qq-real-roots.ms:input_files/choice-linear-form-qq-real-roots.ms output_files/choice-linear-form-qq-real-roots.res:output_files/choice-linear-form-qq-real-roots.res - test/diff/diff_choice-linear-form-real-roots.sh:test/diff/diff_choice-linear-form-real-roots.sh + test/diff/diff_choice-linear-form-qq-real-roots.sh:test/diff/diff_choice-linear-form-qq-real-roots.sh input_files/reals_dim0.ms:input_files/reals_dim0.ms output_files/reals_dim0.res:output_files/reals_dim0.res output_files/reals_dim0.p256.res:output_files/reals_dim0.p256.res From ceca7ef3ef153c8524d4cfc1ee188801cfc7c7b2 Mon Sep 17 00:00:00 2001 From: safey Date: Sat, 24 Jan 2026 08:22:52 +0100 Subject: [PATCH 11/12] renames diff file --- ...orm-real-roots.sh => diff_choice-linear-form-qq-real-roots.sh} | 0 .../{diff_choice-linear-form.sh => diff_choice-linear-form-qq.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/diff/{diff_choice-linear-form-real-roots.sh => diff_choice-linear-form-qq-real-roots.sh} (100%) rename test/diff/{diff_choice-linear-form.sh => diff_choice-linear-form-qq.sh} (100%) diff --git a/test/diff/diff_choice-linear-form-real-roots.sh b/test/diff/diff_choice-linear-form-qq-real-roots.sh similarity index 100% rename from test/diff/diff_choice-linear-form-real-roots.sh rename to test/diff/diff_choice-linear-form-qq-real-roots.sh diff --git a/test/diff/diff_choice-linear-form.sh b/test/diff/diff_choice-linear-form-qq.sh similarity index 100% rename from test/diff/diff_choice-linear-form.sh rename to test/diff/diff_choice-linear-form-qq.sh From 353142a38abaa50d3da4006f50e9ab824d34925d Mon Sep 17 00:00:00 2001 From: safey Date: Sat, 24 Jan 2026 08:31:42 +0100 Subject: [PATCH 12/12] uses nmod_poly_equal in equal_param as suggested by Jeremy --- src/msolve/msolve.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/msolve/msolve.c b/src/msolve/msolve.c index 17ff6507..2c6fb374 100644 --- a/src/msolve/msolve.c +++ b/src/msolve/msolve.c @@ -1591,14 +1591,9 @@ static int32_t check_for_single_element_groebner_basis( * */ static int equal_param(param_t *param, param_t *test_param){ for(int i = 0; i < param->nvars-1; i++){ - if(param->coords[i]->length != test_param->coords[i]->length){ + if(!nmod_poly_equal(param->coords[i], test_param->coords[i])){ return 0; } - for(int32_t j = 0; j < param->coords[i]->length; j++){ - if(param->coords[i]->coeffs[j] != test_param->coords[i]->coeffs[j]){ - return 0; - } - } } return 1; }