Mod poly and mpn_mod random generation - #2448
Conversation
I think you need to rebase on main and force-push to get a clean diff. |
c1be23c to
ba6af38
Compare
|
I cancelled the CI workflow because they were still in testing after almost 4 hours. Please review the code carefully to see what changes to existing functions could have led to this, thanks! (I pointed at some modifications in my comments, but there may be others) |
|
There is probably an infinite loop, I'll do a manual bisect. |
The randtest functions are using `randm` which generates positive coefficients in [0, m) range with m the modulus given by the context. The documentation told that the coefficients are randomly signed, so I fixed that. I introduced a `randm_nonzero` function in fmpz to ensure that coefficients are nonzero and replaced all occurences of `randm` in `fmpz_mod_poly_randtest` functions by this new function. Apart from the `rand` function, this introduces a `rand_monic` and a `rand_irreducible` function.
I added _fmpz_mod_vec_rand with the intent to use it in _mpn_mod_vec_rand but did not use it in the end. This reverts commit f98e52c.
21ee353 to
59f5c7d
Compare
|
The tests halt indefinitely after |
|
Ok, I guess that if a polynomial has nonzero coefficients, it is irreducible with much less probability. This could slow down the tests. I should indeed give up on a "randfull-like" functionality for fmpz_mod_poly_randtest functions but then what would be the point of making another |
This is likely indeed. I haven't looked closely at the test files and the one that is failing, but let's suppose that some test includes working modulo 2, then the new randtest using
In my last batch of comments, you can see that I suggest using |
f5b0816 to
eafe4cf
Compare
|
I changed randm_non_zero t to randtest calls. I gave one extra bit for the random generation before taking the modulus. If you think it is not necessary, I will remove it. |
|
Hello, sorry for not making quickly the last modifications needed to close this PR.
Is this still actual? I can't remember if I did this change. I'll look into it tomorrow. Pay attention to the previous commit. I remove an invocation to fmpz_bits. It apparently fixes a segfault, but I am not sure why it was invocated in the first place. Could you check out for this during review? Otherwise, I made two changes:
|
|
Here is a first batch of comments, on the documentation. |
Yes, your change is fine, and I agree this was an extraneous invocation that was probably added by mistake. |
change nonzero to not_zero for naming uniformisation Co-authored-by: Vincent Neiger <vneiger@users.noreply.github.com> Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com>
Co-authored-by: Vincent Neiger <vneiger@users.noreply.github.com> Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com>
Co-authored-by: Vincent Neiger <vneiger@users.noreply.github.com> Co-authored-by: Dimitri Lesnoff <54949944+dlesnoff@users.noreply.github.com>
vneiger
left a comment
There was a problem hiding this comment.
This looks good to me, thanks!
Follow-up of #2430 .
Adds uniformly distributed
randfunction for the following structures:It seems that implementations of nmod_mpoly
randtestfunctions generate uniformly random coefficients.I did not add
randfunctions for basic types like fmpz_mod nor nmod.Future changes:
randfunction formpn_mod_polyandmpn_mod_mat.