Skip to content

Commit 9a9ea43

Browse files
committed
adjust tolerances, work on interfaces, cleanup
1 parent d656bb9 commit 9a9ea43

File tree

4 files changed

+142
-122
lines changed

4 files changed

+142
-122
lines changed

src/polynomials/LaurentPolynomial.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,20 @@ function integrate(p::P, k::S) where {T, P<: LaurentPolynomial{T}, S<:Number}
426426
return (P)(as, m:n, p.var)
427427

428428
end
429+
430+
431+
function Base.gcd(p::LaurentPolynomial{T}, q::LaurentPolynomial{T}, args...; kwargs...) where {T}
432+
mp, Mp = extrema(p)
433+
mq, Mq = extrema(q)
434+
if mp < 0 || mq < 0
435+
throw(ArgumentError("GCD is not defined when there are `x⁻¹` terms"))
436+
end
437+
438+
degree(p) == 0 && return iszero(p) ? q : one(q)
439+
degree(q) == 0 && return iszero(q) ? p : one(p)
440+
check_same_variable(p,q) || throw(ArgumentError("p and q have different symbols"))
441+
442+
pp, qq = convert(Polynomial, p), convert(Polynomial, q)
443+
u = gcd(pp, qq, args..., kwargs...)
444+
return LaurentPolynomial(coeffs(u), p.var)
445+
end

0 commit comments

Comments
 (0)