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

Fix a bug in gcd for polynomials #1799

Merged
merged 1 commit into from
Oct 7, 2024
Merged

Conversation

joschmitt
Copy link
Collaborator

I don't know what this function is doing, so this is an educated guess. For polynomials over fields, another gcd is used. The function fixed here is only called if one specifies the ignore_content = true.

I found this by calling is_squarefree on a polynomial over a number field in Nemo.

@thofma
Copy link
Member

thofma commented Sep 18, 2024

Can you post the example to reproduce it?

@joschmitt
Copy link
Collaborator Author

joschmitt commented Sep 18, 2024

julia> Rx, x = QQ["x"]
Univariate polynomial ring in x over rationals, (x)

julia> gcd(x, x, true)
ERROR: UndefVarError: `c` not defined
Stacktrace:
 [1] gcd(a::AbstractAlgebra.Generic.Poly{Rational{BigInt}}, b::AbstractAlgebra.Generic.Poly{Rational{BigInt}}, ignore_content::Bool)
   @ AbstractAlgebra ~/.julia/dev/AbstractAlgebra/src/Poly.jl:1890
 [2] top-level scope
   @ REPL[6]:1

gcd(x, x) calls another method though.

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.99%. Comparing base (0f40154) to head (f9c6664).
Report is 26 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1799   +/-   ##
=======================================
  Coverage   87.99%   87.99%           
=======================================
  Files         119      119           
  Lines       30073    30073           
=======================================
  Hits        26464    26464           
  Misses       3609     3609           

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

@thofma
Copy link
Member

thofma commented Sep 18, 2024

This version (with the third boolean argument) should probably not be user-facing, but I guess there is no harm fixing it here.

@lgoettgens lgoettgens closed this Sep 20, 2024
@lgoettgens lgoettgens reopened this Sep 20, 2024
@fingolfin
Copy link
Member

could/should we add a test?

@joschmitt
Copy link
Collaborator Author

could/should we add a test?

I don't know what the function is supposed to do, so I don't feel qualified.

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.

I don't really follow this whole function, but c is clearly only set if !ignore_content holds, so the existing code can't be right. The new code seems at least plausible.

So let's merge this. If there are problems here, and if anyone is actually using this code, we'll just have to hope for a bug report.

@fingolfin fingolfin merged commit 96c82d5 into Nemocas:master Oct 7, 2024
57 of 58 checks passed
@joschmitt joschmitt deleted the js/fixgcd branch October 7, 2024 12:44
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.

4 participants