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

Better unsafe funcs for UnivPoly and a few others #1838

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

fingolfin
Copy link
Member

Not yet quite complete (I want addmul/submul for UnivPoly, too) and also unsure about some things (see inline comments)

@@ -1013,21 +1028,40 @@ function add!(a::UnivPoly{T}, b::UnivPoly{T}, c::UnivPoly{T}) where {T <: RingEl
return a
end

function add!(a::UnivPoly{T}, b::UnivPoly{T}, c::Integer) where {T <: RingElement}
Copy link
Member Author

Choose a reason for hiding this comment

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

What I really need is this but for ZZRingElem instead of Integer.

Come to think of, it also would make a lot of sense to have this for c::T.

And easy way to cover all those would be to just do

Suggested change
function add!(a::UnivPoly{T}, b::UnivPoly{T}, c::Integer) where {T <: RingElement}
function add!(a::UnivPoly{T}, b::UnivPoly{T}, c) where {T <: RingElement}

There shouldn't be too much issues with ambiguity as long as two of the arguments have identical type.

But I still wonder if such a signature is really a good idea?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've now changed it to this (i.e. dropped the restriction on one of the arguments completely).

Wondering if @fieker or @thofma forsee any potential problems with this?

(We would like these functions for GenericCharacterTables.jl so we can speed up things there w/o relying on implementation details for UnivPoly)

Copy link
Member

Choose a reason for hiding this comment

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

no objection from me

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 47.61905% with 22 lines in your changes missing coverage. Please review.

Project coverage is 88.09%. Comparing base (96c82d5) to head (34e5088).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/generic/UnivPoly.jl 27.27% 16 Missing ⚠️
src/generic/TotalFraction.jl 25.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1838      +/-   ##
==========================================
- Coverage   88.13%   88.09%   -0.04%     
==========================================
  Files         119      119              
  Lines       29982    30008      +26     
==========================================
+ Hits        26426    26437      +11     
- Misses       3556     3571      +15     

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

@fingolfin fingolfin marked this pull request as ready for review October 7, 2024 21:53
@fingolfin fingolfin removed the triage label Oct 10, 2024
@fingolfin fingolfin merged commit 5170909 into Nemocas:master Oct 10, 2024
28 of 30 checks passed
@fingolfin fingolfin deleted the mh/unsafe-more branch October 10, 2024 08:58
end

function neg!(z::UnivPoly{T}, a::UnivPoly{T}) where {T <: RingElement}
z.p = neg!(a.p)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs to be

z.p = neg!(z.p, a.p)

to not modify a. I'll add this patch to #1847

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