Skip to content
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 some specialized methods for universal polynomials #2013

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

SoongNoonien
Copy link
Contributor

@SoongNoonien SoongNoonien commented Jan 30, 2025

As @fingolfin mentioned in Nemocas/AbstractAlgebra.jl#1753 (comment), it would be nice to have some methods for certain universal polynomial rings. This is a first implementation of denominator. I think there should be some more methods that are useful. But I haven't found them yet as I currently only need denominator.

Resolves oscar-system/GenericCharacterTables.jl#203

@fingolfin
Copy link
Member

Some other methods you should perhaps add are here: oscar-system/GenericCharacterTables.jl#203

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.29%. Comparing base (82193e6) to head (bddd8cc).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2013      +/-   ##
==========================================
- Coverage   88.31%   88.29%   -0.02%     
==========================================
  Files          98       99       +1     
  Lines       36126    36196      +70     
==========================================
+ Hits        31903    31959      +56     
- Misses       4223     4237      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sensible to me. In case @lgoettgens has time and interested to have a quick look, I'll wait a bit more with merging this.

@SoongNoonien SoongNoonien marked this pull request as ready for review February 7, 2025 09:48

denominator(f::UniversalPolyRingElem{QQFieldElem}) = denominator(data(f))

function +(p::Generic.UnivPoly{T}, n::ZZRingElem) where {T}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't all of these here make sense for, let's say, all "scalar" types that have ad-hoc operations?

In particular, I am thinking about Integer and T (the coeff type), but I guess those would belong in AA instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such methods already exist for Integer and T in AA. But not for ZZRingElem for obvious reasons. Which is why we add them here.

@fingolfin
Copy link
Member

Example demonstrating the effect:

julia> S = universal_polynomial_ring(QQ)
Universal Polynomial Ring over Rational field

julia> x, y = gens(S, [:x,:y])
(x, y)

julia> f = x^3 + y
x^3 + y

julia> n = ZZ(1)
1

Then in master we get:

julia> @b $f  + 1
209.213 ns (6 allocs: 208 bytes)

julia> @b $f  + $n
327.180 ns (10 allocs: 408 bytes)

julia> @b $f.p  + $n
205.153 ns (5 allocs: 176 bytes)

With this branch:

julia> @b $f  + 1
207.000 ns (6 allocs: 208 bytes)

julia> @b $f  + $n
214.286 ns (6 allocs: 208 bytes)

julia> @b $f.p  + $n
203.224 ns (5 allocs: 176 bytes)

@fingolfin fingolfin merged commit 4df8c91 into Nemocas:master Feb 7, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants