-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add more setcoeff!
methods and use them to deduplicate PolyRingElem constructors
#1911
base: master
Are you sure you want to change the base?
Conversation
8181398
to
1950466
Compare
3a67681
to
ce53c5c
Compare
ce53c5c
to
3f86479
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1911 +/- ##
==========================================
- Coverage 87.98% 87.95% -0.03%
==========================================
Files 99 99
Lines 36464 36279 -185
==========================================
- Hits 32082 31911 -171
+ Misses 4382 4368 -14 ☔ View full report in Codecov by Sentry. |
This now implements option 2 of the initial message. |
Sorry I didn't realize this was waiting for feedback from me :-(. Option 2 sounds fine to me. Not even sure we need / want to go to option 1, but as you say, option 2 would be a somewhat natural stepping stone towards that as well. |
return x | ||
# | ||
|
||
function setcoeff!(z::T, i::Int, x::ZZRingElemOrPtr, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) where T <: Zmodn_fmpz_poly |
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.
Should ctx
be another (fourth) argument or a kwarg?
The advantage of a kwarg is that it helps understanding what's going on, esp. in the cases were ctx
is another integer. If I see set!(z, 3, c, R)
it is somewhat more opaque than set!(z, 3, c; ctx=R)
.
Alas, in the end, all of these are low-level unsafe helpers. I can happily live with either variant.
Unfortunately this won't work as I try to access attributes/parents of elements in
setcoeff!
before they are set.I see two ways to resolve this issue:
setcoeff!
gets an optional fourth argument, that is aUInt
fornmod_poly
-based types and afmpz_mod_ctx_struct
forfmpz_mod_poly
-based types. If this fourth argument is not passed, we can reconstruct it (in many cases, but not inside of the constructors as parents are not available).I would tend to 2 for now, and maybe remove this fourth argument again once 1 has made enough progress. What do you think @fingolfin ?