Skip to content

Commit 12c11ef

Browse files
authored
close #598 (#599)
1 parent 257af03 commit 12c11ef

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "Polynomials"
22
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
33
license = "MIT"
44
author = "JuliaMath"
5-
version = "4.0.17"
5+
version = "4.0.18"
66

77
[deps]
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/polynomials/ngcd.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ function ngcd(p::P, q::Q,
1212
args...;
1313
kwargs...) where {T,X,P<:StandardBasisPolynomial{T,X},
1414
S,Y,Q<:StandardBasisPolynomial{S,Y}}
15+
16+
# easy cases
17+
degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN)
18+
degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN)
19+
degree(q) < 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN)
20+
degree(q) == 0 && return (u=one(p), v=p, w=q, Θ=NaN, κ=NaN)
21+
1522
if (degree(q) > degree(p))
1623
u,w,v,Θ,κ = ngcd(q,p,args...; kwargs...)
1724
return (u=u,v=v,w=w, Θ=Θ, κ=κ)
@@ -21,14 +28,12 @@ function ngcd(p::P, q::Q,
2128
return ngcd(q, b, args...; λ=100, kwargs...)
2229
end
2330

24-
# easy cases
25-
degree(p) < 0 && return (u=q, v=p, w=one(q), θ=NaN, κ=NaN)
26-
degree(p) == 0 && return (u=one(q), v=p, w=q, θ=NaN, κ=NaN)
27-
degree(q) < 0 && return (u=one(q), v=p, w=zero(q), θ=NaN, κ=NaN)
28-
degree(q) == 0 && return (u=one(p), v=p, w=q, Θ=NaN, κ=NaN)
31+
# other easy cases
2932
p q && return (u=p,v=one(p), w=one(p), θ=NaN, κ=NaN)
3033
Polynomials.assert_same_variable(p,q)
3134

35+
36+
3237
R = promote_type(float(T))
3338
𝑷 = Polynomials.constructorof(P){R,X}
3439

test/StandardBasis.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,15 @@ end
15581558
@test out.u == x^k
15591559
end
15601560
end
1561+
1562+
# issue #598 ultimately ngcd issue not checking 0 polynomial earlier
1563+
x = Polynomial([0,1])
1564+
A = (1.0 + 2.0*x^2) // (1.0 + 2.0*x^2)
1565+
B = (0.0) // (1.0 + 2.0*x^2)
1566+
C = (3.0*x) // (1.0 + 2.0*x^2)
1567+
D = (1.0 + 2.0*x^2) // (1.0 + 2.0*x^2)
1568+
ab,cd = [A B], [C D]
1569+
@test [A B; C D] == [ab; cd]
15611570
end
15621571

15631572
@testset "Showing" begin

0 commit comments

Comments
 (0)