Skip to content

Commit

Permalink
Merge pull request flintlib#2114 from thofma/th/nmodmpoly
Browse files Browse the repository at this point in the history
fix: nmod_mpoly with modulus 1
  • Loading branch information
albinahlback authored Nov 24, 2024
2 parents a8f9854 + 14c1be8 commit 487785c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/nmod_mpoly/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ void nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx)
{
flint_bitcnt_t bits;

if (ctx->mod.n == UWORD(1))
{
nmod_mpoly_zero(A, ctx);
return;
}

bits = mpoly_gen_bits_required(var, ctx->minfo);
bits = mpoly_fix_bits(bits, ctx->minfo);
nmod_mpoly_fit_length_reset_bits(A, 1, bits, ctx);
Expand Down
3 changes: 3 additions & 0 deletions src/nmod_mpoly/is_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
int nmod_mpoly_is_gen(const nmod_mpoly_t A,
slong var, const nmod_mpoly_ctx_t ctx)
{
if (ctx->mod.n == UWORD(1))
return 1;

if (A->length != WORD(1))
return 0;

Expand Down
2 changes: 1 addition & 1 deletion src/nmod_mpoly/test/t-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST_FUNCTION_START(nmod_mpoly_gen, state)
slong len, exp_bits, k1, k2;
ulong modulus;

modulus = UWORD(2) + n_randint(state, -UWORD(2));
modulus = UWORD(1) + n_randint(state, -UWORD(2));
nmod_mpoly_ctx_init_rand(ctx, state, 20, modulus);
if (ctx->minfo->nvars < 1)
{
Expand Down

0 comments on commit 487785c

Please sign in to comment.