The package rpms/flint.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/flint.git/commit/?id=82193cbacc91....
Change:
+%ifnarch %{arm}
Thanks.
Full change:
============
commit 82193cbacc912f3b81f1b7341374e18a86f12a24
Author: Jerry James <loganjerry(a)gmail.com>
Date: Wed Jul 8 17:02:34 2020 -0600
Disable tests on 32-bit ARM until upstream can diagnose a failure.
-Add upstream patches to fix bugs discovered after release:
-fmpq-poly-add-fmpq.patch, -nmod-mpolyn-interp-crt-lg-poly.patch,
-fmpz-mpoly-div-monagan-pearce.patch, -fmpz-poly-factor.patch,
-fmpz-mod-poly-gcdiv-euclidean.patch.
diff --git a/flint-fmpq-poly-add-fmpq.patch b/flint-fmpq-poly-add-fmpq.patch
new file mode 100644
index 0000000..e18b1b8
--- /dev/null
+++ b/flint-fmpq-poly-add-fmpq.patch
@@ -0,0 +1,24 @@
+See:
+https://github.com/wbhart/flint2/pull/766
+https://github.com/wbhart/flint2/commit/17d26d4c957828f3c98c15ddec85108f841d3438
+
+--- fmpq_poly/inlines.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpq_poly/inlines.c 2020-07-08 14:21:35.022234028 -0600
+@@ -154,6 +154,8 @@ void fmpq_poly_add_fmpq(fmpq_poly_t res,
+ return;
+ }
+
++ fmpq_poly_set(res, poly);
++
+ if (poly -> length == 1)
+ {
+ _fmpq_add(res->coeffs, res->den, poly->coeffs, poly->den,
fmpq_numref(c), fmpq_denref(c));
+@@ -162,8 +164,6 @@ void fmpq_poly_add_fmpq(fmpq_poly_t res,
+ return;
+ }
+
+- fmpq_poly_set(res, poly);
+-
+ if (fmpz_equal(res->den, fmpq_denref(c)))
+ {
+ fmpz_add(res->coeffs + 0, res->coeffs + 0, fmpq_numref(c));
diff --git a/flint-fmpz-mod-poly-gcdiv-euclidean.patch
b/flint-fmpz-mod-poly-gcdiv-euclidean.patch
new file mode 100644
index 0000000..dcd0e34
--- /dev/null
+++ b/flint-fmpz-mod-poly-gcdiv-euclidean.patch
@@ -0,0 +1,52 @@
+--- fmpz_mod_poly/gcdinv_euclidean.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mod_poly/gcdinv_euclidean.c 2020-07-08 15:32:07.200950081 -0600
+@@ -68,6 +68,12 @@ slong _fmpz_mod_poly_gcdinv_euclidean(fm
+ _fmpz_vec_swap(S, Q, lenQ);
+ _fmpz_vec_neg(S, S, lenQ);
+
++ for (i = 0; i < lenQ; i++)
++ {
++ if (fmpz_sgn(S + i) < 0)
++ fmpz_add(S + i, S + i, p);
++ }
++
+ for (i = 0; i < 2*lenB; i++)
+ fmpz_clear(Q + i);
+
+@@ -129,6 +135,12 @@ slong _fmpz_mod_poly_gcdinv_euclidean(fm
+ _fmpz_vec_swap(G, D, lenD);
+ _fmpz_vec_swap(S, U1, lenU1);
+
++ for (i = 0; i < lenU1; i++)
++ {
++ if (fmpz_sgn(S + i) < 0)
++ fmpz_add(S + i, S + i, p);
++ }
++
+ for (i = 0; i < 3*lenB + 2*lenA; i++)
+ fmpz_clear(W + i);
+
+--- fq_poly_templates/test/t-xgcd_euclidean_f.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_poly_templates/test/t-xgcd_euclidean_f.c 2020-07-08 15:32:07.200950081 -0600
+@@ -97,7 +97,7 @@ main(void)
+ /* Special case, arguments share a factor ******************************* */
+
+ /* Compare with result from GCD and check correctness */
+- for (i = 0; i < 5 * flint_test_multiplier(); i++)
++ for (i = 0; i < 50 * flint_test_multiplier(); i++)
+ {
+ TEMPLATE(T, ctx_t) ctx;
+ TEMPLATE(T, t) f1, f2;
+@@ -117,9 +117,9 @@ main(void)
+ TEMPLATE(T, poly_init) (t, ctx);
+ TEMPLATE(T, poly_init) (v, ctx);
+ TEMPLATE(T, poly_init) (w, ctx);
+- TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 100), ctx);
+- TEMPLATE(T, poly_randtest) (b, state, n_randint(state, 100), ctx);
+- TEMPLATE(T, poly_randtest) (f, state, n_randint(state, 20), ctx);
++ TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 10), ctx);
++ TEMPLATE(T, poly_randtest) (b, state, n_randint(state, 10), ctx);
++ TEMPLATE(T, poly_randtest) (f, state, n_randint(state, 5), ctx);
+ TEMPLATE(T, poly_mul) (a, a, f, ctx);
+ TEMPLATE(T, poly_mul) (b, b, f, ctx);
+
diff --git a/flint-fmpz-mpoly-div-monagan-pearce.patch
b/flint-fmpz-mpoly-div-monagan-pearce.patch
new file mode 100644
index 0000000..2d3744a
--- /dev/null
+++ b/flint-fmpz-mpoly-div-monagan-pearce.patch
@@ -0,0 +1,471 @@
+--- fmpz_mpoly/div_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/div_monagan_pearce.c 2020-07-08 15:24:54.544954325 -0600
+@@ -712,7 +712,6 @@ void fmpz_mpoly_div_monagan_pearce(fmpz_
+ int free2 = 0, free3 = 0;
+ fmpz_mpoly_t temp1;
+ fmpz_mpoly_struct * tq;
+- TMP_INIT;
+
+ /* check divisor is nonzero */
+ if (poly3->length == 0)
+@@ -725,13 +724,11 @@ void fmpz_mpoly_div_monagan_pearce(fmpz_
+ return;
+ }
+
+- TMP_START;
+-
+ /* maximum bits in quotient exps and inputs is max for poly2 and poly3 */
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -785,7 +782,7 @@ void fmpz_mpoly_div_monagan_pearce(fmpz_
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -825,5 +822,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- fmpz_mpoly/divrem_ideal_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/divrem_ideal_monagan_pearce.c 2020-07-08 15:24:54.544954325 -0600
+@@ -715,11 +715,9 @@ void fmpz_mpoly_divrem_ideal_monagan_pea
+ return;
+ }
+
+-
+ TMP_START;
+
+ free3 = (int *) TMP_ALLOC(len*sizeof(int));
+-
+ exp3 = (ulong **) TMP_ALLOC(len*sizeof(ulong *));
+
+ /* compute maximum degrees that can occur in any input or output polys */
+@@ -730,7 +728,7 @@ void fmpz_mpoly_divrem_ideal_monagan_pea
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -808,7 +806,7 @@ void fmpz_mpoly_divrem_ideal_monagan_pea
+
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -862,5 +860,7 @@ cleanup3:
+ flint_free(exp3[i]);
+ }
+
++ flint_free(cmpmask);
++
+ TMP_END;
+ }
+--- fmpz_mpoly/divrem_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/divrem_monagan_pearce.c 2020-07-08 15:24:54.545954325 -0600
+@@ -739,7 +739,6 @@ void fmpz_mpoly_divrem_monagan_pearce(fm
+ int free2 = 0, free3 = 0;
+ fmpz_mpoly_t temp1, temp2;
+ fmpz_mpoly_struct * tq, * tr;
+- TMP_INIT;
+
+ /* check divisor is nonzero */
+ if (poly3->length == 0)
+@@ -754,13 +753,11 @@ void fmpz_mpoly_divrem_monagan_pearce(fm
+ return;
+ }
+
+- TMP_START;
+-
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -830,7 +827,7 @@ void fmpz_mpoly_divrem_monagan_pearce(fm
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -860,14 +857,12 @@ void fmpz_mpoly_divrem_monagan_pearce(fm
+ if (q == poly2 || q == poly3)
+ {
+ fmpz_mpoly_swap(temp1, q, ctx);
+-
+ fmpz_mpoly_clear(temp1, ctx);
+ }
+
+ if (r == poly2 || r == poly3)
+ {
+ fmpz_mpoly_swap(temp2, r, ctx);
+-
+ fmpz_mpoly_clear(temp2, ctx);
+ }
+
+@@ -882,5 +877,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- fmpz_mpoly/quasidiv_heap.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/quasidiv_heap.c 2020-07-08 15:24:54.545954325 -0600
+@@ -800,7 +800,6 @@ void fmpz_mpoly_quasidiv_heap(fmpz_t sca
+ int free2 = 0, free3 = 0;
+ fmpz_mpoly_t temp1;
+ fmpz_mpoly_struct * tq;
+- TMP_INIT;
+
+ /* check divisor is nonzero */
+ if (poly3->length == 0)
+@@ -815,10 +814,9 @@ void fmpz_mpoly_quasidiv_heap(fmpz_t sca
+ return;
+ }
+
+- TMP_START;
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -874,6 +872,7 @@ void fmpz_mpoly_quasidiv_heap(fmpz_t sca
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -913,5 +912,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- fmpz_mpoly/quasidivrem_heap.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/quasidivrem_heap.c 2020-07-08 15:24:54.546954325 -0600
+@@ -768,7 +768,6 @@ void fmpz_mpoly_quasidivrem_heap(fmpz_t
+ int free2 = 0, free3 = 0;
+ fmpz_mpoly_t temp1, temp2;
+ fmpz_mpoly_struct * tq, * tr;
+- TMP_INIT;
+
+ /* check divisor is nonzero */
+ if (poly3->length == 0)
+@@ -784,12 +783,11 @@ void fmpz_mpoly_quasidivrem_heap(fmpz_t
+ return;
+ }
+
+- TMP_START;
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -863,6 +861,7 @@ void fmpz_mpoly_quasidivrem_heap(fmpz_t
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -914,5 +913,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- fmpz_mpoly/quasidivrem_ideal_heap.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mpoly/quasidivrem_ideal_heap.c 2020-07-08 15:24:54.547954325 -0600
+@@ -678,7 +678,7 @@ void fmpz_mpoly_quasidivrem_ideal_heap(f
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -755,7 +755,7 @@ void fmpz_mpoly_quasidivrem_ideal_heap(f
+
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -808,5 +808,7 @@ cleanup3:
+ flint_free(exp3[i]);
+ }
+
++ flint_free(cmpmask);
++
+ TMP_END;
+ }
+--- fq_nmod_mpoly/div_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/div_monagan_pearce.c 2020-07-08 15:24:54.547954325 -0600
+@@ -247,7 +247,6 @@ void fq_nmod_mpoly_div_monagan_pearce(fq
+ int free2 = 0, free3 = 0;
+ fq_nmod_mpoly_t temp1;
+ fq_nmod_mpoly_struct * tq;
+- TMP_INIT;
+
+ if (poly3->length == 0)
+ {
+@@ -261,13 +260,11 @@ void fq_nmod_mpoly_div_monagan_pearce(fq
+ return;
+ }
+
+- TMP_START;
+-
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -323,7 +320,7 @@ void fq_nmod_mpoly_div_monagan_pearce(fq
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+
+@@ -364,5 +361,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- fq_nmod_mpoly/divrem_ideal_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/divrem_ideal_monagan_pearce.c 2020-07-08 15:24:54.547954325 -0600
+@@ -336,7 +336,7 @@ void fq_nmod_mpoly_divrem_ideal_monagan_
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -413,7 +413,7 @@ void fq_nmod_mpoly_divrem_ideal_monagan_
+
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -466,5 +466,7 @@ cleanup3:
+ flint_free(exp3[i]);
+ }
+
++ flint_free(cmpmask);
++
+ TMP_END;
+ }
+--- fq_nmod_mpoly/divrem_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/divrem_monagan_pearce.c 2020-07-08 15:24:54.548954325 -0600
+@@ -260,7 +260,6 @@ void fq_nmod_mpoly_divrem_monagan_pearce
+ int free2 = 0, free3 = 0;
+ fq_nmod_mpoly_t temp1, temp2;
+ fq_nmod_mpoly_struct * tq, * tr;
+- TMP_INIT;
+
+ if (poly3->length == 0)
+ {
+@@ -274,13 +273,11 @@ void fq_nmod_mpoly_divrem_monagan_pearce
+ return;
+ }
+
+- TMP_START;
+-
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -352,7 +349,7 @@ void fq_nmod_mpoly_divrem_monagan_pearce
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -402,5 +399,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- nmod_mpoly/div_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/div_monagan_pearce.c 2020-07-08 15:24:54.548954325 -0600
+@@ -491,7 +491,6 @@ void nmod_mpoly_div_monagan_pearce(nmod_
+ int free2 = 0, free3 = 0;
+ nmod_mpoly_t temp1;
+ nmod_mpoly_struct * tq;
+- TMP_INIT;
+
+ if (poly3->length == 0)
+ {
+@@ -509,12 +508,10 @@ void nmod_mpoly_div_monagan_pearce(nmod_
+ return;
+ }
+
+- TMP_START;
+-
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -569,10 +566,9 @@ void nmod_mpoly_div_monagan_pearce(nmod_
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+-
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+ mpoly_repack_monomials(exp2, exp_bits, old_exp2, old_exp_bits,
+ poly2->length, ctx->minfo);
+@@ -610,5 +606,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
+--- nmod_mpoly/divrem_ideal_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/divrem_ideal_monagan_pearce.c 2020-07-08 15:24:54.549954325 -0600
+@@ -538,7 +538,7 @@ void nmod_mpoly_divrem_ideal_monagan_pea
+ exp_bits = FLINT_MAX(exp_bits, poly3[i]->bits);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -614,7 +614,7 @@ void nmod_mpoly_divrem_ideal_monagan_pea
+
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ exp2 = (ulong *) flint_malloc(N*poly2->length*sizeof(ulong));
+@@ -667,5 +667,7 @@ cleanup3:
+ flint_free(exp3[i]);
+ }
+
++ flint_free(cmpmask);
++
+ TMP_END;
+ }
+--- nmod_mpoly/divrem_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/divrem_monagan_pearce.c 2020-07-08 15:24:54.549954325 -0600
+@@ -461,7 +461,6 @@ void nmod_mpoly_divrem_monagan_pearce(nm
+ int free2 = 0, free3 = 0;
+ nmod_mpoly_t temp1, temp2;
+ nmod_mpoly_struct * tq, * tr;
+- TMP_INIT;
+
+ if (poly3->length == 0)
+ {
+@@ -481,13 +480,11 @@ void nmod_mpoly_divrem_monagan_pearce(nm
+ return;
+ }
+
+- TMP_START;
+-
+ exp_bits = FLINT_MAX(poly2->bits, poly3->bits);
+ exp_bits = mpoly_fix_bits(exp_bits, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_malloc(N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+ /* ensure input exponents packed to same size as output exponents */
+@@ -550,14 +547,14 @@ void nmod_mpoly_divrem_monagan_pearce(nm
+ poly2->length, poly3->coeffs, exp3, poly3->length,
exp_bits,
+ N, cmpmask, ctx->ffinfo)) == 0
+ && lenr == 0)
+- {
++ {
+ ulong * old_exp2 = exp2, * old_exp3 = exp3;
+ slong old_exp_bits = exp_bits;
+
+ exp_bits = mpoly_fix_bits(exp_bits + 1, ctx->minfo);
+
+ N = mpoly_words_per_exp(exp_bits, ctx->minfo);
+- cmpmask = (ulong*) TMP_ALLOC(N*sizeof(ulong));
++ cmpmask = (ulong *) flint_realloc(cmpmask, N*sizeof(ulong));
+ mpoly_get_cmpmask(cmpmask, N, exp_bits, ctx->minfo);
+
+
+@@ -608,5 +605,5 @@ cleanup3:
+ if (free3)
+ flint_free(exp3);
+
+- TMP_END;
++ flint_free(cmpmask);
+ }
diff --git a/flint-fmpz-poly-factor.patch b/flint-fmpz-poly-factor.patch
new file mode 100644
index 0000000..34d21a5
--- /dev/null
+++ b/flint-fmpz-poly-factor.patch
@@ -0,0 +1,11 @@
+--- fmpz_mat/next_col_van_hoeij.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fmpz_mat/next_col_van_hoeij.c 2020-07-08 15:29:28.028967218 -0600
+@@ -84,7 +84,7 @@ int fmpz_mat_next_col_van_hoeij(fmpz_mat
+ k = fmpz_bits(P) - bit_r - bit_r/2;
+
+ /* check if LLL justified */
+- if (k < exp + FLINT_BIT_COUNT(r + 1))
++ if (k < exp + (slong) FLINT_BIT_COUNT(r + 1))
+ return 0;
+
+ fmpz_init(P_trunc);
diff --git a/flint-nmod-mpolyn-interp-crt-lg-poly.patch
b/flint-nmod-mpolyn-interp-crt-lg-poly.patch
new file mode 100644
index 0000000..77ff5cf
--- /dev/null
+++ b/flint-nmod-mpolyn-interp-crt-lg-poly.patch
@@ -0,0 +1,1507 @@
+--- fq_nmod_mpoly/interp.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/interp.c 2020-07-08 15:42:31.617271605 -0600
+@@ -214,7 +214,7 @@ int nmod_mpolyn_interp_crt_lg_poly(
+ changed = 1;
+ fq_nmod_mul(u, v, inv_m_eval, fqctx);
+ nmod_poly_mul(w, u, modulus);
+- nmod_poly_sub(Tcoeffs + 0, Fcoeffs + 0, w);
++ nmod_poly_sub(Tcoeffs + Ti, Fcoeffs + Fi, w);
+ }
+ else
+ {
+--- fq_nmod_mpoly/test/t-div_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-div_monagan_pearce.c 2020-07-08 15:42:31.618271605 -0600
+@@ -49,9 +49,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(l, state, len, exp_bits, ctx);
+@@ -125,9 +125,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(q, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+--- fq_nmod_mpoly/test/t-divrem_ideal_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000
-0600
++++ fq_nmod_mpoly/test/t-divrem_ideal_monagan_pearce.c 2020-07-08 15:42:31.618271605
-0600
+@@ -51,9 +51,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bits(g, state, len2, exp_bits2 + 1, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bits(g, state, len2, exp_bits2 + 1, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(r, state, len, exp_bits, ctx);
+@@ -128,9 +128,9 @@ main(void)
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ fq_nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
++ if (fq_nmod_mpoly_is_zero(darr[w], ctx))
++ fq_nmod_mpoly_one(darr[w], ctx);
+ fq_nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+ fq_nmod_mpoly_randtest_bound(k1, state, len, exp_bound, ctx);
+@@ -218,9 +218,9 @@ main(void)
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ fq_nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
++ if (fq_nmod_mpoly_is_zero(darr[w], ctx))
++ fq_nmod_mpoly_one(darr[w], ctx);
+ fq_nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+ fq_nmod_mpoly_randtest_bound(k1, state, len, exp_bound, ctx);
+--- fq_nmod_mpoly/test/t-divrem_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000
-0600
++++ fq_nmod_mpoly/test/t-divrem_monagan_pearce.c 2020-07-08 15:42:31.618271605 -0600
+@@ -16,14 +16,15 @@
+ int
+ main(void)
+ {
+- int i, j, result;
++ int result;
++ slong i, j, tmul = 10;
+ FLINT_TEST_INIT(state);
+
+ flint_printf("divrem_monagan_pearce....");
+ fflush(stdout);
+
+ /* Check f*g/g = f */
+- for (i = 0; i < 50 * flint_test_multiplier(); i++)
++ for (i = 0; i < 5 * tmul * flint_test_multiplier(); i++)
+ {
+ fq_nmod_mpoly_ctx_t ctx;
+ fq_nmod_mpoly_t f, g, h, k, r;
+@@ -49,9 +50,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ fq_nmod_mpoly_randtest_bits(r, state, len, exp_bits, ctx);
+@@ -82,7 +83,7 @@ main(void)
+ }
+
+ /* Check f = g*q + r for random polys */
+- for (i = 0; i < 50 * flint_test_multiplier(); i++)
++ for (i = 0; i < 5 * tmul * flint_test_multiplier(); i++)
+ {
+ fq_nmod_mpoly_ctx_t ctx;
+ fq_nmod_mpoly_t f, g, h, k, r;
+@@ -107,9 +108,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+@@ -141,7 +142,7 @@ main(void)
+ }
+
+ /* Check aliasing of quotient with first argument */
+- for (i = 0; i < 10 * flint_test_multiplier(); i++)
++ for (i = 0; i < tmul * flint_test_multiplier(); i++)
+ {
+ fq_nmod_mpoly_ctx_t ctx;
+ fq_nmod_mpoly_t f, g, h, r1, r2;
+@@ -166,9 +167,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -202,7 +203,7 @@ main(void)
+ }
+
+ /* Check aliasing of quotient with second argument */
+- for (i = 0; i < 10 * flint_test_multiplier(); i++)
++ for (i = 0; i < tmul * flint_test_multiplier(); i++)
+ {
+ fq_nmod_mpoly_ctx_t ctx;
+ fq_nmod_mpoly_t f, g, h, r1, r2;
+@@ -227,9 +228,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -262,7 +263,7 @@ main(void)
+ }
+
+ /* Check aliasing of remainder with first argument */
+- for (i = 0; i < 10 * flint_test_multiplier(); i++)
++ for (i = 0; i < tmul * flint_test_multiplier(); i++)
+ {
+ fq_nmod_mpoly_ctx_t ctx;
+ fq_nmod_mpoly_t f, g, h, k, r1;
+@@ -287,9 +288,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+@@ -351,9 +352,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ fq_nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ fq_nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+--- fq_nmod_mpoly/test/t-gcd_brown.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-gcd_brown.c 2020-07-08 15:42:31.619271605 -0600
+@@ -150,9 +150,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
+- } while (g->length == 0);
++ fq_nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(g, ctx))
++ fq_nmod_mpoly_one(g, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ fq_nmod_mpoly_mul(a, a, g, ctx);
+--- fq_nmod_mpoly/test/t-gcd.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-gcd.c 2020-07-08 15:42:31.619271605 -0600
+@@ -144,9 +144,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
+- } while (t->length != 1);
++ fq_nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bits(a, state, len1, exp_bits1, ctx);
+ fq_nmod_mpoly_randtest_bits(b, state, len2, exp_bits2, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -189,12 +189,13 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
+- } while (t1->length != 1);
+- do {
+- fq_nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
+- } while (t2->length != 1);
++ fq_nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
++ fq_nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
++ if (t1->length != 1 || t2->length != 1)
++ {
++ flint_printf("FAIL:\ncheck random monomial generation\n");
++ flint_abort();
++ }
+ fq_nmod_mpoly_randtest_bits(a, state, len1, exp_bits, ctx);
+ fq_nmod_mpoly_mul(b, a, t1, ctx);
+ fq_nmod_mpoly_mul(t2, a, t2, ctx);
+@@ -234,9 +235,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+
+@@ -279,9 +280,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -352,9 +353,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -431,9 +432,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -486,9 +487,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+
+@@ -571,9 +572,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+--- fq_nmod_mpoly/test/t-gcd_cofactors.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-gcd_cofactors.c 2020-07-08 15:42:31.620271605 -0600
+@@ -277,9 +277,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
+- } while (t->length != 1);
++ fq_nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bits(a, state, len1, exp_bits1, ctx);
+ fq_nmod_mpoly_randtest_bits(b, state, len2, exp_bits2, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -326,12 +326,13 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
+- } while (t1->length != 1);
+- do {
+- fq_nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
+- } while (t2->length != 1);
++ fq_nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
++ fq_nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
++ if (t1->length != 1 || t2->length != 1)
++ {
++ flint_printf("FAIL:\ncheck random monomial generation\n");
++ flint_abort();
++ }
+ fq_nmod_mpoly_randtest_bits(a, state, len1, exp_bits, ctx);
+ fq_nmod_mpoly_mul(b, a, t1, ctx);
+ fq_nmod_mpoly_mul(t2, a, t2, ctx);
+@@ -432,9 +433,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+
+@@ -481,9 +482,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -558,9 +559,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ fq_nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -641,9 +642,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+@@ -700,9 +701,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+
+@@ -789,9 +790,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ fq_nmod_mpoly_mul(a, a, t, ctx);
+--- fq_nmod_mpoly/test/t-gcd_zippel.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-gcd_zippel.c 2020-07-08 15:42:31.620271605 -0600
+@@ -61,9 +61,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- fq_nmod_mpoly_randtest_bounds(t, state, len, degbounds, ctx);
+- } while (t->length == 0);
++ fq_nmod_mpoly_randtest_bounds(t, state, len, degbounds, ctx);
++ if (fq_nmod_mpoly_is_zero(t, ctx))
++ fq_nmod_mpoly_one(t, ctx);
+ fq_nmod_mpoly_randtest_bounds(a, state, len1, degbounds1, ctx);
+ fq_nmod_mpoly_randtest_bounds(b, state, len2, degbounds2, ctx);
+
+--- fq_nmod_mpoly/test/t-get_set_term_coeff_fq_nmod.c.orig 2020-06-05 09:22:08.000000000
-0600
++++ fq_nmod_mpoly/test/t-get_set_term_coeff_fq_nmod.c 2020-07-08 15:42:31.620271605
-0600
+@@ -38,9 +38,9 @@ main(void)
+
+ len = n_randint(state, 100) + 1;
+ exp_bits = n_randint(state, 200) + 1;
+- do {
+- fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (fq_nmod_mpoly_length(f, ctx) == 0);
++ fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(f, ctx))
++ fq_nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
+--- fq_nmod_mpoly/test/t-get_set_term_exp_fmpz.c.orig 2020-06-05 09:22:08.000000000
-0600
++++ fq_nmod_mpoly/test/t-get_set_term_exp_fmpz.c 2020-07-08 15:42:31.621271605 -0600
+@@ -39,9 +39,9 @@ main(void)
+ len = n_randint(state, 50) + 1;
+ exp_bits = n_randint(state, 100) + 1;
+
+- do {
+- fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (fq_nmod_mpoly_length(f, ctx) == 0);
++ fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(f, ctx))
++ fq_nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
+--- fq_nmod_mpoly/test/t-get_set_term_exp_si.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-get_set_term_exp_si.c 2020-07-08 15:42:31.621271605 -0600
+@@ -39,9 +39,9 @@ main(void)
+ len = n_randint(state, 50) + 1;
+ exp_bits = n_randint(state, 200) + 2;
+
+- do {
+- fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (fq_nmod_mpoly_length(f, ctx) == 0);
++ fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(f, ctx))
++ fq_nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
+--- fq_nmod_mpoly/test/t-get_set_term_exp_ui.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ fq_nmod_mpoly/test/t-get_set_term_exp_ui.c 2020-07-08 15:42:31.621271605 -0600
+@@ -39,9 +39,9 @@ main(void)
+ len = n_randint(state, 50) + 1;
+ exp_bits = n_randint(state, 100) + 2;
+
+- do {
+- fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (fq_nmod_mpoly_length(f, ctx) == 0);
++ fq_nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (fq_nmod_mpoly_is_zero(f, ctx))
++ fq_nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
+--- nmod_mpoly/randtest_bits.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/randtest_bits.c 2020-07-08 15:42:31.622271605 -0600
+@@ -14,6 +14,7 @@
+ void nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state,
+ slong length, flint_bitcnt_t exp_bits, const nmod_mpoly_ctx_t ctx)
+ {
++ mp_limb_t p = ctx->ffinfo->mod.n;
+ slong i, j, nvars = ctx->minfo->nvars;
+ fmpz * exp;
+ TMP_INIT;
+@@ -29,7 +30,7 @@ void nmod_mpoly_randtest_bits(nmod_mpoly
+ {
+ mpoly_monomial_randbits_fmpz(exp, state, exp_bits, ctx->minfo);
+ _nmod_mpoly_push_exp_ffmpz(A, exp, ctx);
+- A->coeffs[A->length - 1] = n_randint(state, ctx->ffinfo->mod.n);
++ A->coeffs[A->length - 1] = p > 1 ? 1 + n_randint(state, p - 1) : 0;
+ }
+ nmod_mpoly_sort_terms(A, ctx);
+ nmod_mpoly_combine_like_terms(A, ctx);
+--- nmod_mpoly/randtest_bound.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/randtest_bound.c 2020-07-08 15:42:31.622271605 -0600
+@@ -14,6 +14,7 @@
+ void nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state,
+ slong length, ulong exp_bound, const nmod_mpoly_ctx_t ctx)
+ {
++ mp_limb_t p = ctx->ffinfo->mod.n;
+ slong i, j, nvars = ctx->minfo->nvars;
+ ulong * exp;
+ TMP_INIT;
+@@ -26,9 +27,8 @@ void nmod_mpoly_randtest_bound(nmod_mpol
+ {
+ for (j = 0; j < nvars; j++)
+ exp[j] = n_randint(state, exp_bound);
+-
+ _nmod_mpoly_push_exp_ui(A, exp, ctx);
+- A->coeffs[A->length - 1] = n_randint(state, ctx->ffinfo->mod.n);
++ A->coeffs[A->length - 1] = p > 1 ? 1 + n_randint(state, p - 1) : 0;
+ }
+ nmod_mpoly_sort_terms(A, ctx);
+ nmod_mpoly_combine_like_terms(A, ctx);
+--- nmod_mpoly/randtest_bounds.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/randtest_bounds.c 2020-07-08 15:42:31.622271605 -0600
+@@ -14,6 +14,7 @@
+ void nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state,
+ slong length, ulong * exp_bounds, const nmod_mpoly_ctx_t ctx)
+ {
++ mp_limb_t p = ctx->ffinfo->mod.n;
+ slong i, j, nvars = ctx->minfo->nvars;
+ ulong * exp;
+ TMP_INIT;
+@@ -26,9 +27,8 @@ void nmod_mpoly_randtest_bounds(nmod_mpo
+ {
+ for (j = 0; j < nvars; j++)
+ exp[j] = n_randint(state, exp_bounds[j]);
+-
+ _nmod_mpoly_push_exp_ui(A, exp, ctx);
+- A->coeffs[A->length - 1] = n_randint(state, ctx->ffinfo->mod.n);
++ A->coeffs[A->length - 1] = p > 1 ? 1 + n_randint(state, p - 1) : 0;
+ }
+ nmod_mpoly_sort_terms(A, ctx);
+ nmod_mpoly_combine_like_terms(A, ctx);
+--- nmod_mpoly/test/t-div.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-div.c 2020-07-08 15:42:31.622271605 -0600
+@@ -87,9 +87,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(l, state, len, exp_bits, ctx);
+@@ -184,9 +184,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(q, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(r, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+--- nmod_mpoly/test/t-divides.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divides.c 2020-07-08 15:42:31.623271605 -0600
+@@ -58,9 +58,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2 + 1, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2 + 1, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+
+@@ -140,9 +140,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -220,9 +220,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -303,9 +303,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -377,9 +377,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+--- nmod_mpoly/test/t-divides_dense.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divides_dense.c 2020-07-08 15:42:31.623271605 -0600
+@@ -60,9 +60,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -131,9 +131,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -201,9 +201,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+@@ -273,9 +273,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bounds(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bounds(g, state, len2 + 1, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bounds(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bounds(k, state, len, exp_bound, ctx);
+
+--- nmod_mpoly/test/t-divides_heap_threaded.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divides_heap_threaded.c 2020-07-08 15:42:31.624271605 -0600
+@@ -99,9 +99,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+
+@@ -158,9 +158,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+
+ flint_set_num_threads(n_randint(state, max_threads) + 1);
+@@ -215,9 +215,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+
+ flint_set_num_threads(n_randint(state, max_threads) + 1);
+@@ -274,9 +274,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(p, state, len3, exp_bound3, ctx);
+
+ flint_set_num_threads(n_randint(state, max_threads) + 1);
+@@ -336,9 +336,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(p, state, len3, exp_bound3, ctx);
+
+ flint_set_num_threads(n_randint(state, max_threads) + 1);
+@@ -397,9 +397,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(p, state, len3, exp_bound3, ctx);
+
+ flint_set_num_threads(n_randint(state, max_threads) + 1);
+--- nmod_mpoly/test/t-divides_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divides_monagan_pearce.c 2020-07-08 15:42:31.624271605 -0600
+@@ -53,9 +53,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+
+@@ -113,9 +113,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+@@ -179,9 +179,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (nmod_mpoly_is_zero(g, ctx));
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+
+@@ -243,9 +243,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+
+ ok1 = nmod_mpoly_divides_monagan_pearce(h, f, g, ctx);
+@@ -304,9 +304,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bits(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+
+@@ -368,9 +368,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+
+ ok1 = nmod_mpoly_divides_monagan_pearce(h, f, g, ctx);
+--- nmod_mpoly/test/t-div_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-div_monagan_pearce.c 2020-07-08 15:42:31.623271605 -0600
+@@ -53,9 +53,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(l, state, len, exp_bits, ctx);
+@@ -133,9 +133,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(q, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+--- nmod_mpoly/test/t-divrem.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divrem.c 2020-07-08 15:42:31.625271605 -0600
+@@ -57,9 +57,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(r, state, len, exp_bits, ctx);
+@@ -124,9 +124,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+@@ -191,9 +191,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -259,9 +259,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -326,9 +326,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+@@ -397,9 +397,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+--- nmod_mpoly/test/t-divrem_ideal.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divrem_ideal.c 2020-07-08 15:42:31.625271605 -0600
+@@ -58,9 +58,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bits2 + 1, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bits2 + 1, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bound(r, state, len, exp_bits, ctx);
+@@ -158,9 +158,9 @@ main(void)
+ nmod_mpoly_inflate(f, f, shifts, strides, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1, ctx);
++ if (nmod_mpoly_is_zero(darr[w], ctx))
++ nmod_mpoly_one(darr[w], ctx);
+ nmod_mpoly_inflate(darr[w], darr[w], shifts, strides, ctx);
+ nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+@@ -267,9 +267,9 @@ main(void)
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1, ctx);
++ if (nmod_mpoly_is_zero(darr[w], ctx))
++ nmod_mpoly_one(darr[w], ctx);
+ nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+ nmod_mpoly_randtest_bound(k1, state, len, exp_bound, ctx);
+--- nmod_mpoly/test/t-divrem_ideal_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000
-0600
++++ nmod_mpoly/test/t-divrem_ideal_monagan_pearce.c 2020-07-08 15:42:31.625271605 -0600
+@@ -64,9 +64,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2 + 1, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2 + 1, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r, state, len, exp_bound, ctx);
+@@ -151,9 +151,9 @@ main(void)
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1, ctx);
++ if (nmod_mpoly_is_zero(darr[w], ctx))
++ nmod_mpoly_one(darr[w], ctx);
+ nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+ nmod_mpoly_randtest_bound(k1, state, len, exp_bound, ctx);
+@@ -251,9 +251,9 @@ main(void)
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+ for (w = 0; w < num; w++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1,
ctx);
+- } while (darr[w]->length == 0);
++ nmod_mpoly_randtest_bound(darr[w], state, len2, exp_bound2 + 1, ctx);
++ if (nmod_mpoly_is_zero(darr[w], ctx))
++ nmod_mpoly_one(darr[w], ctx);
+ nmod_mpoly_randtest_bound(qarr[w], state, len, exp_bound, ctx);
+ }
+ nmod_mpoly_randtest_bound(k1, state, len, exp_bound, ctx);
+--- nmod_mpoly/test/t-divrem_monagan_pearce.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-divrem_monagan_pearce.c 2020-07-08 15:42:31.626271605 -0600
+@@ -57,9 +57,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bits(f, state, len1, exp_bits1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bits2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bits(h, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(k, state, len, exp_bits, ctx);
+ nmod_mpoly_randtest_bits(r, state, len, exp_bits, ctx);
+@@ -124,9 +124,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+
+@@ -191,9 +191,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -259,9 +259,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r2, state, len, exp_bound, ctx);
+@@ -326,9 +326,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+@@ -397,9 +397,9 @@ main(void)
+ for (j = 0; j < 4; j++)
+ {
+ nmod_mpoly_randtest_bound(f, state, len1, exp_bound1, ctx);
+- do {
+- nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len2, exp_bound2, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(h, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(k, state, len, exp_bound, ctx);
+ nmod_mpoly_randtest_bound(r1, state, len, exp_bound, ctx);
+--- nmod_mpoly/test/t-gcd_brown.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-gcd_brown.c 2020-07-08 15:42:31.627271604 -0600
+@@ -27,6 +27,8 @@ void gcd_check(
+ nmod_mpoly_init(cb, ctx);
+ nmod_mpoly_init(cg, ctx);
+
++ nmod_mpoly_assert_canonical(a, ctx);
++ nmod_mpoly_assert_canonical(b, ctx);
+ res = nmod_mpoly_gcd_brown(g, a, b, ctx);
+ nmod_mpoly_assert_canonical(g, ctx);
+
+@@ -68,6 +70,8 @@ void gcd_check(
+ flint_abort();
+ }
+
++ nmod_mpoly_assert_canonical(ca, ctx);
++ nmod_mpoly_assert_canonical(cb, ctx);
+ res = nmod_mpoly_gcd_brown(cg, ca, cb, ctx);
+ nmod_mpoly_assert_canonical(cg, ctx);
+
+@@ -131,9 +135,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, g, ctx);
+--- nmod_mpoly/test/t-gcd_brown_threaded.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-gcd_brown_threaded.c 2020-07-08 15:42:31.627271604 -0600
+@@ -159,9 +159,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, g, ctx);
+@@ -205,9 +205,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
+- } while (g->length == 0);
++ nmod_mpoly_randtest_bound(g, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(g, ctx))
++ nmod_mpoly_one(g, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, g, ctx);
+--- nmod_mpoly/test/t-gcd.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-gcd.c 2020-07-08 15:42:31.626271605 -0600
+@@ -256,9 +256,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
+- } while (t->length != 1);
++ nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bits(a, state, len1, exp_bits1, ctx);
+ nmod_mpoly_randtest_bits(b, state, len2, exp_bits2, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -307,12 +307,13 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
+- } while (t1->length != 1);
+- do {
+- nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
+- } while (t2->length != 1);
++ nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
++ nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
++ if (t1->length != 1 || t2->length != 1)
++ {
++ flint_printf("FAIL:\ncheck random monomial generation\n");
++ flint_abort();
++ }
+ nmod_mpoly_randtest_bits(a, state, len1, exp_bits, ctx);
+ nmod_mpoly_mul(b, a, t1, ctx);
+ nmod_mpoly_mul(a, a, t2, ctx);
+@@ -416,9 +417,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+
+@@ -467,9 +468,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -546,9 +547,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -624,9 +625,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -685,9 +686,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -775,9 +776,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+--- nmod_mpoly/test/t-gcd_cofactors.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-gcd_cofactors.c 2020-07-08 15:42:31.628271605 -0600
+@@ -400,9 +400,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
+- } while (t->length != 1);
++ nmod_mpoly_randtest_bits(t, state, 1, exp_bits, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bits(a, state, len1, exp_bits1, ctx);
+ nmod_mpoly_randtest_bits(b, state, len2, exp_bits2, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -455,12 +455,18 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
+- } while (t1->length != 1);
+- do {
+- nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
+- } while (t2->length != 1);
++ nmod_mpoly_randtest_bits(t1, state, 1, exp_bits1, ctx);
++ nmod_mpoly_randtest_bits(t2, state, 1, exp_bits2, ctx);
++ if (t1->length != 1 || t2->length != 1)
++ {
++flint_printf("exp_bits1: %wu\n", exp_bits1);
++flint_printf("exp_bits2: %wu\n", exp_bits2);
++flint_printf("t1: "); nmod_mpoly_print_pretty(t1, NULL, ctx);
flint_printf("\n");
++flint_printf("t2: "); nmod_mpoly_print_pretty(t2, NULL, ctx);
flint_printf("\n");
++
++ flint_printf("FAIL:\ncheck random monomial generation\n");
++ flint_abort();
++ }
+ nmod_mpoly_randtest_bits(a, state, len1, exp_bits, ctx);
+ nmod_mpoly_mul(b, a, t1, ctx);
+ nmod_mpoly_mul(t2, a, t2, ctx);
+@@ -573,9 +579,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -628,9 +634,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -712,9 +718,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bound(t, state, len, degbound, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bound(a, state, len1, degbound, ctx);
+ nmod_mpoly_randtest_bound(b, state, len2, degbound, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -802,9 +808,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -868,9 +874,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+@@ -963,9 +969,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len1, degbounds1, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len2, degbounds2, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len3, degbounds3, ctx);
+ nmod_mpoly_mul(a, a, t, ctx);
+--- nmod_mpoly/test/t-gcd_zippel.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-gcd_zippel.c 2020-07-08 15:42:31.628271605 -0600
+@@ -61,9 +61,9 @@ main(void)
+
+ for (j = 0; j < 4; j++)
+ {
+- do {
+- nmod_mpoly_randtest_bounds(t, state, len, degbounds, ctx);
+- } while (t->length == 0);
++ nmod_mpoly_randtest_bounds(t, state, len, degbounds, ctx);
++ if (nmod_mpoly_is_zero(t, ctx))
++ nmod_mpoly_one(t, ctx);
+ nmod_mpoly_randtest_bounds(a, state, len1, degbounds1, ctx);
+ nmod_mpoly_randtest_bounds(b, state, len2, degbounds2, ctx);
+
+--- nmod_mpoly/test/t-get_set_term_exp_si.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-get_set_term_exp_si.c 2020-07-08 15:42:31.628271605 -0600
+@@ -42,9 +42,9 @@ main(void)
+ len = n_randint(state, 50) + 1;
+ exp_bits = n_randint(state, 200) + 2;
+
+- do {
+- nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (nmod_mpoly_length(f, ctx) == 0);
++ nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (nmod_mpoly_is_zero(f, ctx))
++ nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
+--- nmod_mpoly/test/t-get_set_term_exp_ui.c.orig 2020-06-05 09:22:08.000000000 -0600
++++ nmod_mpoly/test/t-get_set_term_exp_ui.c 2020-07-08 15:42:31.628271605 -0600
+@@ -42,9 +42,9 @@ main(void)
+ len = n_randint(state, 50) + 1;
+ exp_bits = n_randint(state, 100) + 2;
+
+- do {
+- nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
+- } while (nmod_mpoly_length(f, ctx) == 0);
++ nmod_mpoly_randtest_bits(f, state, len, exp_bits, ctx);
++ if (nmod_mpoly_is_zero(f, ctx))
++ nmod_mpoly_one(f, ctx);
+
+ for (j = 0; j < 10; j++)
+ {
diff --git a/flint.spec b/flint.spec
index 265ad31..7433319 100644
--- a/flint.spec
+++ b/flint.spec
@@ -21,6 +21,25 @@ Patch0: %{name}-hmod_mat.patch
Patch1: %{name}-popcnt.patch
# Adapt to recent LaTeX encoding changes
Patch2: %{name}-latex.patch
+# Fix fmpq_poly_add_fmpq with polynomials of degree 1
+#
https://github.com/wbhart/flint2/pull/766
+Patch3: %{name}-fmpq-poly-add-fmpq.patch
+# Fix possible infinite loop in nmod_mpolyn_interp_crt_lg_poly
+#
https://github.com/wbhart/flint2/issues/784
+#
https://github.com/wbhart/flint2/commit/6dd9f22ac7dd58056ad65e353ef7ed272...
+Patch4: %{name}-nmod-mpolyn-interp-crt-lg-poly.patch
+# Fix possible SIGBUS in fmpz_mpoly_div_monagan_pearce
+#
https://github.com/wbhart/flint2/issues/785
+#
https://github.com/wbhart/flint2/commit/c300499ec13e1bed5f47596658ad99b3d...
+Patch5: %{name}-fmpz-mpoly-div-monagan-pearce.patch
+# Fix a bug in fmpz_poly_factor
+#
https://github.com/wbhart/flint2/issues/783
+#
https://github.com/wbhart/flint2/commit/5010d74dd50d016db6b55a5e7772f07eb...
+Patch6: %{name}-fmpz-poly-factor.patch
+# Fix a bug in fmpz_mod_poly_gcdiv_euclidean
+#
https://github.com/wbhart/flint2/commit/499d027dc0e377cd55bedf1b1f7e2bc5e...
+Patch7: %{name}-fmpz-mod-poly-gcdiv-euclidean.patch
+
BuildRequires: gcc-c++
BuildRequires: gmp-devel
@@ -190,12 +209,16 @@ cp -p qadic/CPimport.txt %{buildroot}%{_datadir}/flint
popd
+%ifnarch %{arm}
+# Tests temporarily disabled on ARM.
+# See
https://github.com/wbhart/flint2/issues/786
%check
pushd %{name}-%{version}
export LD_LIBRARY_PATH=$PWD
make check QUIET_CC= QUIET_CXX= QUIET_AR= \
LDFLAGS="%{build_ldflags}" LIBDIR=%{_lib}
popd
+%endif
%files
@@ -224,6 +247,11 @@ popd
%changelog
* Wed Jul 8 2020 Jerry James <loganjerry(a)gmail.com> - 2.6.0-1
- Version 2.6.0
+- Add upstream patches to fix bugs discovered after release:
+ -fmpq-poly-add-fmpq.patch, -nmod-mpolyn-interp-crt-lg-poly.patch,
+ -fmpz-mpoly-div-monagan-pearce.patch, -fmpz-poly-factor.patch,
+ -fmpz-mod-poly-gcdiv-euclidean.patch
+- Disable tests on 32-bit ARM until upstream can diagnose a failure
* Tue Jan 28 2020 Fedora Release Engineering <releng(a)fedoraproject.org> - 2.5.2-31
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild