Skip to content

Commit

Permalink
Use padic_field/qadic_field and prepare deprecations (thofma#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
joschmitt authored and lgoettgens committed Sep 19, 2024
1 parent d0ba956 commit be9debd
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion examples/NFDB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ function _p_adic_regulator_coates(K::AbsSimpleNumField, p::IntegerUnion)
while true
(prec > 2^12 || working_prec > 2^12) && error("Something wrong")
imK =[LocalFieldValuationRingElem{PadicField, PadicFieldElem}[] for i in 1:degK]
Qp = PadicField(p, prec, cached = false)
Qp = padic_field(p, precision = prec, cached = false)
Zp = ring_of_integers(Qp)
dK = discriminant(OK)
r = maximum([ramification_index(P) for P in dp])
Expand Down
2 changes: 1 addition & 1 deletion examples/Plesken.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function primitive_root_r_div_qm1(R, r::Int)
end

function get_f(r::Int, p::ZZRingElem, s::Int)
R = PadicField(r, s)
R = padic_field(r, precision = s)
return lift(teichmuller(R(p)))
end
# plan
Expand Down
2 changes: 1 addition & 1 deletion examples/Tropics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ lp[1].gen_two*lp[2].gen_two^2
ma = representation_matrix(a)
mb = representation_matrix(k(ans))
@assert iszero(ma*mb - mb*ma)
Qp = PadicField(7, 10)
Qp = padic_field(7, precision = 10)
Main.TropicalModule.simultaneous_diagonalization([map_entries(Qp, ma), map_entries(Qp, mb)])
=#
Expand Down
7 changes: 7 additions & 0 deletions src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,10 @@ end
# Deprecated in 0.33.0

@deprecate rres reduced_resultant

# To be deprecated in 0.34.0

#@deprecate lift(a::LocalFieldValuationRingElem) lift(ZZ, a)
lift(a::LocalFieldValuationRingElem) = lift(ZZ, a)
#@deprecate prime_field(L::Union{QadicField, LocalField}) absolute_base_field(L)
prime_field(L::Union{QadicField, LocalField}) = absolute_base_field(L)
4 changes: 2 additions & 2 deletions src/HeckeTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2241,11 +2241,11 @@ mutable struct qAdicRootCtx
lf = Hecke.factor_mod_pk(Array, H, 1)
if splitting_field
d = lcm([degree(y[1]) for y = lf])
R = QadicField(p, d, 1)[1]
R = qadic_field(p, d, precision = 1)[1]
Q = [R]
r.is_splitting = true
else
Q = [QadicField(p, x, 1)[1] for x = Set(degree(y[1]) for y = lf)]
Q = [qadic_field(p, x, precision = 1)[1] for x = Set(degree(y[1]) for y = lf)]
r.is_splitting = false
end
@assert all(x->isone(x[2]), lf)
Expand Down
14 changes: 7 additions & 7 deletions src/LocalField/Completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ function completion(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumF
f = degree(P)
e = ramification_index(P)
prec_padics = div(precision+e-1, e)
Qp = PadicField(minimum(P), prec_padics, cached = false)
Qp = padic_field(minimum(P), precision = prec_padics, cached = false)
Zp = maximal_order(Qp)
Qq, gQq = QadicField(minimum(P), f, prec_padics, cached = false)
Qq, gQq = qadic_field(minimum(P), f, precision = prec_padics, cached = false)
Qqx, gQqx = polynomial_ring(Qq, "x")
q, mq = residue_field(Qq)
#F, mF = ResidueFieldSmall(OK, P)
Expand Down Expand Up @@ -336,7 +336,7 @@ function setprecision!(f::CompletionMap{LocalField{QadicFieldElem, EisensteinLoc
gq = _increase_precision(gq, pol_gq, div(f.precision+e-1, e), ex, P)
f.inv_img = (gq, f.inv_img[2])

Zp = maximal_order(prime_field(Kp))
Zp = maximal_order(absolute_base_field(Kp))
Qq = base_field(Kp)

setprecision!(Qq, ex)
Expand Down Expand Up @@ -384,7 +384,7 @@ function totally_ramified_completion(K::AbsSimpleNumField, P::AbsNumFieldOrderId
@assert nf(OK) == K
@assert isone(degree(P))
e = ramification_index(P)
Qp = PadicField(minimum(P), precision)
Qp = padic_field(minimum(P), precision = precision)
Zp = maximal_order(Qp)
Zx = FlintZZ["x"][1]
Qpx = polynomial_ring(Qp, "x")[1]
Expand Down Expand Up @@ -443,7 +443,7 @@ function setprecision!(f::CompletionMap{LocalField{PadicFieldElem, EisensteinLoc
if r > 0
ex += 1
end
Qp = PadicField(prime(Kp), div(new_prec, e)+1)
Qp = padic_field(prime(Kp), precision = div(new_prec, e) + 1)
Zp = maximal_order(Qp)
Qpx, _ = polynomial_ring(Qp, "x")
pows_u = powers(u, e-1)
Expand Down Expand Up @@ -495,8 +495,8 @@ function unramified_completion(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{Ab
@assert isone(ramification_index(P))
f = degree(P)
p = minimum(P)
Qq, gQq = QadicField(p, f, precision)
Qp = PadicField(p, precision)
Qq, gQq = qadic_field(p, f, precision = precision)
Qp = padic_field(p, precision = precision)
Zp = maximal_order(Qp)
q, mq = residue_field(Qq)
F, mF = residue_field(OK, P)
Expand Down
10 changes: 5 additions & 5 deletions src/LocalField/Conjugates.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#XXX: valuation(Q(0)) == 0 !!!!!
function newton_lift(f::ZZPolyRingElem, r::QadicFieldElem, prec::Int = parent(r).prec_max, starting_prec::Int = 2)
function newton_lift(f::ZZPolyRingElem, r::QadicFieldElem, prec::Int = precision(parent(r)), starting_prec::Int = 2)
Q = parent(r)
n = prec
i = n
Expand All @@ -19,22 +19,22 @@ function newton_lift(f::ZZPolyRingElem, r::QadicFieldElem, prec::Int = parent(r)
for p = reverse(chain)
setprecision!(r, p)
setprecision!(o, p)
Q.prec_max = r.N
setprecision!(Q, r.N)
if r.N > precision(Q)
setprecision!(qf, r.N)
setprecision!(qfs, r.N)
end
r = r - qf(r)*o
if r.N >= n
Q.prec_max = n
setprecision!(Q, n)
return r
end
o = o*(2-qfs(r)*o)
end
return r
end

function newton_lift(f::ZZPolyRingElem, r::LocalFieldElem, precision::Int = parent(r).prec_max, starting_prec::Int = 2)
function newton_lift(f::ZZPolyRingElem, r::LocalFieldElem, precision::Int = precision(parent(r)), starting_prec::Int = 2)
Q = parent(r)
n = precision
i = n
Expand Down Expand Up @@ -93,7 +93,7 @@ function roots(C::qAdicRootCtx, n::Int = 10)
lf = factor_mod_pk(Array, C.H, n)
rt = QadicFieldElem[]
for Q = C.Q
Q.prec_max = n
setprecision!(Q, n)
for x = lf
if is_splitting(C) || degree(x[1]) == degree(Q)
append!(rt, roots(Q, x[1], max_roots = 1))
Expand Down
2 changes: 1 addition & 1 deletion src/LocalField/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ function divexact(a::LocalFieldElem, b::Union{Integer, ZZRingElem}; check::Bool=
e = absolute_ramification_index(K)
v = valuation(b, p)
iszero(a) && return setprecision(a, precision(a) - v*e)
Qp = prime_field(K)
Qp = absolute_base_field(K)
old = precision(Qp)
setprecision!(Qp, e*precision(a)+ Int(_valuation_integral(a)) + v)
bb = inv(Qp(b))
Expand Down
11 changes: 1 addition & 10 deletions src/LocalField/LocalField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ end
#
################################################################################

function prime_field(L::Union{QadicField, LocalField})
L = base_ring(defining_polynomial(L))
while typeof(L) != PadicField
L = base_ring(defining_polynomial(L))
end
return L
end


function base_field(L::LocalField)
return base_ring(defining_polynomial(L))
end
Expand Down Expand Up @@ -366,7 +357,7 @@ end

function local_field(f::QQPolyRingElem, p::Int, precision::Int, s::VarName, ::Type{T} = GenericLocalField; check::Bool = true, cached::Bool = true) where T <: LocalFieldParameter
@assert is_prime(p)
K = PadicField(p, precision)
K = padic_field(p, precision = precision)
fK = map_coefficients(K, f, cached = false)
return local_field(fK, s, T, cached = cached, check = check)
end
Expand Down
4 changes: 2 additions & 2 deletions src/LocalField/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function setcoeff!(c::Generic.Poly{T}, n::Int, a::T) where {T <: Union{PadicFiel
end

#TODO: find better crossover points
# qp = PadicField(3, 10);
# qp = padic_field(3, precision = 10);
# qpt, t = qp["t"]
# E = eisenstein_extension(cyclotomic(3, gen(Hecke.Globals.Zx))(t+1))[1]
# Es, s = E["s"]
Expand Down Expand Up @@ -747,7 +747,7 @@ function characteristic_polynomial(f::Generic.Poly{T}, g::Generic.Poly{T}) where
error("Not yet implemented")
end
d1 = clog(ZZRingElem(degree(f)+1), p)
L = QadicField(p, d1, min(precision(f), precision(g)))
L = qadic_field(p, d1, precision = min(precision(f), precision(g)))
Lt = polynomial_ring(L, "t")[1]
fL = map_coefficients(L, f, parent = Lt)
gL = map_coefficients(L, g, parent = Lt)
Expand Down
14 changes: 7 additions & 7 deletions src/LocalField/neq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function coordinates(a::Union{QadicFieldElem, LocalFieldElem}, k)
return c
end
coordinates(a::PadicFieldElem, ::PadicField) = [a]
lift(a::Hecke.LocalFieldValuationRingElem{PadicField, PadicFieldElem}) = lift(a.x)
lift(R::Ring, a::Hecke.LocalFieldValuationRingElem{PadicField, PadicFieldElem}) = lift(R, a.x)

function setprecision!(A::Generic.MatSpaceElem{Hecke.LocalFieldValuationRingElem{PadicField, PadicFieldElem}}, n::Int)
for i=1:nrows(A)
Expand Down Expand Up @@ -255,7 +255,7 @@ function solve_1_units(a::Vector{T}, b::T) where T
cur_a = copy(a)
cur_b = b
# @assert degree(K) == e
Qp = prime_field(K)
Qp = absolute_base_field(K)
Zp = ring_of_integers(Qp)
expo_mult = identity_matrix(ZZ, length(cur_a))
#transformation of cur_a to a
Expand Down Expand Up @@ -565,7 +565,7 @@ struct MapEvalCtx
map::Generic.MatSpaceElem{PadicFieldElem}

function MapEvalCtx(M::LocalFieldMor)
mat = matrix(prime_field(domain(M)),
mat = matrix(absolute_base_field(domain(M)),
absolute_degree(domain(M)),
absolute_degree(codomain(M)),
reduce(vcat, [absolute_coordinates(M(x))
Expand Down Expand Up @@ -778,7 +778,7 @@ function local_fundamental_class_serre(mKL::LocalFieldMor)
#thus Gal(E/base_field(L)) = Gal(L/base_field(L)) x unram of base_field
bL = base_field(L)
E2, _ = unramified_extension(map_coefficients(x->bL(coeff(x, 0)), defining_polynomial(E), cached = false))
G2 = automorphism_list(E2, prime_field(E2))
G2 = automorphism_list(E2, absolute_base_field(E2))
GG = morphism_type(E)[]
for e = G2
ime = e(gen(E2))
Expand All @@ -794,7 +794,7 @@ function local_fundamental_class_serre(mKL::LocalFieldMor)
@assert length(GG) == divexact(absolute_degree(E), absolute_degree(K))
# @assert all(x->x in GG, automorphism_list(E, K))
else
GG = automorphism_list(E, prime_field(E))
GG = automorphism_list(E, absolute_base_field(E))
gK = map(E, gK)
GG = [g for g = GG if map(g, gK) == gK]
end
Expand Down Expand Up @@ -828,7 +828,7 @@ function local_fundamental_class_serre(mKL::LocalFieldMor)
beta = []
sigma_hat = []
#need to map and compare all generators
gL = gens(L, prime_field(L))
gL = gens(L, absolute_base_field(L))
imGG = map(x->map(x, map(E, gL)), GG)
imG = map(x->map(x, gL), G)

Expand Down Expand Up @@ -1367,7 +1367,7 @@ function is_local_norm(k::Hecke.AbsSimpleNumField, a::ZZRingElem)
end
continue
end
Qp = PadicField(p, prec)
Qp = padic_field(p, precision = prec)
#for each P we need
# - a gen (pi) for the valuation
# - a gen for the residue field
Expand Down
6 changes: 3 additions & 3 deletions src/LocalField/pAdic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function my_log_one_minus(x::PadicFieldElem)
pp = prime(parent(x), 2)
X = 1-x
while true
y = lift(1-X) % pp
y = lift(ZZ, 1-X) % pp
lg += parent(x)(my_log_one_minus_inner(y, precision(x), le, prime(parent(x))))
X = X*inv(parent(x)(1-y))
pp *= pp
Expand Down Expand Up @@ -76,10 +76,10 @@ function my_log_one_minus(x::QadicFieldElem)
pp = prime(parent(x))^2
X = 1-x
R, _ = polynomial_ring(QQ, cached = false)
S, _ = residue_ring(R, map_coefficients(x->QQ(lift(x)), defining_polynomial(parent(x)), parent = R))
S, _ = residue_ring(R, map_coefficients(x->QQ(lift(ZZ, x)), defining_polynomial(parent(x)), parent = R))
while true
Y = 1-X
y = S(R([lift(coeff(Y, i)) % pp for i=0:length(Y)]))
y = S(R([lift(ZZ, coeff(Y, i)) % pp for i=0:length(Y)]))
lg += parent(x)(my_log_one_minus_inner(y, precision(x), le, prime(parent(x))).data)
X = X*inv(parent(x)(1-y.data))
pp *= pp
Expand Down
2 changes: 1 addition & 1 deletion src/LocalField/qAdic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function lift_reco(::QQField, a::PadicFieldElem; reco::Bool = false)
return x*prime(R, v)
end
else
return lift(FlintQQ, a)
return lift(QQ, a)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/Misc/UnitsModM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function disc_log_mod(a::ZZRingElem, b::ZZRingElem, M::ZZRingElem)
@assert (b-1) % 8 == 0
@assert (a^2-1) % 8 == 0
if fM[p] > 3
F = PadicField(p, fM[p], cached = false)
F = padic_field(p, precision = fM[p], cached = false)
g += 2*lift(divexact(log(F(b)), log(F(a^2))))
end
return g
Expand Down
2 changes: 1 addition & 1 deletion src/NumField/NfAbs/MPolyAbsFact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ function field(RC::RootCtx, m::MatElem)

@vprintln :AbsFact 1 "target field has (local) degree $k"

Qq = QadicField(characteristic(F), k, 1, cached = false)[1]
Qq = qadic_field(characteristic(F), k, precision = 1, cached = false)[1]
Qqt = polynomial_ring(Qq, cached = false)[1]
k, mk = residue_field(Qq)

Expand Down
2 changes: 1 addition & 1 deletion src/QuadForm/Quad/NormalForm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function _padic_normal_form(G::QQMatrix, p::ZZRingElem; prec::Int = -1, partial:

n = ncols(Gmod)

Qp = PadicField(p, prec, cached = false)
Qp = padic_field(p, precision = prec, cached = false)

if n == 0
return (zero_matrix(FlintQQ, n, n), zero_matrix(FlintQQ, n, n))::Tuple{QQMatrix, QQMatrix}
Expand Down
Loading

0 comments on commit be9debd

Please sign in to comment.