Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset nmod_poly_factor_t before writing to it #1603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/nmod_poly_factor/factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,23 @@
nmod_poly_factor_with_berlekamp(nmod_poly_factor_t result,
const nmod_poly_t input)
{
result->num = 0;
return __nmod_poly_factor_deflation(result, input, BERLEKAMP);
}

mp_limb_t
nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t result,
const nmod_poly_t input)
{
result->num = 0;
return __nmod_poly_factor_deflation(result, input, ZASSENHAUS);
}

mp_limb_t
nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t result,
const nmod_poly_t input)
{
result->num = 0;

Check warning on line 173 in src/nmod_poly_factor/factor.c

View check run for this annotation

Codecov / codecov/patch

src/nmod_poly_factor/factor.c#L173

Added line #L173 was not covered by tests
return __nmod_poly_factor_deflation(result, input, KALTOFEN);
}

Expand Down
2 changes: 2 additions & 0 deletions src/nmod_poly_factor/factor_cantor_zassenhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f)

nmod_poly_make_monic(v, f);

res->num = 0;

i = 0;
do
{
Expand Down
2 changes: 2 additions & 0 deletions src/nmod_poly_factor/factor_distinct_deg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res,

nmod_poly_make_monic(v, poly);

res->num = 0;

if (n == 1)
{
nmod_poly_factor_insert(res, v, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/nmod_poly_factor/factor_distinct_deg_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res,

nmod_poly_make_monic(v, poly);

res->num = 0;

if (n == 1)
{
nmod_poly_factor_insert(res, v, 1);
Expand Down
8 changes: 4 additions & 4 deletions src/nmod_poly_factor/factor_kaltofen_shoup.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res,
{
nmod_poly_t v;
nmod_poly_factor_t sq_free, dist_deg;
slong i, j, k, l, res_num, dist_deg_num;
slong i, j, k, l, res_num;
slong * degs;

nmod_poly_init_mod(v, poly->mod);

nmod_poly_make_monic(v, poly);

res->num = 0;

if (poly->length <= 2)
{
nmod_poly_factor_insert (res, v, 1);
Expand All @@ -48,8 +50,6 @@ void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res,
nmod_poly_factor_init(dist_deg);
for (i = 0; i < sq_free->num; i++)
{
dist_deg_num = dist_deg->num;

if ((flint_get_num_threads() > 1) &&
((sq_free->p + i)->length > (1024*flint_get_num_threads())/4))
nmod_poly_factor_distinct_deg_threaded(dist_deg, sq_free->p + i,
Expand All @@ -58,7 +58,7 @@ void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res,
nmod_poly_factor_distinct_deg(dist_deg, sq_free->p + i, &degs);

/* compute equal-degree factorisation */
for (j = dist_deg_num, l = 0; j < dist_deg->num; j++, l++)
for (j = 0, l = 0; j < dist_deg->num; j++, l++)
{
res_num = res->num;

Expand Down
3 changes: 2 additions & 1 deletion src/nmod_poly_factor/factor_squarefree.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f)
mp_limb_t p;
slong deg, i;

res->num = 0;

if (f->length <= 1)
{
res->num = 0;
return;
}

Expand Down