Skip to content

Commit 4a31d39

Browse files
authored
Fix gcd with zero (#177)
1 parent cbeec6f commit 4a31d39

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/gcd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function Base.gcd(p1::APL{T}, p2::APL{S}, algo::AbstractUnivariateGCDAlgorithm=G
107107
if isapproxzero(p1)
108108
return convert(MA.promote_operation(gcd, typeof(p1), typeof(p2)), p2)
109109
end
110-
if isapproxzero(p1)
111-
return convert(MA.promote_operation(gcd, typeof(p1), typeof(p2)), p2)
110+
if isapproxzero(p2)
111+
return convert(MA.promote_operation(gcd, typeof(p1), typeof(p2)), p1)
112112
end
113113
shift1, defl1 = deflation(p1)
114114
shift2, defl2 = deflation(p2)

test/division.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ end
134134
function multivariate_gcd_test(::Type{T}, algo=GeneralizedEuclideanAlgorithm()) where {T}
135135
Mod.@polyvar x y z
136136
o = one(T)
137+
zr = zero(T)
138+
sym_test(o * x, zr * x, o * x, algo)
139+
sym_test(o * x + o, zr * x, o * x + o, algo)
137140
# Inspired from https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/issues/160
138141
f1 = o * x * y + o * x
139142
f2 = o * y^2

0 commit comments

Comments
 (0)