Skip to content

Commit

Permalink
Fix a bug in fmpz_mod_poly_gcdiv_euclidean, triggered by a new test in
Browse files Browse the repository at this point in the history
fq_poly (xgcd_euclidean).
  • Loading branch information
wbhart committed Jul 7, 2020
1 parent 7628a8e commit 499d027
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions fmpz_mod_poly/gcdinv_euclidean.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S,
_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);

Expand Down Expand Up @@ -129,6 +135,12 @@ slong _fmpz_mod_poly_gcdinv_euclidean(fmpz *G, fmpz *S,
_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);

Expand Down
8 changes: 4 additions & 4 deletions fq_poly_templates/test/t-xgcd_euclidean_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 499d027

Please sign in to comment.