Skip to content

Commit 0e53689

Browse files
authored
Fix gcd edge case with different variables (#196)
1 parent 522ad02 commit 0e53689

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/gcd.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ function deflated_gcd(p1::APL{T}, p2::APL{S}, algo) where {T, S}
232232
return gcd(g, p2, algo)
233233
else
234234
if num_common > 1
235-
@assert i1 == i2
236235
v1 = variables(p1)[i1]
236+
@assert v1 == variables(p2)[i2]
237237
return multivariate_gcd(p1, p2, v1, algo)
238238
else
239239
return univariate_gcd(p1, p2, algo)

test/division.jl

+4
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ function multivariate_gcd_test(::Type{T}, algo=GeneralizedEuclideanAlgorithm())
243243
(T != Float64 || (algo != GeneralizedEuclideanAlgorithm(false, true) && algo != GeneralizedEuclideanAlgorithm(true, true)))
244244
triple_test(a, b, c, algo)
245245
end
246+
247+
# https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/issues/195
248+
sym_test(x*(y^2) + 2x*y*z + x*(z^2) + x*y + x*z, y + z, y + z, algo)
246249
end
247250

248251
function lcm_test()
@@ -302,6 +305,7 @@ function extracted_variable_test()
302305
_test(x^4 + y^5 + z^6, x^3 + y^2 + z, z, z)
303306
_test(x^6 + y^5 + z^4, x + y^2 + z^3, x, x)
304307
_test(x^6 + y + z^4 - y, x + y + z^3 - y, x, x)
308+
_test(x*(y^2) + 2x*y*z + x*(z^2) + x*y + x*z, y + z, y, y)
305309
end
306310

307311
@testset "Division" begin

0 commit comments

Comments
 (0)