-
Notifications
You must be signed in to change notification settings - Fork 245
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
Correct FQ_DEFAULT_TYPE comparison in evaluation #2047
Correct FQ_DEFAULT_TYPE comparison in evaluation #2047
Conversation
Thanks, looks good! Do you agree @fredrik-johansson? |
I don't know if I need to add tests to show that this is fixed? I've not contributed to flint before -- this was identified while working on python-flint. |
Yes, it would be good with a test. Could you implement one? The tests are under |
1427162
to
93ad013
Compare
OK -- I had a few silly bugs along the way, but I think I now have a semi-decent check for all 5 fq_default types in place. |
93ad013
to
f4783b0
Compare
Thanks for the commit! A couple of comments:
|
The actual test was copied from an exiting one: flint/src/fmpz_mod_poly/test/t-evaluate_fmpz.c Lines 43 to 46 in 05340d2
I can change this is you want, I just did what already existed. I can randomise the type, but the idea was to ensure all 5 types were always captured. If you would prefer I can use the |
Oh... Apparently https://flintlib.org/doc/fq_default.html#c.fq_default_ctx_randtest is in the documentation but not in the code? Should an issue be made for this? |
You only copied parts of that test. That part only checks aliasing, not other mathematical consistencies.
It is better with randomization as you can change seeds etc. All types will be covered given large enough test multipliers.
Given that |
fmpz_init(p); | ||
|
||
/* Repeat the whole test 10 times to capture different degrees */ | ||
for (i = 0; i < 10; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert test multiplier here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I purposefully didn't because the multiplier is in the inner test function. Would you like it here too? I was worried about having this multiplier squared would be an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it in, feel free to ask me to remove it again
k = n_randint(state, 12); | ||
fmpz_set_ui(p, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that you are only able to capture bugs for cases on the form
But be careful here since the fq_zech
type does not like when you go big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For FQ_ZECH and FQ_NMOD I have two tests likely to pick each of these but allow fq_default to automatically select between these to avoid needing to be precise about when to use one or the other. Hopefully you are ok with what i have picked
did you need anything else from me for this PR? |
Sorry for the delay. Will respond in a couple of days. |
Does it no longer check aliasing? |
I'm not sure I understand |
We usually check aliasing, such as |
You want the evaluation to check aliasing then? I can do this if you want I didn't intentionally add or remove anything though. Is the current test not sufficient? |
Since it was in the previous commit (and contained in similar tests), I would very much like that!
Don't worry, didn't cross my mind.
Well, it should work (since it is inherited from |
/* Evaluate the polynomials f1, f2, f3 = f1 * f2 on the element a */
fq_default_poly_evaluate_fq_default(c, f3, a, ctx);
fq_default_poly_evaluate_fq_default(b, f2, a, ctx);
fq_default_poly_evaluate_fq_default(a, f1, a, ctx); this code is currently in place, it doesn't quite check that fq_default_poly_evaluate_fq_default(c, f1, a, ctx);
fq_default_poly_evaluate_fq_default(a, f1, a, ctx);
fq_default_equal(a, c, ctx); But it implicitly checks this as it computes |
My bad. Yes, looks good! Will wait until Fredrik comes back from his vacation to see if he has any more opinions. |
Should be fine to merge after streamlining the test code on top of #2050. |
Sorry for the delay in this, the new test is cleaner and uses the random context method from my other PR |
The method
fq_default_poly_evaluate_fq_default()
had an incorrect comparison for the default type, which lead to a segfault when using this method with typefmpz_mod
.This PR should fix the issue and hence fix #2046