From cb99cfd4261f9620e3f8c173abeccdc545810bad Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Fri, 5 Jan 2024 20:23:17 +0100 Subject: [PATCH] feat: adjust to finite field changes in Nemo (#1338) --- Project.toml | 4 ++-- examples/Plesken.jl | 2 +- ext/GAPExt/brauer.jl | 24 +++++++++++----------- ext/GAPExt/fields.jl | 8 ++++---- ext/GAPExt/maximal_abelian_subextension.jl | 2 +- src/AlgAss/AbsAlgAss.jl | 2 +- src/AlgAss/AlgAss.jl | 2 +- src/EllCrv/EllCrv.jl | 2 +- src/EllCrv/Finite.jl | 24 +++++++++++----------- src/EllCrv/LocalData.jl | 2 +- src/LocalField/Conjugates.jl | 6 +++--- src/LocalField/Poly.jl | 5 +++-- src/LocalField/qAdic.jl | 4 ++-- src/Map/MapType.jl | 6 +++--- src/Map/NfOrd.jl | 2 +- src/Misc/Poly.jl | 2 +- src/Misc/RatRecon.jl | 6 +++--- src/Misc/nmod_poly.jl | 14 ------------- src/NumField/NfAbs/Simplify.jl | 4 ++-- src/NumField/NfRel/Simplify.jl | 4 ++-- src/NumField/Selmer.jl | 19 +++-------------- src/NumField/Subfields.jl | 2 +- src/NumFieldOrd/NfOrd/Clgp/Types.jl | 2 +- src/NumFieldOrd/NfOrd/Hensel.jl | 4 ++-- src/NumFieldOrd/NfOrd/ResidueField.jl | 2 +- src/QuadForm/Herm/GenusRep.jl | 2 +- src/QuadForm/LineOrbits.jl | 2 +- src/QuadForm/Misc.jl | 2 +- test/EllCrv/Finite.jl | 8 ++++---- test/Misc/FiniteField.jl | 6 +++--- test/Misc/RelFinField.jl | 2 +- 31 files changed, 75 insertions(+), 101 deletions(-) diff --git a/Project.toml b/Project.toml index 54a337b879..a12fa1928f 100644 --- a/Project.toml +++ b/Project.toml @@ -28,7 +28,7 @@ GAPExt = "GAP" PolymakeExt = "Polymake" [compat] -AbstractAlgebra = "^0.34.4" +AbstractAlgebra = "^0.35.2" Dates = "1.6" Distributed = "1.6" GAP = "0.9.6, 0.10" @@ -37,7 +37,7 @@ LazyArtifacts = "1.6" Libdl = "1.6" LinearAlgebra = "1.6" Markdown = "1.6" -Nemo = "^0.38.2" +Nemo = "^0.39.1" Pkg = "1.6" Polymake = "0.10, 0.11" Printf = "1.6" diff --git a/examples/Plesken.jl b/examples/Plesken.jl index 2ac817da95..430f980f43 100644 --- a/examples/Plesken.jl +++ b/examples/Plesken.jl @@ -234,7 +234,7 @@ function plesken_kummer(p::ZZRingElem, r::Int, s::Int) end descent = true ord = degree(opt) - R = FlintFiniteField(opt, "a")[1] + R = Native.finite_field(opt, "a")[1] T = residue_ring(FlintZZ, p) J = CoerceMap(T, R) end diff --git a/ext/GAPExt/brauer.jl b/ext/GAPExt/brauer.jl index 3cb13c6794..4708047e09 100644 --- a/ext/GAPExt/brauer.jl +++ b/ext/GAPExt/brauer.jl @@ -662,12 +662,12 @@ function _obstruction_prime_no_extend(x::FieldsTower, cocycles, p::Int) GC = automorphism_list(K, copy = false) D = x.isomorphism Pcomp = 2 - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx = polynomial_ring(R, "x", cached = false)[1] ff = Rx(K.pol) while iszero(mod(p, Pcomp)) || iszero(discriminant(ff)) Pcomp = next_prime(Pcomp) - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx = polynomial_ring(R, "x", cached = false)[1] ff = Rx(K.pol) end @@ -738,13 +738,13 @@ function _obstruction_prime(x::FieldsTower, cocycles::Vector{cocycle_ctx}, p) permGC = _from_autos_to_perm(autsK) Gperm = _perm_to_gap_grp(permGC) Pcomp = 2 - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx = polynomial_ring(R, "x", cached = false)[1] ff1 = Rx(K.pol) ff2 = Rx(K1.pol) while iszero(mod(p, Pcomp)) || iszero(discriminant(ff1)) || iszero(discriminant(ff2)) Pcomp = next_prime(Pcomp) - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx = polynomial_ring(R, "x", cached = false)[1] ff1 = Rx(K.pol) ff2 = Rx(K1.pol) @@ -801,12 +801,12 @@ function action_on_roots(G::Vector{NfToNfMor}, zeta::nf_elem, pv::Int) p = 11 K = domain(G[1]) Qx = parent(K.pol) - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) while iszero(discriminant(fmod)) || iszero(mod(pv, p)) p = next_prime(p) - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) end @@ -833,13 +833,13 @@ function restriction(autsK1::Vector{NfToNfMor}, autsK::Vector{NfToNfMor}, mp::Nf K = domain(mp) K1 = codomain(mp) p = 11 - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) fmod = Rx(K1.pol) while iszero(discriminant(ff1)) || iszero(discriminant(fmod)) p = next_prime(p) - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) fmod = Rx(K1.pol) @@ -914,13 +914,13 @@ function _obstruction_pp(F::FieldsTower, cocycles::Vector{cocycle_ctx}, pv::Int) permGC = _from_autos_to_perm(autsK) Gperm = _perm_to_gap_grp(permGC) Pcomp = 7 - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) ff2 = Rx(K1.pol) while iszero(discriminant(ff1)) || iszero(discriminant(ff2)) Pcomp = next_prime(Pcomp) - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) ff2 = Rx(K1.pol) @@ -1006,12 +1006,12 @@ function _obstruction_pp_no_extend(F::FieldsTower, cocycles::Vector{cocycle_ctx} permGC = _from_autos_to_perm(autsK) Gperm = _perm_to_gap_grp(permGC) Pcomp = 7 - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) while iszero(discriminant(ff1)) Pcomp = next_prime(Pcomp) - R = GF(Pcomp, cached = false) + R = Native.GF(Pcomp, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) ff1 = Rx(K.pol) end diff --git a/ext/GAPExt/fields.jl b/ext/GAPExt/fields.jl index 5384827a5b..c0604e3fe8 100644 --- a/ext/GAPExt/fields.jl +++ b/ext/GAPExt/fields.jl @@ -173,12 +173,12 @@ function permutations(G::Vector{Hecke.NfToNfMor}) dK = degree(K) d = numerator(discriminant(K.pol)) p = 11 - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) while iszero(discriminant(fmod)) p = next_prime(p) - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) end @@ -264,12 +264,12 @@ function _from_autos_to_perm(G::Vector{Hecke.NfToNfMor}) n = length(G) #First, find a good prime p = 3 - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) while iszero(discriminant(fmod)) p = next_prime(p) - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) end diff --git a/ext/GAPExt/maximal_abelian_subextension.jl b/ext/GAPExt/maximal_abelian_subextension.jl index 49838f1063..610cb0a415 100644 --- a/ext/GAPExt/maximal_abelian_subextension.jl +++ b/ext/GAPExt/maximal_abelian_subextension.jl @@ -58,7 +58,7 @@ function check_abelian_extensions(class_fields::Vector{Tuple{ClassField{MapRayCl while iszero(mod(d1, p)) || iszero(mod(d2, p)) p = next_prime(p) end - R = GF(p, cached = false) + R = Native.GF(p, cached = false) Rx, x = polynomial_ring(R, "x", cached = false) fmod = Rx(K.pol) mp_pol = Rx(image_primitive_element(emb_sub)) diff --git a/src/AlgAss/AbsAlgAss.jl b/src/AlgAss/AbsAlgAss.jl index f456e451ba..5ff6579e61 100644 --- a/src/AlgAss/AbsAlgAss.jl +++ b/src/AlgAss/AbsAlgAss.jl @@ -1281,7 +1281,7 @@ function _radical(A::AbsAlgAss{T}) where { T <: Union{ fqPolyRepFieldElem, FqPol if T <: fqPolyRepFieldElem Fp = Native.GF(Int(p)) elseif T === FqFieldElem - Fp = Nemo._GF(p) + Fp = GF(p) else Fp = Native.GF(p) end diff --git a/src/AlgAss/AlgAss.jl b/src/AlgAss/AlgAss.jl index 3ff26fae9b..235c654039 100644 --- a/src/AlgAss/AlgAss.jl +++ b/src/AlgAss/AlgAss.jl @@ -295,7 +295,7 @@ function AlgAss(O::Union{NfAbsOrd, AlgAssAbsOrd}, I::Union{NfAbsOrdIdl, AlgAssAb end r = length(basis_elts) - Fp = Nemo._GF(p, cached = false) + Fp = GF(p, cached = false) if r == 0 A = _zero_algebra(Fp) diff --git a/src/EllCrv/EllCrv.jl b/src/EllCrv/EllCrv.jl index afa8b8da8f..c3b1c4284b 100644 --- a/src/EllCrv/EllCrv.jl +++ b/src/EllCrv/EllCrv.jl @@ -319,7 +319,7 @@ Return an elliptic curve with the given $j$-invariant. ```jldoctest julia> K = GF(3) -Finite field of characteristic 3 +Finite field of degree 1 over GF(3) julia> elliptic_curve_from_j_invariant(K(2)) Elliptic curve with equation diff --git a/src/EllCrv/Finite.jl b/src/EllCrv/Finite.jl index b69b003370..9340ce2242 100644 --- a/src/EllCrv/Finite.jl +++ b/src/EllCrv/Finite.jl @@ -1050,16 +1050,16 @@ Return the polynomial whose roots correspond to j-invariants of supersingular elliptic curves of characteristic p. """ function supersingular_polynomial(p::IntegerUnion) - p = ZZRingElem(p) - K = GF(p) - KJ, J = polynomial_ring(GF(p), "J") - if p < 3 + _p = ZZRingElem(p) + K = GF(_p) + KJ, J = polynomial_ring(K, "J") + if _p < 3 return J end - m = divexact((p-1), 2) - KXT, (X, T) = polynomial_ring(K, ["X", "T"]) - H = sum([binomial(m, i)^2 *T^i for i in (0:m)]) + m = divexact((_p -1 ), 2) + KXT, (X, T) = polynomial_ring(K, ["X", "T"], cached = false) + H = sum(elem_type(KXT)[binomial(m, i)^2 *T^i for i in 0:m]) F = T^2 * (T - 1)^2 * X - 256 * (T^2 - T + 1)^3 R = resultant(F, H, 2) factors = factor(evaluate(R, [J, zero(KJ)])) @@ -1144,17 +1144,17 @@ Return a list of generators of the group of rational points on $E$. julia> E = elliptic_curve(GF(101, 2), [1, 2]); julia> gens(E) -2-element Vector{EllCrvPt{fqPolyRepFieldElem}}: - Point (93*o + 10 : 22*o + 69 : 1) of Elliptic curve with equation +2-element Vector{EllCrvPt{FqFieldElem}}: + Point (16*o + 42 : 88*o + 97 : 1) of Elliptic curve with equation y^2 = x^3 + x + 2 - Point (89*o + 62 : 14*o + 26 : 1) of Elliptic curve with equation + Point (88*o + 23 : 94*o + 22 : 1) of Elliptic curve with equation y^2 = x^3 + x + 2 julia> E = elliptic_curve(GF(101), [1, 2]); julia> gens(E) -1-element Vector{EllCrvPt{fpFieldElem}}: - Point (50 : 69 : 1) of Elliptic curve with equation +1-element Vector{EllCrvPt{FqFieldElem}}: + Point (85 : 58 : 1) of Elliptic curve with equation y^2 = x^3 + x + 2 ``` """ diff --git a/src/EllCrv/LocalData.jl b/src/EllCrv/LocalData.jl index e6a3013338..5e5300a096 100644 --- a/src/EllCrv/LocalData.jl +++ b/src/EllCrv/LocalData.jl @@ -116,7 +116,7 @@ end function _tates_algorithm(E::EllCrv{QQFieldElem}, _p::IntegerUnion) p = ZZ(_p) F = GF(p, cached = false) - _invmod = x -> QQ(lift(inv(F(x)))) + _invmod = x -> QQ(lift(ZZ, inv(F(x)))) _uni = p return __tates_algorithm_generic(E, ZZ, x -> is_zero(x) ? inf : valuation(x, p), x -> smod(x, p), x -> F(x), x -> QQ(lift(x)), _invmod, p) end diff --git a/src/LocalField/Conjugates.jl b/src/LocalField/Conjugates.jl index 433ced64dd..4a7c5907db 100644 --- a/src/LocalField/Conjugates.jl +++ b/src/LocalField/Conjugates.jl @@ -556,8 +556,8 @@ function completion(K::AnticNumberField, ca::qadic) while length(pa) < d push!(pa, pa[end]*pa[2]) end - m = matrix(Nemo._GF(p), d, d, [lift(ZZ, coeff(pa[i], j-1)) for j=1:d for i=1:d]) - o = matrix(Nemo._GF(p), d, 1, [lift(ZZ, coeff(gen(R), j-1)) for j=1:d]) + m = matrix(GF(p), d, d, [lift(ZZ, coeff(pa[i], j-1)) for j=1:d for i=1:d]) + o = matrix(GF(p), d, 1, [lift(ZZ, coeff(gen(R), j-1)) for j=1:d]) s = solve(m, o) @hassert :qAdic 1 m*s == o a = K() @@ -566,7 +566,7 @@ function completion(K::AnticNumberField, ca::qadic) end f = defining_polynomial(parent(ca), FlintZZ) fso = inv(derivative(f)(gen(R))) - o = matrix(Nemo._GF(p), d, 1, [lift(ZZ, coeff(fso, j-1)) for j=1:d]) + o = matrix(GF(p), d, 1, [lift(ZZ, coeff(fso, j-1)) for j=1:d]) s = solve(m, o) b = K() for i=1:d diff --git a/src/LocalField/Poly.jl b/src/LocalField/Poly.jl index b90642cd4a..5f31bdaef3 100644 --- a/src/LocalField/Poly.jl +++ b/src/LocalField/Poly.jl @@ -170,8 +170,9 @@ function fun_factor(g::Generic.Poly{padic}) Rt = polynomial_ring(R, "t", cached = false)[1] fR = Rt([R(Hecke.lift(coeff(g, i))) for i = 0:degree(g)]) u, g1 = Hecke.fun_factor(fR) - fun = x -> lift(x, K) - return map_coefficients(fun, u, parent = Kt), map_coefficients(fun, g1, parent = Kt) + liftu = Kt(elem_type(K)[lift(coeff(u, i), K) for i in 0:degree(u)]) + liftg1 = Kt(elem_type(K)[lift(coeff(g1, i), K) for i in 0:degree(g1)]) + return (liftu, liftg1)::Tuple{typeof(g), typeof(g)} end function fun_factor(f::Generic.Poly{S}) where S <: Union{qadic, LocalFieldElem} diff --git a/src/LocalField/qAdic.jl b/src/LocalField/qAdic.jl index 8299105c1b..413d053a88 100644 --- a/src/LocalField/qAdic.jl +++ b/src/LocalField/qAdic.jl @@ -8,7 +8,7 @@ function residue_field(Q::FlintQadicField) if z !== nothing return codomain(z), z end - Fp = Nemo._GF(prime(Q)) + Fp = GF(prime(Q)) Fpt = polynomial_ring(Fp, cached = false)[1] g = defining_polynomial(Q) #no Conway if parameters are too large! f = Fpt([Fp(lift(coeff(g, i))) for i=0:degree(Q)]) @@ -36,7 +36,7 @@ function residue_field(Q::FlintQadicField) end function residue_field(Q::FlintPadicField) - k = Nemo._GF(prime(Q)) + k = GF(prime(Q)) pro = function(x::padic) v = valuation(x) v < 0 && error("elt non integral") diff --git a/src/Map/MapType.jl b/src/Map/MapType.jl index 47840bf8bd..6e4ec85d9f 100644 --- a/src/Map/MapType.jl +++ b/src/Map/MapType.jl @@ -148,7 +148,7 @@ julia> F = GF(2); julia> f = MapFromFunc(QQ, F, x -> F(numerator(x)) * inv(F(denominator(x)))) Map defined by a julia-function from rational field - to finite field of characteristic 2 + to finite field of degree 1 over GF(2) julia> f(QQ(1//3)) 1 @@ -156,10 +156,10 @@ julia> f(QQ(1//3)) julia> println(f) Map: QQ -> GF(2) -julia> f = MapFromFunc(QQ, F, x -> F(numerator(x)) * inv(F(denominator(x))), y -> QQ(lift(y)),) +julia> f = MapFromFunc(QQ, F, x -> F(numerator(x)) * inv(F(denominator(x))), y -> QQ(lift(ZZ, y)),) Map defined by a julia-function with inverse from rational field - to finite field of characteristic 2 + to finite field of degree 1 over GF(2) julia> preimage(f, F(1)) 1 diff --git a/src/Map/NfOrd.jl b/src/Map/NfOrd.jl index ca70dc8877..55a6c29a17 100644 --- a/src/Map/NfOrd.jl +++ b/src/Map/NfOrd.jl @@ -557,7 +557,7 @@ function NfOrdToFqFieldMor(O::NfOrd, P::NfOrdIdl) z.P = P a, g, b = get_residue_field_data(P) p = minimum(P) - R = Nemo._GF(p, cached = false) + R = GF(p, cached = false) Rx, x = polynomial_ring(R, "_\$", cached = false) F, = Nemo._residue_field(Rx(g), "_\$", check = false) d = degree(g) diff --git a/src/Misc/Poly.jl b/src/Misc/Poly.jl index 12589427fe..f035a9083c 100644 --- a/src/Misc/Poly.jl +++ b/src/Misc/Poly.jl @@ -877,7 +877,7 @@ specified, return the `n`-th cyclotomic polynomial over the integers. ```jldoctest julia> F, _ = finite_field(5) -(Finite field of characteristic 5, 1) +(Finite field of degree 1 over GF(5), 0) julia> Ft, _ = F["t"] (Univariate polynomial ring in t over GF(5), t) diff --git a/src/Misc/RatRecon.jl b/src/Misc/RatRecon.jl index e0a840ef0d..ea99441821 100644 --- a/src/Misc/RatRecon.jl +++ b/src/Misc/RatRecon.jl @@ -297,7 +297,7 @@ function _modp_results(g::QQPolyRingElem,f::QQPolyRingElem, p::ZZRingElem, M::In l1 = fpPolyRingElem[]; l2 = fpPolyRingElem[];l3 = ZZRingElem[] L = listprimes([f,g], p, M) for j in 1:length(L) - Rp, t = polynomial_ring(GF(Int(L[j]), cached=false), cached=false) + Rp, t = polynomial_ring(Native.GF(Int(L[j]), cached=false), cached=false) gp = Rp(g) fp = Rp(f) fl, nu_p, de_p = rational_reconstruction_subres(gp, fp, -1, ErrorTolerant = ErrorTolerant) @@ -424,13 +424,13 @@ function _modpResults(f, p::ZZRingElem, M::Int) Np = listprimes([f], p, M) Zx, Y = polynomial_ring(FlintZZ, "Y", cached=false) for j in 1:length(Np) - RNp = GF(Int(Np[j]), cached=false) + RNp = Native.GF(Int(Np[j]), cached=false) Rp, t = polynomial_ring(RNp, "t", cached=false) fp = Rp(f) if degree(fp) != degree(f) continue #bad prime... end - L1 = Nemo.fpFieldElem[] + L1 = fpFieldElem[] for i in 0:degree(fp) push!(L1, coeff(fp, i)) end diff --git a/src/Misc/nmod_poly.jl b/src/Misc/nmod_poly.jl index 791d3a192e..0ed0964d0a 100644 --- a/src/Misc/nmod_poly.jl +++ b/src/Misc/nmod_poly.jl @@ -1265,20 +1265,6 @@ function unit_group_1_part(f::fqPolyRepPolyRingElem, k::Int) return gens, rels end -#= -function FlintFiniteField(f::fqPolyRepPolyRingElem, s::AbstractString = "o"; cached::Bool = true, check::Bool = true) - if check && !is_irreducible(f) - error("poly not irreducible") - end - k = base_ring(f) - p = characteristic(k) - K, o = FlintFiniteField(p, degree(k)*degree(f), s, cached = cached) - r = roots(K, f)[1] # not working, embeddings are missing - fl || error("s.th. went wrong") - return K, r -end -=# - function euler_phi(f::T) where {T <: Union{fpPolyRingElem, fqPolyRepPolyRingElem, FpPolyRingElem}} lf = factor(f) q = size(base_ring(f)) diff --git a/src/NumField/NfAbs/Simplify.jl b/src/NumField/NfAbs/Simplify.jl index b11ac93e25..63fa220886 100644 --- a/src/NumField/NfAbs/Simplify.jl +++ b/src/NumField/NfAbs/Simplify.jl @@ -213,7 +213,7 @@ function _sieve_primitive_elements(B::Vector{nf_elem}) p, d = _find_prime(ZZPolyRingElem[f]) - F = FlintFiniteField(p, d, "w", cached = false)[1] + F = Nemo.Native.finite_field(p, d, "w", cached = false)[1] Ft = polynomial_ring(F, "t", cached = false)[1] ap = zero(Ft) fit!(ap, degree(K)+1) @@ -352,7 +352,7 @@ function polredabs(K::AnticNumberField) f = Zx(K.pol) p, d = _find_prime(ZZPolyRingElem[f]) - F = FlintFiniteField(p, d, "w", cached = false)[1] + F = Native.finite_field(p, d, "w", cached = false)[1] Ft = polynomial_ring(F, "t", cached = false)[1] ap = zero(Ft) fit!(ap, degree(K)+1) diff --git a/src/NumField/NfRel/Simplify.jl b/src/NumField/NfRel/Simplify.jl index 338e4ed1c9..cbead5501e 100644 --- a/src/NumField/NfRel/Simplify.jl +++ b/src/NumField/NfRel/Simplify.jl @@ -150,7 +150,7 @@ function _setup_block_system(Lrel::NfRel{nf_elem}) #First, we search for elements that are primitive using block systems Fp = Native.GF(p, cached = false) Fpx = polynomial_ring(Fp, cached = false)[1] - F = FlintFiniteField(p, abs_deg, "w", cached = false)[1] + F = Native.finite_field(p, abs_deg, "w", cached = false)[1] Fx = polynomial_ring(F, cached = false)[1] rt_base_field = roots(F, Zx(K.pol)) tmp = Fpx() @@ -274,7 +274,7 @@ function _setup_block_system(Lrel::NfRelNS{nf_elem}) #First, we search for elements that are primitive using block systems Fp = Native.GF(p, cached = false) Fpx = polynomial_ring(Fp, cached = false)[1] - F = FlintFiniteField(p, abs_deg, "w", cached = false)[1] + F = Native.finite_field(p, abs_deg, "w", cached = false)[1] Fx = polynomial_ring(F, cached = false)[1] rt_base_field = roots(F, Zx(K.pol)) rt = Dict{FqPolyRepFieldElem, Vector{Vector{FqPolyRepFieldElem}}}() diff --git a/src/NumField/Selmer.jl b/src/NumField/Selmer.jl index 3278f4dab9..2b81168352 100644 --- a/src/NumField/Selmer.jl +++ b/src/NumField/Selmer.jl @@ -244,7 +244,7 @@ function pselmer_group_fac_elem(p::Int, S::Vector{ZZRingElem}; algo::Symbol = :r v = ZZRingElem[x == -1 ? sign(a)<0 : valuation(a, x) for x = S] if check b = a*FacElem(QQ, QQFieldElem[x for x = S], [-x for x = v], parent = R) - is_power(b, p) || error("not in the codomain") + is_power(b, p)[1] || error("not in the codomain") end return G(v) end @@ -269,28 +269,15 @@ Hecke.valuation(a::FacElem{QQFieldElem, QQField}, p::ZZRingElem) = reduce(+, [v* Hecke.valuation(a::FacElem{QQFieldElem, QQField}, p::Integer) = reduce(+, [v*valuation(k,p) for (k,v) = a], init = ZZRingElem(0)) function Hecke.is_power(a::FacElem{QQFieldElem, QQField}, p::Int) - b = simplify(a) - for (k,v) = b - if v % p != 0 - return false - end - if !is_power(k, p)[1] - return false - end - end - return true -end - -function Hecke.is_power_with_root(a::FacElem{QQFieldElem, QQField}, p::Int) b = simplify(a) K = QQFieldElem[] V = ZZRingElem[] - for (k,v) = p + for (k,v) = b if v % p == 0 push!(K, k) push!(V, divexact(v, p)) else - fl, r = is_power_with_root(k, p) + fl, r = is_power(k, p) fl || return false, a push!(K, r) push!(V, v) diff --git a/src/NumField/Subfields.jl b/src/NumField/Subfields.jl index fc673f7179..dcc6c1285c 100644 --- a/src/NumField/Subfields.jl +++ b/src/NumField/Subfields.jl @@ -139,7 +139,7 @@ function _subfield_primitive_element_from_basis(K::AnticNumberField, as::Vector{ f = Zx(K.pol*denominator(K.pol)) p, d = _find_prime(ZZPolyRingElem[f]) #First, we search for elements that are primitive using block systems - F = FlintFiniteField(p, d, "w", cached = false)[1] + F = Nemo.Native.finite_field(p, d, "w", cached = false)[1] Ft = polynomial_ring(F, "t", cached = false)[1] ap = zero(Ft) fit!(ap, degree(K)+1) diff --git a/src/NumFieldOrd/NfOrd/Clgp/Types.jl b/src/NumFieldOrd/NfOrd/Clgp/Types.jl index 3241fc39bf..4cf033bc85 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/Types.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/Types.jl @@ -131,7 +131,7 @@ mutable struct NormCtx_gen <: NormCtx while true p = next_prime(p) push!(NC.lp, p) - k = GF(p, cached = false) + k = Native.GF(p, cached = false) kx, x = polynomial_ring(k, cached = false) b = zero_matrix(k, degree(O), degree(O)) for i=1:degree(O) diff --git a/src/NumFieldOrd/NfOrd/Hensel.jl b/src/NumFieldOrd/NfOrd/Hensel.jl index 220765ee85..8be3602cef 100644 --- a/src/NumFieldOrd/NfOrd/Hensel.jl +++ b/src/NumFieldOrd/NfOrd/Hensel.jl @@ -146,7 +146,7 @@ function _roots_hensel(f::Generic.Poly{nf_elem}; continue end - Rp = Nemo.GF(p, cached=false) + Rp = Nemo.Native.GF(p, cached=false) Rpt, t = polynomial_ring(Rp, "t", cached=false) gp = Rpt(K.pol) if degree(gp) < degree(K) || iszero(discriminant(gp)) @@ -676,7 +676,7 @@ function _hensel(f::Generic.Poly{nf_elem}, p::Int, k::Int; max_roots::Int = degr K = base_ring(f) k = max(k, 2) - Rp = GF(p, cached=false) + Rp = Nemo.Native.GF(p, cached=false) Rpt, t = polynomial_ring(Rp, "t", cached=false) gp = Rpt(K.pol) lp = factor(gp).fac diff --git a/src/NumFieldOrd/NfOrd/ResidueField.jl b/src/NumFieldOrd/NfOrd/ResidueField.jl index 50d98826f2..191f4ae29f 100644 --- a/src/NumFieldOrd/NfOrd/ResidueField.jl +++ b/src/NumFieldOrd/NfOrd/ResidueField.jl @@ -69,7 +69,7 @@ end ################################################################################ function _residue_field_nonindex_divisor_helper_fq_default(f::QQPolyRingElem, g::QQPolyRingElem, p) - R = Nemo._GF(p, cached = false) + R = GF(p, cached = false) Zy, y = polynomial_ring(ZZ, "y", cached = false) Rx, x = polynomial_ring(R, "x", cached = false) diff --git a/src/QuadForm/Herm/GenusRep.jl b/src/QuadForm/Herm/GenusRep.jl index a2117b44d1..9c75644996 100644 --- a/src/QuadForm/Herm/GenusRep.jl +++ b/src/QuadForm/Herm/GenusRep.jl @@ -501,7 +501,7 @@ function genus_generators(L::HermLat) l = length(PP) VD = Int[ valuation(D, P) for P in PP ] K, k = kernel(nnorm) - F = Nemo._GF(2, cached = false) + F = GF(2, cached = false) V = VectorSpace(F, length(PP)) S = elem_type(V)[] for u in gens(K) diff --git a/src/QuadForm/LineOrbits.jl b/src/QuadForm/LineOrbits.jl index ab08b9594a..58617783c9 100644 --- a/src/QuadForm/LineOrbits.jl +++ b/src/QuadForm/LineOrbits.jl @@ -310,7 +310,7 @@ function line_orbits(G::Vector{FqPolyRepMatrix}) let GFp = GFp fp = map_coefficients(a -> GFp(a.data), f, parent = GFpx) end - FF, aa = FlintFiniteField(fp, "aa", cached = false) + FF, aa = Native.finite_field(fp, "aa", cached = false) GG = Vector{dense_matrix_type(FF)}(undef, length(G)) for i in 1:length(G) GG[i] = map_entries(b -> sum(coeff(b, i) * aa^i for i in 0:(d-1)), G[i])::dense_matrix_type(FF) diff --git a/src/QuadForm/Misc.jl b/src/QuadForm/Misc.jl index 3b44428e7b..b6bd358845 100644 --- a/src/QuadForm/Misc.jl +++ b/src/QuadForm/Misc.jl @@ -851,7 +851,7 @@ function _find_quaternion_algebra(b, P, I) end end - F = Nemo.GF(2) + F = Nemo.Native.GF(2) target = matrix(F, 1, length(__P) + length(I), vcat(fill(1, n), fill(0, length(__P) - n), fill(1, m), fill(0, length(I) - m))) if iszero(target) diff --git a/test/EllCrv/Finite.jl b/test/EllCrv/Finite.jl index 0710f1508c..6dc653a407 100644 --- a/test/EllCrv/Finite.jl +++ b/test/EllCrv/Finite.jl @@ -7,10 +7,10 @@ @testset "Elliptic curves over finite fields" begin R1 = GF(23) - R2, a2 = FlintFiniteField(23, 1, "a") - R3, a3 = FlintFiniteField(ZZRingElem(23), 1, "a") - R4, a4 = FlintFiniteField(23, 2, "a") - R4_, a4_ = Hecke.Nemo._FiniteField(23, 2, "a") + R2, a2 = Native.finite_field(23, 1, "a") + R3, a3 = Native.finite_field(ZZRingElem(23), 1, "a") + R4, a4 = Native.finite_field(23, 2, "a") + R4_, a4_ = finite_field(23, 2, "a") E1 = EllipticCurve(R1, [2, 3]) E2 = EllipticCurve(R2, [2, 3]) diff --git a/test/Misc/FiniteField.jl b/test/Misc/FiniteField.jl index 806df87728..f8711ccd9c 100644 --- a/test/Misc/FiniteField.jl +++ b/test/Misc/FiniteField.jl @@ -171,9 +171,9 @@ end @testset "FqField" begin for p in [31, 11, 101] - _ = Hecke.Nemo._GF(ZZRingElem(p), 2, "a") - _ = Hecke.Nemo._GF(ZZRingElem(p), 2, 'a') - F = Hecke.Nemo._GF(ZZRingElem(p), 2, :a) + _ = GF(ZZRingElem(p), 2, "a") + _ = GF(ZZRingElem(p), 2, 'a') + F = GF(ZZRingElem(p), 2, :a) G, mG = unit_group(F) #Test generator g = mG(G[1]) diff --git a/test/Misc/RelFinField.jl b/test/Misc/RelFinField.jl index 2d6322da4d..1eae50faf4 100644 --- a/test/Misc/RelFinField.jl +++ b/test/Misc/RelFinField.jl @@ -95,7 +95,7 @@ end end - F = Hecke.Nemo._GF(3^3, cached = false) + F = GF(3^3, cached = false) x = polynomial_ring(F, "x", cached = false)[2] K, gK = Hecke.Nemo._residue_field(x^2+1, "a") Kt, t = K["t"]