Skip to content

Commit dc96201

Browse files
committed
Fix bug in ^(f::Generic.MPoly, n::Int)
If the coefficient ring is not a domain then the `n`-th power of an element `f` may have degree less than `n*deg(f)`.
1 parent d51ff09 commit dc96201

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/generic/MPoly.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,8 @@ function ^(a::MPoly{T}, b::Int) where {T <: RingElement}
23162316
return zero(a)
23172317
end
23182318
elseif length(a) == 1
2319+
c = coeff(a, 1)^b
2320+
is_zero(c) && return zero(a)
23192321
N = size(a.exps, 1)
23202322
exps = zeros(UInt, N, 1)
23212323
monomial_mul!(exps, 1, a.exps, 1, b, N)
@@ -2324,7 +2326,7 @@ function ^(a::MPoly{T}, b::Int) where {T <: RingElement}
23242326
error("Exponent overflow in powering")
23252327
end
23262328
end
2327-
return parent(a)([coeff(a, 1)^b], exps)
2329+
return parent(a)([c], exps)
23282330
elseif b == 0
23292331
return one(a)
23302332
elseif b == 1

0 commit comments

Comments
 (0)