-
Notifications
You must be signed in to change notification settings - Fork 58
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 optimized is_trivial methods for zzModRing and ZZModRing #1949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,13 +56,15 @@ | |
|
||
modulus(R::zzModRing) = R.n | ||
|
||
characteristic(R::zzModRing) = ZZRingElem(modulus(R)) | ||
|
||
is_trivial(a::zzModRing) = is_unit(modulus(a)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you use is_unit here but is_one in the other file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is_unit is mathematically correct. here it gets optimized to just checking for one as the modulus is unsigned . for the ZZ case using isone is an optimization to save 1 or 2 machine instructions checking for -1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok. thanks for the explanation |
||
|
||
function deepcopy_internal(a::zzModRingElem, dict::IdDict) | ||
R = parent(a) | ||
return zzModRingElem(deepcopy(a.data), R) | ||
end | ||
|
||
characteristic(R::zzModRing) = ZZRingElem(modulus(R)) | ||
|
||
############################################################################### | ||
# | ||
# Canonicalisation | ||
|
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.
perhaps this makes it clearer?