Skip to content

Commit

Permalink
close #598 (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani authored Feb 28, 2025
1 parent 257af03 commit 12c11ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Polynomials"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
license = "MIT"
author = "JuliaMath"
version = "4.0.17"
version = "4.0.18"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
15 changes: 10 additions & 5 deletions src/polynomials/ngcd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ function ngcd(p::P, q::Q,
args...;
kwargs...) where {T,X,P<:StandardBasisPolynomial{T,X},
S,Y,Q<:StandardBasisPolynomial{S,Y}}

# easy cases
degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN)
degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN)
degree(q) < 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN)
degree(q) == 0 && return (u=one(p), v=p, w=q, Θ=NaN, κ=NaN)

if (degree(q) > degree(p))
u,w,v,Θ,κ = ngcd(q,p,args...; kwargs...)
return (u=u,v=v,w=w, Θ=Θ, κ=κ)
Expand All @@ -21,14 +28,12 @@ function ngcd(p::P, q::Q,
return ngcd(q, b, args...; λ=100, kwargs...)
end

# easy cases
degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN)
degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN)
degree(q) < 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN)
degree(q) == 0 && return (u=one(p), v=p, w=q, Θ=NaN, κ=NaN)
# other easy cases
p q && return (u=p,v=one(p), w=one(p), θ=NaN, κ=NaN)
Polynomials.assert_same_variable(p,q)



R = promote_type(float(T))
𝑷 = Polynomials.constructorof(P){R,X}

Expand Down
9 changes: 9 additions & 0 deletions test/StandardBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,15 @@ end
@test out.u == x^k
end
end

# issue #598 ultimately ngcd issue not checking 0 polynomial earlier
x = Polynomial([0,1])
A = (1.0 + 2.0*x^2) // (1.0 + 2.0*x^2)
B = (0.0) // (1.0 + 2.0*x^2)
C = (3.0*x) // (1.0 + 2.0*x^2)
D = (1.0 + 2.0*x^2) // (1.0 + 2.0*x^2)
ab,cd = [A B], [C D]
@test [A B; C D] == [ab; cd]
end

@testset "Showing" begin
Expand Down

2 comments on commit 12c11ef

@jverzani
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/126075

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v4.0.18 -m "<description of version>" 12c11efaf5e40d5c6995c94259020b7fd6df5380
git push origin v4.0.18

Please sign in to comment.