Skip to content

Commit 03d6b8b

Browse files
fix: fix GCD of complex coefficient polynomials (#340)
1 parent e289a0d commit 03d6b8b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/gcd.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,13 @@ function primitive_part(
959959
)
960960
return p
961961
end
962+
function primitive_part(
963+
p::_APL{<:Complex{<:AbstractFloat}},
964+
::AbstractUnivariateGCDAlgorithm,
965+
::MA.MutableTrait,
966+
)
967+
return p
968+
end
962969

963970
"""
964971
primitive_part_content(poly::AbstractPolynomialLike{T}, algo::AbstractUnivariateGCDAlgorithm) where {T}

test/commutative/gcd.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,10 @@ end
305305
p2 = MP.polynomial(p * q, ComplexF64)
306306
g = @inferred gcd(p1, p2)
307307
@test isone(g)
308+
309+
p1 = p - 2.5im
310+
p2 = 2.0p - 5.0im
311+
g = @inferred gcd(p1, p2)
312+
@test isequal(p1, g) || isequal(p2, g)
308313
end
309314
end

0 commit comments

Comments
 (0)