Skip to content

Commit 4389773

Browse files
feat: support GCD for non-concrete polynomial types
1 parent 0e6fbb0 commit 4389773

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/gcd.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,9 @@ function MA.operate(
306306
defl,
307307
)
308308
return polynomial(
309-
map(terms(p)) do t
310-
return term(
311-
coefficient(t),
312-
MA.operate(op, monomial(t), shift, defl),
313-
)
309+
coefficients(p),
310+
map(monomials(p)) do m
311+
return MA.operate(op, m, shift, defl)
314312
end,
315313
)
316314
end

test/commutative/gcd.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,11 @@ end
291291
end
292292
end
293293
end
294+
@testset "Non-concrete polynomial GCD" begin
295+
Mod.@polyvar p q
296+
p1 = MP.polynomial(p^2 + q^2, Number)
297+
p2 = MP.polynomial(p * q, Number)
298+
g = gcd(p1, p2)
299+
@test isone(g)
300+
end
294301
end

0 commit comments

Comments
 (0)