Skip to content

Commit

Permalink
fix: multivariate gcd over number fields (#1407)
Browse files Browse the repository at this point in the history
- handle the case of non-nice defining polynomial better
  • Loading branch information
thofma authored Feb 19, 2024
1 parent 52c3f2e commit c336a38
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/NumField/NfAbs/MPolyGcd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,12 @@ function _gcd(f::Hecke.Generic.MPoly{AbsSimpleNumFieldElem}, g::Hecke.Generic.MP
Zx = Hecke.Globals.Zx
R = RecoCtx(K)

de = lcm(lcm(map(denominator, coefficients(f))), lcm(map(denominator, coefficients(g))))
E = any_order(K)
de = lcm(lcm(map(c -> denominator(c, E), coefficients(f))),
lcm(map(c -> denominator(c, E), coefficients(g))))

f*=de
g*=de
E = any_order(K)
lI = E*E(leading_coefficient(f)) + E*E(leading_coefficient(g))
gl = Hecke.short_elem(lI)
gl *= evaluate(derivative(K.pol), gen(K)) # use Kronnecker basis
Expand Down
9 changes: 7 additions & 2 deletions test/NfAbs/MPolyGcd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
@test isone(gcd(f+1,g))

end
end


# test non-integral defining equation
Qx, x = QQ["x"]
K, a = number_field(x^2 - 1//3*x + 1);
R, (u, v) = polynomial_ring(K, ["u", "v"])
@test gcd(a*u, a*u) == u
@test is_one(gcd(a*u, a^2*v))
end
9 changes: 9 additions & 0 deletions test/NumField/NfAbs/MPolyFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,13 @@
f = (x^3+5*y^3)*(x^2+2*y^2)
# not a real test, just check that it does not crash
@test length(factor_absolute(f)) == 3

# non-integral defining equation
Qx, x = QQ["x"]
K, a = number_field(x^2 - 1//3*x + 1);
R, (u, v) = polynomial_ring(K, ["u", "v"])
f = (u + a)*(v^2 + a)
fa = factor(f)
@test unit(fa) * prod(g^e for (g, e) in fa) == f

end

0 comments on commit c336a38

Please sign in to comment.