Skip to content

Commit

Permalink
Use random primes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Moss committed Oct 1, 2024
1 parent 775d319 commit 0926c48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/fmpz_mod_mpoly/test/t-compose_fmpz_mod_mpoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ TEST_FUNCTION_START(fmpz_mod_mpoly_compose, state)
fmpz_mod_mpoly_ctx_t ctxAC, ctxB;
slong * c;

fmpz_init_set_ui(p, 13);
fmpz_init(p);
fmpz_randprime(p, state, n_randint(state, 15) + 2, 0);
fmpz_mod_mpoly_ctx_init(ctxB, nvarsB, ORD_LEX, p);
fmpz_mod_mpoly_ctx_init(ctxAC, nvarsAC, ORD_LEX, p);

Expand Down Expand Up @@ -132,7 +133,8 @@ TEST_FUNCTION_START(fmpz_mod_mpoly_compose, state)
slong len;
flint_bitcnt_t exp_bits;

fmpz_init_set_ui(p, 13);
fmpz_init(p);
fmpz_randprime(p, state, n_randint(state, 15) + 2, 0);
fmpz_mod_mpoly_ctx_init_rand(ctxB, state, 20, p);
fmpz_mod_mpoly_ctx_init_rand(ctxAC, state, 20, p);

Expand Down Expand Up @@ -217,7 +219,8 @@ TEST_FUNCTION_START(fmpz_mod_mpoly_compose, state)
fmpz_mod_mpoly_t f, g, g1, g2;
fmpz_mod_mpoly_ctx_t ctx;

fmpz_init_set_ui(p, 13);
fmpz_init(p);
fmpz_randprime(p, state, n_randint(state, 15) + 2, 0);
fmpz_mod_mpoly_ctx_init_rand(ctx, state, 10, p);

vals1 = (fmpz_mod_mpoly_struct **) flint_malloc(ctx->minfo->nvars*
Expand Down Expand Up @@ -280,7 +283,8 @@ TEST_FUNCTION_START(fmpz_mod_mpoly_compose, state)
slong len1, len2;
slong exp_bound1, exp_bound2;

fmpz_init_set_ui(p, 13);
fmpz_init(p);
fmpz_randprime(p, state, n_randint(state, 15) + 2, 0);
fmpz_mod_mpoly_ctx_init_rand(ctx1, state, 6, p);
fmpz_mod_mpoly_ctx_init_rand(ctx2, state, 6, p);

Expand Down
7 changes: 5 additions & 2 deletions src/nmod_mpoly/test/t-compose_nmod_mpoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ TEST_FUNCTION_START(nmod_mpoly_compose_nmod_mpoly, state)
nmod_mpoly_struct C[3];
nmod_mpoly_ctx_t ctxAC, ctxB;
slong * c;
ulong modulus;

nmod_mpoly_ctx_init(ctxB, nvarsB, ORD_LEX, 13);
nmod_mpoly_ctx_init(ctxAC, nvarsAC, ORD_LEX, 13);
modulus = n_randint(state, FLINT_BITS - 1) + 1;
modulus = n_randbits(state, modulus);
nmod_mpoly_ctx_init(ctxB, nvarsB, ORD_LEX, modulus);
nmod_mpoly_ctx_init(ctxAC, nvarsAC, ORD_LEX, modulus);

nmod_mpoly_init(B, ctxB);
nmod_mpoly_init(A, ctxAC);
Expand Down

0 comments on commit 0926c48

Please sign in to comment.